on_actions = {
	# country
	on_new_term_election = {
		random_events = {
			100 = usa.6
			100 = usa.7
			100 = usa.8
			100 = usa.9
			100 = usa.10
			100 = usa.11
			100 = usa.12
		}
		random_events = {
			100 = spain.9
			100 = lar_spain.1
		}
		random_events = {
			100 = LSM_equipment.12
		}
		random_events = {
			100 = election.2
			100 = election.3
			100 = election.4
			100 = election.5
			100 = election.6
			100 = election.11
			100 = election.12
			100 = election.13
			100 = election.14
			100 = election.15
		}
	}

	on_daily_SWE = {
		effect = {
			if = {
				limit = {
					#is_ironman =  = yes
					original_tag = SWE
					has_completed_focus = SWE_per_albin_bus
					divisions_in_state = {
						state = 141
						size > 0 # use < or ><state_id>
						unit = bus # optional. specific unit eg. mountaineers, light_tank
					}
				}
				set_variable = { global.achievement_days_since_bus_left_stockholm = 0 }
		
			}

			if = {
				limit = {
					divisions_in_state = {
						state = 141
						size < 1 # use < or ><state_id>
						unit = bus # optional. specific unit eg. mountaineers, light_tank
					}
					check_variable = { global.achievement_days_since_bus_left_stockholm < 100 }
				}
				add_to_variable = { global.achievement_days_since_bus_left_stockholm = 1 }
			}
			
			if = {
				limit = {
					original_tag = SWE
					has_completed_focus = SWE_per_albin_bus
					divisions_in_state = {
						state = 681
						size > 0 # use < or ><state_id>
						unit = bus # optional. specific unit eg. mountaineers, light_tank
					}

					check_variable = { global.achievement_days_since_bus_left_stockholm < 19 }
				}

				set_global_flag = achievement_has_managed_to_travel_to_cape_town_in_18_days
			}
		}
	}

	# Ace pilots
	# country, FROM = ace
	on_ace_promoted = {
		random_events = {
			100 = ace_promoted.1
			5 = ace_promoted.2
		}
	}

	# country, FROM = ace, PREV = enemy ace
	# This event fires twice, once for each ace.
	on_aces_killed_each_other = {
		random_events = {
			100 = aces_killed_each_other.1
		}
	}

	# country, FROM = our ace,
	# PREV = enemy ace, has killed FROM
	on_ace_killed_by_ace = {
		random_events = {
			100 = ace_killed_by_ace.1
		}
	}

	# country, FROM = our ace,
	# PREV = enemy ace, killed by FROM
	on_ace_killed_other_ace = {
		random_events = {
			100 = ace_killed_other_ace.1
		}
	}

	# our ace is killed by no name
	# country, FROM = ace
	on_ace_killed = {
		random_events = {
			100 = ace_died.1
		}
	}

	# our ace died in accident
	# country, FROM = ace
	on_ace_killed_on_accident = {

	}

	# enemy ace is killed by our non name
	# country, FROM = enemy ace
	on_non_ace_killed_other_ace = {

	}

	# During justifying wargoals
	# triggered daily, so make sure there is a sink somewhere not firing events
	# country, FROM = target nation
	on_justifying_wargoal_pulse = {

		random_events = {
			100 = war_justification.1
			100 = war_justification.2
			100 = war_justification.3
			100 = war_justification.4
			100 = war_justification.5
			100 = war_justification.6
			100 = war_justification.7
			100 = war_justification.8
			100 = war_justification.9
			100 = war_justification.10
			100 = war_justification.11
			100 = war_justification.12
			100 = war_justification.13
			100 = war_justification.14
			100 = war_justification.15
			100 = war_justification.16
			100 = war_justification.17
			100 = war_justification.18
			100 = war_justification.19
			17000 = 0
		}
	}

	on_wargoal_expire = {
		random_events = {
			100 = war_justification.301
		}
	}

	on_nuke_drop = {

		effect = {
			set_global_flag = first_nuke_dropped
			if = {
				limit = { NOT = { has_global_flag = first_nuke_dropped } }
				country_event = { id = generic.8 }
			}
			if = {
				limit = { has_idea = race_for_the_bomb_outclassed }
				remove_ideas = race_for_the_bomb_outclassed
			}
			if = {
				limit = { NOT = { has_country_flag = achievement_has_dropped_nuke } }
				goto_state = FROM
				set_country_flag = achievement_has_dropped_nuke
			}
			if = {
				limit = {
					FROM = { state = 378 }
				}
				set_country_flag = achievement_has_nuked_california
			}
			if = {
				limit = {
					FROM = { is_core_of = AST }
				}
				set_country_flag = achievement_AST_nuke_self
			}
			if = {
				limit = {
					tag = SWE
					FROM = {
						is_owned_by = DEN
						is_core_of = DEN
					}
				}
				set_country_flag = achievement_med_plutonium
			}

			if = { #Med Plutonium 2 
				limit = {
					tag = DEN
					FROM = {
						is_owned_by = SWE
						is_core_of = SWE
					}
				}
				set_country_flag = achievement_med_plutonium_2
			}
			if = {
				limit = {
					FROM = {
						is_core_of = JAP
					}
					has_global_flag = JAP_nuke_4
					NOT = {
						has_global_flag = JAP_nuke_5
					}
				}
				set_global_flag = JAP_nuke_5
				ROOT = { set_country_flag = nuked_japan_5 }
			}
			if = {
				limit = {
					FROM = {
						is_core_of = JAP
					}
					has_global_flag = JAP_nuke_3
					NOT = {
						has_global_flag = JAP_nuke_4
					}
				}
				set_global_flag = JAP_nuke_4
				ROOT = { set_country_flag = nuked_japan_4 }
			}
			if = {
				limit = {
					FROM = {
						is_core_of = JAP
					}
					has_global_flag = JAP_nuke_2
					NOT = {
						has_global_flag = JAP_nuke_3
					}
				}
				set_global_flag = JAP_nuke_3
				ROOT = { set_country_flag = nuked_japan_3 }
			}
			if = {
				limit = {
					FROM = {
						is_core_of = JAP
					}
					has_global_flag = JAP_nuke_1
					NOT = {
						has_global_flag = JAP_nuke_2
					}
				}
				set_global_flag = JAP_nuke_2
				ROOT = { set_country_flag = nuked_japan_2 }
			}
			if = {
				limit = {
					FROM = {
						is_core_of = JAP
					}
					NOT = {
						has_global_flag = JAP_nuke_1
					}
				}
				set_global_flag = JAP_nuke_1
				ROOT = { set_country_flag = nuked_japan_1 }
			}
			if = {
				limit = {
					FROM = {
						state = 953
					}
					NOT = {
						has_global_flag = land_of_fire_flag
					}
				}
				set_global_flag = land_of_fire_flag
			}

			news_event = { id = nuke_dropped.2 days = 1}
			news_event = { id = nuke_dropped.3 days = 1}
			news_event = { id = nuke_dropped.4 days = 1}
			news_event = { id = nuke_dropped.5 days = 1}
			news_event = { id = nuke_dropped.6 days = 1}
			news_event = { id = nuke_dropped.7 days = 1}
			news_event = { id = nuke_dropped.8 days = 1}
			news_event = { id = nuke_dropped.9 days = 1}
			news_event = { id = nuke_dropped.10 days = 1}
			news_event = { id = nuke_dropped.11 days = 1}
			news_event = { id = nuke_dropped.12 days = 1}
			news_event = { id = nuke_dropped.13 days = 1}
		}
		random_events = {
			100 = nuke_dropped.0
		}
	}

	# country random events
	#on_bi_yearly_pulse = {
	#
	#}

	#on_five_year_pulse = {
	#
	#}

	on_border_war_lost = {
		effect = {
			owner = {
				country_event = { id = china.14 }
				country_event = { id = china.16 }
			}
		}
	}

	on_leave_faction = {
		effect = {
			if = {
				limit = {
					has_country_flag = TO_joined_brussels_treaty
				}
				clr_country_flag = TO_joined_brussels_treaty
			}
			if = {
				limit = {
					AND = {
						tag = CAN
						NOT = { has_dlc = "Together for Victory" }
					}
				}
				abandon_colony_tag = yes
			}
			FROM = {
				add_opinion_modifier = {
					modifier = faction_traitor
					target = ROOT
					days = 365
				}

				add_opinion_modifier = {
					modifier = faction_traitor_trade
					target = ROOT
					days = 365
				}
			}
		}
	}

	#FROM is the one that joins the faction
	on_create_faction = {
		effect = {
			# Sunset invasion check
			if = {
				limit = {
					FROM = { is_puppet = no }
					OR = {
						AND = {
							tag = MEX
							FROM = {
								capital_scope = {
									NOT = { is_on_continent = south_america }
								}
							}
						}
						AND = {
							FROM = {
								tag = MEX
							}
							capital_scope = {
								NOT = { is_on_continent = south_america }
							}
						}
					}
				}
				set_country_flag = achievement_failed_sunset_invasion
			}
		}
	}

	#FROM is country getting invited.
	on_offer_join_faction = {
		effect = {
			#Give achievement to nation joining a faction, but not in one from game start
			if = {
				limit = {
					date > 1936.01.02
				}
				FROM = {
					if = {
						limit = {
							is_faction_leader = no
						}
						set_country_flag = achievement_has_joined_faction
					}
				}
			}
			#Remove anti_soviet_pact if joining commie Soviet in faction
			if = {
				limit = {
					original_tag = SOV
					has_government = communism
					FROM = {
						has_idea = anti_soviet_pact
					}
				}
				FROM = {
					remove_ideas = anti_soviet_pact
				}
			}

			# Sunset invasion check
			if = {
				limit = {
					is_puppet = no
					OR = {
						AND = {
							tag = MEX
							FROM = {
								capital_scope = {
									NOT = { is_on_continent = south_america }
								}
							}
						}
						AND = {
							FROM = {
								tag = MEX
							}
							capital_scope = {
								NOT = { is_on_continent = south_america }
							}
						}
					}
				}
				set_country_flag = achievement_failed_sunset_invasion
			}
		}
	}

	#FROM is faction leader on join faction requests. THIS DOES NOT FIRE ON ADD_TO_FACTION EFFECT! USE ON_OFFER_JOIN_FACTION!
	on_join_faction = {
		effect = {
			set_country_flag = achievement_has_joined_faction
			#Remove anti_soviet_pact if joining commie Soviet in faction
			if = {
				limit = {
					has_idea = anti_soviet_pact
					FROM = {
						original_tag = SOV
						has_government = communism
					}
				}
				remove_ideas = anti_soviet_pact
			}

			# Sunset invasion check
			if = {
				limit = {
					is_puppet = no
					OR = {
						AND = {
							tag = MEX
							FROM = {
								capital_scope = {
									NOT = { is_on_continent = south_america }
								}
							}
						}
						AND = {
							FROM = {
								tag = MEX
							}
							capital_scope = {
								NOT = { is_on_continent = south_america }
							}
						}
					}
				}
				set_country_flag = achievement_failed_sunset_invasion
			}

			# Romania shouldn't declare war on Bulgaria on historical mode, if both are going to join the Axis
			if = {
				limit = {
					original_tag = BUL
					FROM = { original_tag = GER }
					is_historical_focus_on = yes
				}
				ROM = {
					add_ai_strategy = {
						type = befriend
						id = "BUL"
						value = 200
					}
				}
			}
		}
	}

	#FROM is war target
	on_declare_war = {
		effect = {
			#make sure Germany doesn't force ideology on France for the achievement
			if = {
				limit = {
					FROM = { original_tag = FRA }
					tag = GER
				}
				set_country_flag = invalid_for_danzig_achievement
			}
			#make sure warlords don't use the same guy
			if = {
				limit = {
					OR = {
						original_tag = YUN
						original_tag = SIK
						original_tag = GXC
						original_tag = SHX
						original_tag = XSM
					}
				}
				if = {
					limit = {
						ROOT = {
							original_tag = FROM
							NOT = { has_country_flag = warlord_replaced }
						}
					}
					ROOT = {
						retire_country_leader = yes
						set_country_flag = warlord_replaced
					}
					FROM = {
						warlord_rule_all_parties = yes
					}
				}
			}
			#make sure Dominions lose the dominion tag
			if = {
				limit = {
					OR = {
						original_tag = CAN
						original_tag = RAJ
						original_tag = MAL
						original_tag = INS
					}
				}
				if = {
					limit = {
						ROOT = {
							original_tag = FROM
						}
					}
					abandon_colony_tag = yes
					FROM = {
						abandon_colony_tag = yes
					}
				}
			}
			if = {
				limit = {
					FROM = {
						OR = {
							has_idea = american_protection_drift_democratic
							has_idea = american_protection_drift_communism
							has_idea = american_protection_drift_fascism
							has_idea = american_protection_defence_democratic
							has_idea = american_protection_defence_communism
							has_idea = american_protection_defence_fascism
						}
					}
					NOT = {
						tag = USA
						is_in_faction_with = USA # I guess USA will not go to war with someone they are in faction with
						has_war_with = USA
						#USA = { has_war_with = FROM } Should USA enforce peace in a nation it is already at war with?
					}
					OR = {
						has_idea = american_protection_drift_democratic
						has_idea = american_protection_drift_communism
						has_idea = american_protection_drift_fascism
						has_idea = american_protection_defence_democratic
						has_idea = american_protection_defence_communism
						has_idea = american_protection_defence_fascism
					}
				}
				FROM = { country_event = { id = usa.16 days = 1 } }
			}

			# Remove pact opinion modifiers if at war with Germany
			if = {
				limit = {
					tag = GER
					FROM = {
						OR = {
							has_opinion_modifier = anti_comintern_pact_opinion
							has_opinion_modifier = tripartite_pact_opinion
							has_idea = anti_soviet_pact
						}
					}
				}
				FROM = {
					remove_opinion_modifier = { target = GER modifier = anti_comintern_pact_opinion }
					remove_opinion_modifier = { target = GER modifier = tripartite_pact_opinion }
					remove_ideas = anti_soviet_pact
				}
			}
			#Germany has started a war - allies should try to contain Germany
			if = {
				limit = {
					ROOT = {
						TAG = GER
					}
					NOT = {
						has_global_flag = GER_has_started_war
					}
				}
				set_global_flag = GER_has_started_war
			}



			#Call Anti-Soviet pact members to war
			if = {
				limit = {
					ROOT = {
						original_tag = SOV
						has_government = communism
					}
					FROM = { has_idea = anti_soviet_pact }
				}
				save_event_target_as = anti_soviet_pact_aggressor
				FROM = {
					country_event = { id = germany.84 days = 1 }
				}
			}

			#Remove MEFO bills if Germany goes to war
			if = {
				limit = {
					ROOT = { original_tag = GER }
					ROOT = { GER_has_mefo_bills = yes }
					NOT = { FROM = { original_tag = GER } } # Don't remove it from Fascist Germany if they start the civil war
				}
				ROOT = {
					GER_remove_mefo_bills = yes
					set_country_flag = mefo_bills_removed_through_war
				}
			}

			#Remove MEFO bills if Germany is declared war on
			if = {
				limit = {
					FROM = { original_tag = GER }
					FROM = { GER_has_mefo_bills = yes }
				}
				FROM = {
					GER_remove_mefo_bills = yes
					set_country_flag = mefo_bills_removed_through_war
				}
			}

			#Remove previous ideology civil war faction from Democratic Germany faction and add Democratic civil war faction to Germany's faction
			if = {
				limit = {
					FROM = {
						is_in_faction_with = GER
					#	has_civil_war = yes
						NOT = { has_government = democratic }
					}
					has_government = democratic
					GER = { has_government = democratic }
				}
				FROM = { set_country_flag = GER_civil_war_target }
				GER = { remove_from_faction = FROM }
				GER = { add_to_faction = ROOT }
				GER = { country_event = wtt_germany.52 }
			}

			#If prepared by siphoning equipment, receive equipment back
			if = {
				limit = {
					FROM = {
						has_civil_war = yes
						has_country_flag = siphoned_equipment_stockpiles_for_civil_war
					}
					has_civil_war = yes
				}
				FROM = {
					clr_country_flag = siphoned_equipment_stockpiles_for_civil_war
					add_equipment_to_stockpile = {
						type = infantry_equipment
						amount = 1000
					}
				}
			}

			#If prepared with surprise attack plan, get bonus
			if = {
				limit = {
					FROM = {
						original_tag = ROOT
						#has_civil_war = yes
						has_country_flag = formulated_surprise_attack_plan_for_civil_war
					}
					#has_civil_war = yes
				}
				FROM = {
					clr_country_flag = formulated_surprise_attack_plan_for_civil_war
					add_timed_idea = {
						idea = civil_war_surprise_attack_plan
						days = 30
					}
				}
			}

			if = {
				limit = {
					FROM = {
						has_civil_war = yes
						original_tag = SPR
					}
					has_civil_war = yes
					original_tag = SPR

				}
				random_country = {
					limit = {
						original_tag = FRA
						OR = {
							has_completed_focus = FRA_right_wing_rhetoric
							has_completed_focus = FRA_utilize_the_leagues
						}
					}
					country_event = { id = france.32 }
				}
			}
		}
	}

	# When a new faction is formed
	on_faction_formed = {
		effect = {
			news_event = { id = news.159 }
		}
	}

	# ROOT is capitulated country, FROM is winner
	on_capitulation = {
		effect = {
			if = {
				limit = {
					tag = SOV
					FIN = {
						has_war_with = SOV
						is_in_faction = no
						is_ai = no
						controls_state = 219
						any_war_score > 14
					}
					NOT = { has_global_flag = finnish_him_achievement_flag }
				}
				set_global_flag = finnish_him_achievement_flag
			}
			if = {
				limit = {
					tag = GER
					FROM = {
						tag = SOV
					}
					NOT = { has_global_flag = fall_of_berlin_sov }
				}
				play_victory_parade_effect = yes
			}
			if = {
				limit = {
					tag = GER
				}
				8 = {
					if = {
						limit = { is_core_of = ROOT }
						remove_core_of = ROOT
					}
				}
				28 = {
					if = {
						limit = { is_core_of = ROOT }
						remove_core_of = ROOT
					}
				}
				807 = {
					if = {
						limit = { is_core_of = ROOT }
						remove_core_of = ROOT
					}
				}
				85 = {
					if = {
						limit = { is_core_of = ROOT }
						remove_core_of = ROOT
					}
				}
				if = {
					limit = { has_government = fascism }
					69 = {
						if = {
							limit = { is_core_of = ROOT }
							remove_core_of = ROOT
						}
					}
					74 = {
						if = {
							limit = { is_core_of = ROOT }
							remove_core_of = ROOT
						}
					}
				}
			}
			if = {
				limit = {
					NOT = { original_tag = GER }
					NOT = { has_government = fascism }
					has_civil_war = no
					NOT = {
						AND = {
							FROM = {
								original_tag = SPR
							}
							original_tag = SPR
						}
					}
				}
				news_event = { id = country_capitulated.0 days = 0 }
			}
			if = {
				limit = { tag = FRA }
				set_global_flag = FRA_already_surrendered
				set_variable = { global.FRA_capitulation_days = global.num_days }
			}
			if = {
				limit = {
					FROM = { tag = JAP }
					ROOT = { tag = CHI }
				}
				JAP = { JAP_intervene_in_china_remove = yes }
			}

			if = {
				limit = {
					original_tag = POL
					has_government = neutrality
					NOT = { has_completed_focus = POL_fulfil_fifth_of_november }
				}
				retire_country_leader = yes
			}
			if = {
				limit = {
					original_tag = YUG
				}
				remove_ideas = YUG_idea_economic_aid
			}
			if = {
				limit = {
					NOT = { has_dlc = "Arms Against Tyranny"} # AAT uses separate system
					original_tag = DEN
					any_country = {
						OR = {
							tag = ROOT
							is_in_faction_with = ROOT
						}
						100 = { is_controlled_by = PREV }
					}

				}
				country_event = { id = wtt_denmark.1 days = 1 }
			}
			if = {
				limit = {
					original_tag = FRA
					has_government = democratic
					NOT = { has_global_flag = achievement_france_surrender } #might as well use the achievement flag to check if france.10 fired
					16 = { is_controlled_by = GER } # Don't fire if someone else is the occupier of Paris
					is_subject = no
					is_in_faction_with = ENG
					has_war_with = GER
				}
				# Revoke all guarantees
				every_other_country = {
					limit = {
						is_guaranteed_by = ROOT
					}
					ROOT = {
						diplomatic_relation = {
							country = PREV
							relation = guarantee
							active = no
						}
					}
				}
				country_event = france.10
			}
			if = {
				limit = {
					original_tag = GER
					has_government = fascism
				}
				set_global_flag = germany_lost_the_war
			}

			if = {
				limit= {
					ROOT = {
						original_tag = ENG
					}
					FROM = {
						original_tag = ICE
					}
				}

				set_global_flag = achivement_ice_capitulated_eng
			}
		}
	}

	# ROOT is previously capitulated country
	on_uncapitulation = {
		effect = {
			if = {
				limit = {
					original_tag = FRA
					has_government = democratic
					is_puppet = no
				}
				drop_cosmetic_tag = yes
			}
		}
	}
	#ROOT is capitulated country, FROM is winner.
	on_capitulation_immediate = {
		effect = {
			if = {
				limit = {
					ROOT = {
						original_tag = BEL
						is_in_faction = yes
						#is_government_in_exile = yes
					}
				}
				if = {
					limit = {
						295 = {
							is_fully_controlled_by = ROOT
						}
					}
					295 = { set_state_flag = prevent_auto_flip_after_capitulation }
				}

				if = {
					limit = {
						538 = {
							is_fully_controlled_by = ROOT
						}
					}

					538 = { set_state_flag = prevent_auto_flip_after_capitulation }
				}

				if = {
					limit = {
						888 = {
							is_fully_controlled_by = ROOT
						}
					}

					888 = { set_state_flag = prevent_auto_flip_after_capitulation }
				}

				if = {
					limit = {
						889 = {
							is_fully_controlled_by = ROOT
						}
					}
					889 = { set_state_flag = prevent_auto_flip_after_capitulation }

				}

				if = {
					limit = {
						890 = {
							is_fully_controlled_by = ROOT
						}
					}

					890 = { set_state_flag = prevent_auto_flip_after_capitulation }

				}

				if = {
					limit = {
						769 = {
							is_fully_controlled_by = ROOT
						}
					}

					769  = { set_state_flag = prevent_auto_flip_after_capitulation }
				}

				if = {
					limit = {
						768 = {
							is_fully_controlled_by = ROOT
						}
					}
					768 = { set_state_flag = prevent_auto_flip_after_capitulation }
				}

				if = {
					limit = {
						718 = {
							is_fully_controlled_by = ROOT
						}
					}
					718 = { set_state_flag = prevent_auto_flip_after_capitulation }
				}
			}
			
			if = {
				limit = {
					ROOT = {
						original_tag = FRA
						is_in_faction = yes
					}

					635 = { is_fully_controlled_by = ROOT }
				}

				635 = { set_state_flag = prevent_auto_flip_after_capitulation }
			}
		}
	}

	on_government_change = {
		effect = {
			#Make sure Soviet can always create factions
			if = {
				limit = {
					original_tag = SOV
					NOT = { has_government = communism }
				}
				set_rule = { can_create_factions = yes }
			}
			if = {
				limit = { has_government = democratic }
				if = {
					limit = { has_idea = democratic_opposition_voicing_protests }
					remove_ideas = democratic_opposition_voicing_protests
				}
				if = {
					limit = { has_idea = democratic_revolutionaries }
					remove_ideas = democratic_revolutionaries
				}
				if = {
					limit = { has_idea = reign_of_terror }
					remove_ideas = reign_of_terror
				}
			}
			if = {
				limit = { has_government = communism }
				if = {
					limit = { TAG = SAF }
					set_cosmetic_tag = SAF_COM
				}
				if = {
					limit = { has_idea = communist_partisans_recruiting }
					remove_ideas = communist_partisans_recruiting
				}
				if = {
					limit = { has_idea = communist_revolutionaries }
					remove_ideas = communist_revolutionaries
				}
				if = {
					limit = { has_idea = communism_defeated }
					remove_ideas = communism_defeated
				}

				#Remove anti_soviet_pact
				if = {
					limit = { has_idea = anti_soviet_pact }
					remove_ideas = anti_soviet_pact
				}
			}
			if = {
				limit = { has_government = fascism }
				if = {
					limit = { has_idea = fascist_assault_divisions }
					remove_ideas = fascist_assault_divisions
				}
				if = {
					limit = { has_idea = fascist_revolutionaries }
					remove_ideas = fascist_revolutionaries
				}
				if = {
					limit = { has_idea = fascism_defeated }
					remove_ideas = fascism_defeated
				}
				if = {
					limit = { has_idea = anti_nazi_coup }
					remove_ideas = anti_nazi_coup
				}
			}
			#Replace the following two with events for SOV if they are not communist.
			#if = {
			#	limit = {
			#		OR = {
			#			has_idea = trotskyite_plot
			#			has_idea = trotskyite_plot_purged
			#		}
			#		NOT = {
			#			has_civil_war = yes
			#		}
			#	}
			#	country_event = { id = soviet.54 }
			#}
		}
	}

	on_coup_succeeded = {
		effect = {
			#Turn elections on for democracies created from coup
			random_other_country = {
				limit = {
					has_government = democratic
					original_tag = ROOT
				}
				set_politics = {
					ruling_party = democratic
					elections_allowed = yes
				}
			}
		}
	}

	#ROOT is winner #FROM gets annexed - This will also fire on_annex
	on_civil_war_end = {
		effect = {

			#End of SCW
			if = {
				limit = {
					NOT = { has_dlc = "La Resistance" }
					FROM = {
						original_tag = SPR
					}
					ROOT = {
						original_tag = SPR
						has_government = fascism
					}
				}
				if = {
					limit = {
						OR = {
							is_historical_focus_on = no
							has_completed_focus = SPA_supremacy_of_the_communion
						}
					}
					add_timed_idea = { idea = SPA_recovering_from_civil_war days = 2190 }
				}
				if = {
					limit = {
						is_historical_focus_on = yes
						NOT = {
							has_completed_focus = SPA_supremacy_of_the_communion
						}
					}
					add_ideas = SPA_recovering_from_civil_war #keep the spirit on historical mode, keeping them out of the war
				}
			}
			#End of SCW
			if = {
				limit = {
					FROM = {
						original_tag = SPR
					}
					ROOT = {
						original_tag = SPR
						OR = {
							has_government = democratic
							has_government = communism
						}
					}
				}
				ROOT = {
					set_country_flag = achievement_won_spanish_civil_war
				}
			}
			if = {
				limit = {
					has_government = democratic
				}
				set_politics = {
					ruling_party = democratic
					elections_allowed = yes
				}
			}
			#End of German Civil War
			if = {
				limit = {
					FROM = {
						original_tag = GER
						has_government = fascism
					}
					original_tag = GER
					has_government = neutrality
					NOT = { is_subject_of = HOL }
				}
				set_global_flag = { flag = civil_war_olympics value = 1 days = 30 }
				country_event = { id = wtt_germany.18 days = 1 }
			}
			#End of US civil war
			if = {
				limit = {
					original_tag = USA
					OR = {
						has_government = neutrality
						has_government = fascism
					}
				}
				news_event = { id = mtg_news.7 days = 4 random_days = 5 }
			}
			#End of Balkan war
			if = {
				limit = {
					has_dlc = "Death or Dishonor"
					original_tag = YUG
				}
				every_other_country = {
					limit = {
						has_country_flag = yugoslav_puppet_flag
					}
					white_peace = PREV
					PREV = { puppet = PREV }
					set_autonomy = { target = THIS autonomy_state = autonomy_integrated_puppet }
				}
				if = {
					limit = {
						FROM = { has_focus_tree = yugoslavian_focus }
					}
					load_focus_tree = { tree = yugoslavian_focus keep_completed = yes }
					unlock_national_focus = YUG_end_the_regency
				}
			}
			#End of ideology Civil War
			if = {
				limit = {
					has_country_flag = ideology_civil_war
				}
				clr_country_flag = ideology_civil_war
				set_country_flag = { flag = won_ideology_civil_war value = 1 days = 365 }
				country_event = { id = generic.11 days = 1 }
			}
			if = {
				limit = {
					original_tag = BUL
					has_focus_tree = generic_focus
				}
				if = {
					limit = { has_idea = BUL_second_national_catastrophe }
					remove_ideas = BUL_second_national_catastrophe
				}
				if = {
					limit = { has_idea = BUL_second_national_catastrophe_02 }
					remove_ideas = BUL_second_national_catastrophe_02
				}
			}
		}
	}

	#used when puppeting in a peace conference
	#ROOT = nation being puppeted, FROM = overlord

	on_puppet = {
		effect = {
			if = {
				limit = {
					OR = {
						original_tag = DDR
						original_tag = WGR
						original_tag = GER
					}
					has_government = communism
					OR = {
						has_country_leader = { name = "Wilhelm Pieck" }
						has_country_leader = { character = GER_wilhelm_pieck }
					}
					FROM = {
						original_tag = SOV
						has_government = communism
						has_country_leader = { character = SOV_iosif_stalin } # Would look silly if Trotsky released Stalin's Puppet
					}
				}
				add_country_leader_trait = stalins_puppet
			}
			if = {
				limit = {
					NOT = { has_elections = yes }
					has_government = democratic
				}
				set_politics = {
					ruling_party = democratic
					elections_allowed = yes
				}
			}
		}
	}

	#used when puppeting through the occupied territories menu during peace time (or when releasing from non-core but owned territory, f.e. Britain releasing Egypt)
	#ROOT = nation being released, FROM = overlord

	on_release_as_puppet = {
		effect = {
			if = {
				limit = {
					OR = {
						original_tag = DDR
						original_tag = WGR
						original_tag = GER
					}
					has_government = communism
					OR = {
						has_country_leader = { name = "Wilhelm Pieck" }
						has_country_leader = { character = GER_wilhelm_pieck }
					}					FROM = {
						original_tag = SOV
						has_government = communism
						has_country_leader = { character = SOV_iosif_stalin } # Would look silly if Trotsky released Stalin's Puppet
					}
				}
				add_country_leader_trait = stalins_puppet
			}
			if = {
				limit = {
					NOT = { has_elections = yes }
					has_government = democratic
				}
				set_politics = {
					ruling_party = democratic
					elections_allowed = yes
				}
			}
		}
	}

	#ROOT is winner #FROM gets annexed - For civil wars on_civil_war_end is also fired
	on_annex = {
		effect = {
			every_country = {
				limit = {
					OR = {
						original_tag = RAJ
						original_tag = CAN
						original_tag = MAL
						original_tag = INS
					}
					is_puppet = no
				}
				abandon_colony_tag = yes
			}
		}
	}

	#Not run on a specific country.
	on_startup = {
		effect = {
			GER = {
				if = {
					limit = {
						has_dlc = "Waking the Tiger"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = GER_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = GER_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						40 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}
								}
							}
							GER = {
								set_country_flag = GER_AI_RANDOM_FASCIST
								set_add_fascist_weight_small = yes
							}
						}
						35 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}		
								}
							}
							modifier = {
								factor = 1.2
								game_weight_can_add_unaligned = yes
								OR = {
									has_game_rule = {
										rule = ENG_ai_behavior
										option = NEUTRALITY
									}
									ENG = {
										has_country_flag = ENG_AI_RANDOM_NEUTRALITY
									}
								}
							}
							modifier = {
								factor = 0.85
								game_weight_can_add_unaligned = no
								OR = {
									has_game_rule = {
										rule = ENG_ai_behavior
										option = NEUTRALITY
									}
									ENG = {
										has_country_flag = ENG_AI_RANDOM_NEUTRALITY
									}
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
								NOT = {
									OR = {
										has_game_rule = {
											rule = ENG_ai_behavior
											option = NEUTRALITY
										}	
										ENG = {
											has_country_flag = ENG_AI_RANDOM_NEUTRALITY
										}
									}
								}
							}
							GER = {
								set_country_flag = GER_AI_RANDOM_KAISER
								set_add_unaligned_game_weight_large = yes
							}
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}	
								}
							}
							GER = {
								set_country_flag = GER_AI_RANDOM_DEMOCRATIC
								set_add_democratic_game_weight_large = yes
							}
						}
					}
				}
			}
			ITA = {
				if = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = ITA_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = ITA_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						35 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}
								}
							}
							ITA = {
								set_country_flag = ITA_AI_RANDOM_FASCIST_HISTORICAL
							}
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}		
								}
							}
							ITA = {
								set_country_flag = ITA_AI_RANDOM_FASCIST_BALBO
							}
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}		
								}
							}
							ITA = {
								set_country_flag = ITA_AI_RANDOM_FASCIST_GRANDI
							}
						}
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}		
								}
							}
							ITA = {
								set_country_flag = ITA_AI_RANDOM_MONARCHIST
							}
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}		
								}
							}
							ITA = {
								set_country_flag = ITA_AI_RANDOM_CHRISTIAN_DEMOCRACY
							}
						}
						20 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}		
								}
							}
							ITA = {
								set_country_flag = ITA_AI_RANDOM_COMMUNIST_PLAN
							}
						}
						20 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}		
								}
							}
							ITA = {
								set_country_flag = ITA_AI_RANDOM_DEMOCRATIC_PLAN
							}
						}
					}
				}
			}
			CHI = { #No game weighting here
				if = {
					limit = {
						has_dlc = "Waking the Tiger"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = CHI_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = CHI_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						50 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}
								}
							}
							CHI = { set_country_flag = CHI_AI_RANDOM_HISTORICAL } 
						}
						50 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							CHI = { set_country_flag = CHI_AI_RANDOM_ALTERNATE } 
						}
					}
				}
			}
			MAN = {
				if = {
					limit = {
						has_dlc = "Waking the Tiger"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = MAN_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = MAN_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						40 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}
								}
							}
							MAN = { set_country_flag = MAN_AI_RANDOM_OBEDIENCE } 
						}
						60 = {  
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							MAN = { set_country_flag = MAN_AI_RANDOM_INDEPENDENCE } 
						}
					}
				}
			}
			PRC = {
				if = {
					limit = {
						has_dlc = "Waking the Tiger"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = PRC_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = PRC_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						34 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}
								}
							}
							PRC = { set_country_flag = PRC_AI_RANDOM_HISTORICAL } 
						}
						33 = {  
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							PRC = { set_country_flag = PRC_AI_RANDOM_ALTERNATE_1 } 
						}
						33 = {  
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							PRC = { set_country_flag = PRC_AI_RANDOM_ALTERNATE_2 } 
						}
					}
				}
			}
			SOV = {
				if = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = SOV_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = SOV_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						50 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}
								}
							}
							SOV = { set_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL }
							set_add_communist_weight_small = yes
						}
						65 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							SOV = { set_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION }
							set_add_communist_weight_small = yes
						}
						35 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							SOV = { set_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION_COOPERATIVE }
							set_add_communist_weight_small = yes
						}
						65 = {
							SOV = { set_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION }
							set_add_communist_weight_small = yes
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
						}
						35 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							SOV = { set_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION_COOPERATIVE }
							set_add_communist_weight_small = yes
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
						}
						50 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							SOV = { set_country_flag = SOV_AI_RANDOM_EXILES_TSARIST }
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.50
								game_weight_can_add_unaligned = no
							}
						}
						50 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							SOV = { set_country_flag = SOV_AI_RANDOM_EXILES_FASCIST }
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.50
								game_weight_can_add_fascist = no
							}
						}
						50 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							SOV = { set_country_flag = SOV_AI_RANDOM_EXILES_DEMOCRATIC }
							set_add_democratic_game_weight_large = yes
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.20
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 2.0
								GER = { is_ai = no }
								ENG = {
									OR = {
										has_country_flag = ENG_AI_RANDOM_DEMOCRATIC_ALTERNATE
										has_game_rule = {
											rule = ENG_ai_behavior 
											option = DEMOCRATIC_ALTERNATE
										}
									}
								}
								FRA = {
									OR = {
										has_country_flag = FRA_AI_DEMOCRATIC_ALTERNATE
										has_game_rule = {
											rule = FRA_ai_behavior
											option = DEMOCRATIC_ALTERNATE
										}
									}
								}
							}
						}
					}
				}
			}
			FRA = {
				if = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = FRA_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = FRA_ai_behavior
								option = RANDOM
							}
						}
						NOT = { has_dlc = "La Resistance" }
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_country_flag = FRA_AI_COMMUNIST
							set_add_communist_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_country_flag = FRA_AI_RANDOM_DEMOCRATIC_ALTERNATE
							set_add_democratic_game_weight_large = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}		
								}
							}
							set_country_flag = FRA_AI_DEMOCRATIC_HISTORICAL
							set_add_democratic_game_weight_large = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_country_flag = FRA_AI_FASCIST
							set_add_fascist_weight_small = yes
						}
					}
				}
			}
			FRA = {
				if = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = FRA_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = FRA_ai_behavior
								option = RANDOM
							}
						}
						has_dlc = "La Resistance"
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 1.5
								OR = {
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION }
								}
								game_weight_can_add_communist = no
								GER = { is_ai = no }
							}
							set_country_flag = FRA_AI_COMMUNIST
							set_add_communist_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_country_flag = FRA_AI_DEMOCRATIC_ALTERNATE
							set_add_democratic_game_weight_large = yes
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}	
								}
							}
							set_country_flag = FRA_AI_DEMOCRATIC_HISTORICAL
							set_add_democratic_game_weight_large = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_country_flag = FRA_AI_FASCIST
							set_add_fascist_game_weight_large = yes
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							random_list = {
								30 = { set_country_flag = FRA_AI_ORLEANIST }
								35 = { set_country_flag = FRA_AI_LEGITIMIST }
								35 = { set_country_flag = FRA_AI_BONAPARTIST }
							}
							set_add_unaligned_game_weight_large = yes
						}
					}
				}
			}
			JAP = {
				if = {
					limit = {
						has_dlc = "Waking the Tiger"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = JAP_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = JAP_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						35 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}		
								}
							}
							JAP = { set_country_flag = JAP_AI_RANDOM_FASCIST }
							set_add_fascist_game_weight_large = yes
						}
						30 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							JAP = { set_country_flag = JAP_AI_RANDOM_NEUTRALITY }
							set_add_unaligned_game_weight_large = yes
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							JAP = { set_country_flag = JAP_AI_RANDOM_DEMOCRATIC }
							set_add_democratic_weight_small = yes
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							JAP = { set_country_flag = JAP_AI_RANDOM_COMMUNIST }
							set_add_communist_weight_small = yes
						}
					}
				}
			}
			ROM = {
				if = {
					limit = {
						has_dlc = "Death or Dishonor"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = ROM_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = ROM_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							set_country_flag = ROM_AI_RANDOM_BALKAN_DOMINANCE
							set_add_unaligned_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ROM_AI_RANDOM_DEMOCRATIC
							set_add_democratic_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							set_country_flag = ROM_AI_RANDOM_FASCIST_HISTORICAL
							set_add_fascist_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ROM_AI_RANDOM_COMMUNIST
							set_add_communist_weight_small = yes
						}
					}
				}
			}
			HUN = {
				if = {
					limit = {
						has_dlc = "Death or Dishonor"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = HUN_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = HUN_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						5 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = HUN_AI_RANDOM_COMMUNIST
							set_add_communist_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = HUN_AI_RANDOM_AUSTRIA_HUNGARY
							set_add_unaligned_weight_small = yes
						}
						5 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = HUN_AI_RANDOM_DEMOCRATIC
							set_add_democratic_weight_small = yes
						}
						40 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							set_country_flag = HUN_AI_RANDOM_FASCIST_HISTORICAL
							set_add_fascist_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = HUN_AI_RANDOM_FASCIST_ALTERNATE
							set_add_fascist_weight_small = yes
						}
					}
				}
			}
			CZE = {
				if = {
					limit = {
						has_dlc = "Death or Dishonor"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = CZE_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = CZE_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 1.25
								OR = {
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION_COOPERATIVE }
								}
							}
							set_country_flag = CZE_AI_RANDOM_COMMUNIST
							set_add_communist_weight_small = yes
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = CZE_AI_RANDOM_DEMOCRATIC
							set_add_democratic_weight_small = yes
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.50
								ROM = { has_country_flag = ROM_AI_RANDOM_COMMUNIST }
								OR = {
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION_COOPERATIVE }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION_COOPERATIVE }
								}
							}
							modifier = {
								factor = 0.50
								YUG = { has_country_flag = ROM_AI_RANDOM_COMMUNIST }
								OR = {
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION_COOPERATIVE }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_RIGHT_OPPOSITION_COOPERATIVE }
								}
							}
							set_country_flag = CZE_AI_RANDOM_DEMOCRATIC_ALTERNATE
							set_add_democratic_weight_small = yes
						}
						20 = {
							modifier = {
								factor = 0.5
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							set_country_flag = CZE_AI_RANDOM_HISTORICAL
							set_add_democratic_weight_small = yes
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 2
								GER = { has_country_flag = GER_AI_RANDOM_FASCIST }
							}
							set_country_flag = CZE_AI_RANDOM_FASCIST
							set_add_fascist_weight_small = yes
						}
					}
				}
			}
			YUG = {
				if = {
					limit = {
						has_dlc = "Death or Dishonor"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = YUG_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = YUG_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = YUG_AI_RANDOM_COMMUNIST
							set_add_communist_weight_small = yes
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = YUG_AI_RANDOM_DEMOCRATIC
							set_add_democratic_weight_small = yes
						}
						40 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							set_country_flag = YUG_AI_RANDOM_HISTORICAL
							set_add_unaligned_weight_small = yes
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = YUG_AI_RANDOM_FASCIST
							set_add_fascist_weight_small = yes
						}
					}
				}
			}
			AST = {
				if = {
					limit = {
						has_dlc = "Together for Victory"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = AST_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = AST_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = AST_AI_RANDOM_COMMUNIST 
						}
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = AST_AI_RANDOM_DEMOCRATIC_ALTERNATE 
						}
						45 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}		
								}
							}
							set_country_flag = AST_AI_DEMOCRATIC_HISTORICAL 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = AST_AI_RANDOM_FASCIST 
						}
					}
				}
			}
			CAN = {
				if = {
					limit = {
						has_dlc = "Together for Victory"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = CAN_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = CAN_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = CAN_AI_RANDOM_COMMUNIST 
						}
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = CAN_AI_RANDOM_DEMOCRATIC_ALTERNATE 
						}
						45 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							set_country_flag = CAN_AI_DEMOCRATIC_HISTORICAL 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = CAN_AI_RANDOM_FASCIST 
						}
					}
				}
			}
			SAF = {
				if = {
					limit = {
						has_dlc = "Together for Victory"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = SAF_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = SAF_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SAF_AI_RANDOM_COMMUNIST 
						}
						35 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SAF_AI_RANDOM_DEMOCRATIC_ALTERNATE 
						}
						35 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}
								}
							}
							set_country_flag = SAF_AI_DEMOCRATIC_HISTORICAL 
						}
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SAF_AI_RANDOM_FASCIST 
						}
					}
				}
			}
			NZL = {
				if = {
					limit = {
						has_dlc = "Together for Victory"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = NZL_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = NZL_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						5 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = NZL_AI_RANDOM_COMMUNIST 
						}
						5 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = NZL_AI_RANDOM_DEMOCRATIC_ALTERNATE 
						}
						85 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}		
								}
							}
							set_country_flag = NZL_AI_DEMOCRATIC_HISTORICAL 
						}
						5 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = NZL_AI_RANDOM_FASCIST 
						}
					}
				}
			}
			RAJ = {
				if = {
					limit = {
						has_dlc = "Together for Victory"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = RAJ_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = RAJ_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						5 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = RAJ_AI_RANDOM_COMMUNIST 
						}
						90 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}		
								}
							}
							set_country_flag = RAJ_AI_DEMOCRATIC_HISTORICAL 
						}
						5 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}		
							set_country_flag = RAJ_AI_RANDOM_FASCIST
					 	}
					}
				}
			}
			POL = {
				if = {
					limit = {
						OR = {
							has_dlc = "Poland: United and Ready"
							has_dlc = "No Step Back"
						}
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = POL_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = POL_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = POL_AI_RANDOM_COMMUNIST
							set_add_communist_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_country_flag = POL_AI_RANDOM_HISTORICAL
							set_add_unaligned_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = POL_AI_RANDOM_DEMOCRATIC
							set_add_democratic_weight_small = yes
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = POL_AI_RANDOM_FASCIST
							set_add_fascist_weight_small = yes
						}
						25 = {
							set_country_flag = POL_AI_RANDOM_FASCIST_INDEPENDENT
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.75
								game_weight_can_add_fascist = no
							}
						}
						25 = {
							set_country_flag = POL_AI_RANDOM_COMMONWEALTH
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.75
								game_weight_can_add_unaligned = no
							}
							set_add_unaligned_weight_small = yes
						}
						25 = {
							set_country_flag = POL_AI_RANDOM_ROMANIA
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.75
								game_weight_can_add_unaligned = no
							}
							set_add_unaligned_weight_small = yes
						}
						25 = {
							set_country_flag = POL_AI_RANDOM_HABSBURG
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.75
								game_weight_can_add_unaligned = no
							}
							set_add_unaligned_weight_small = yes
						}
						25 = {
							set_country_flag = POL_AI_RANDOM_BERMONDT
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0
								NOT = { has_dlc = "No Step Back" }
							}
							modifier = {
								factor = 0.5
								game_weight_can_add_fascist = no
							}
							set_add_fascist_weight_small = yes
						}
					}
				}
			}
			ENG = {
				if = {
					limit = {
						has_dlc = "Man the Guns"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = ENG_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = ENG_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 1.5
								OR = {
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL }
									SOV = { has_country_flag = SOV_AI_RANDOM_COMMUNIST_LEFT_OPPOSITION }
								}
								game_weight_can_add_communist = no
								GER = { is_ai = no }
							}
							set_add_communist_weight_small = yes
							set_country_flag = ENG_AI_RANDOM_COMMUNIST
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_add_democratic_game_weight_large = yes
							set_country_flag = ENG_AI_RANDOM_DEMOCRATIC_ALTERNATE
						}
						20 = {
							modifier = {
								factor = 0.5
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							set_add_democratic_game_weight_large = yes
							set_country_flag = ENG_AI_DEMOCRATIC_HISTORICAL
						}
						25 = {
							modifier = {
								factor = 1.2
								game_weight_can_add_unaligned = yes
								OR = {
									has_game_rule = {
										rule = GER_ai_behavior
										option = KAISER
									}
									GER = {
										has_country_flag = GER_AI_RANDOM_KAISER
									}
								}
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.85
								game_weight_can_add_unaligned = no
								OR = {
									has_game_rule = {
										rule = GER_ai_behavior
										option = KAISER
									}
									GER = {
										has_country_flag = GER_AI_RANDOM_KAISER
									}
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
								NOT = {
									OR = {
										has_game_rule = {
											rule = GER_ai_behavior
											option = KAISER
										}	
										ENG = {
											has_country_flag = GER_AI_RANDOM_KAISER
										}
									}
								}
							}
							set_add_unaligned_game_weight_large = yes
							set_country_flag = ENG_AI_RANDOM_NEUTRALITY
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_add_fascist_game_weight_large = yes
							set_country_flag = ENG_AI_RANDOM_FASCIST
						}
					}
				}
			}
			USA = {
				if = {
					limit = {
						has_dlc = "Man the Guns"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = USA_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = USA_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0.4
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = USA_AI_RANDOM_COMMUNIST
						}
						25 = {
							modifier = {
								factor = 0.15
								game_weight_can_add_democratic = no
							}
							modifier = {
								OR = {
									CHL = {
										is_ai = no
									}
									BRA = {
										is_ai = no
									}
									ARG = {
										is_ai = no
									}			
									PAR = {
										is_ai = no
									}									
									URG = {
										is_ai = no
									}									
								}
								factor = 1.25
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_add_democratic_game_weight_large = yes
							set_country_flag = USA_AI_RANDOM_DEMOCRATIC_ALTERNATE
						}
						25 = {
							modifier = {
								factor = 0.10
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}		
								}
							}
							set_add_democratic_game_weight_large = yes
							set_country_flag = USA_AI_DEMOCRATIC_HISTORICAL
						}
						25 = {
							modifier = {
								factor = 0.4
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MINORS_ONLY
									}			
								}
							}
							set_add_fascist_game_weight_large = yes
							set_country_flag = USA_AI_RANDOM_FASCIST
						}
					}
				}
			}
			HOL = {
				if = {
					limit = {
						has_dlc = "Man the Guns"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = HOL_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = HOL_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = HOL_AI_RANDOM_COMMUNIST
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = HOL_AI_RANDOM_DEMOCRATIC_ALTERNATE_1
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = HOL_AI_RANDOM_DEMOCRATIC_ALTERNATE_2
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = HOL_AI_RANDOM_DEMOCRATIC_ALTERNATE_3
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = HOL_AI_RANDOM_DEMOCRATIC_HISTORICAL
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = HOL_AI_RANDOM_NEUTRALITY
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = HOL_AI_RANDOM_FASCIST
						}
					}
				}
			}
			MEX = {
				if = {
					limit = {
						has_dlc = "Man the Guns"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = MEX_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = MEX_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}		
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = MEX_AI_SECULAR_REPUBLIC
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = MEX_AI_SOCIAL_CATHOLICISM
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = MEX_AI_FASCIST_DICTATORSHIP
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = MEX_AI_THEOCRATIC_ORDER
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = MEX_AI_SOVIET_REPUBLIC
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = MEX_AI_CARDENISMO
						}
					}
				}
			}
			SPR = {
				if = {
					limit = {
						has_dlc = "La Resistance"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = SPR_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = SPR_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						40 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = SPR_AI_RANDOM_NATIONALIST_HISTORICAL
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = SPR_AI_RANDOM_SECOND_REPUBLIC
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = SPR_AI_RANDOM_FALANGIST
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = SPR_AI_RANDOM_CARLIST
						}
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SPR_AI_RANDOM_ANARCHIST 
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = SPR_AI_RANDOM_INDEPENDENT_COMMUNIST
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = SPR_AI_RANDOM_STALINIST
						}
					}
				}
			}
			POR = {
				if = {
					limit = {
						has_dlc = "La Resistance"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = POR_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = POR_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}		
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = POR_AI_RANDOM_NEUTRALITY_HISTORICAL
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = POR_AI_RANDOM_FASCIST_AXIS
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = POR_AI_RANDOM_FASCIST_FIFTH_EMPIRE
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = POR_AI_RANDOM_NEUTRALITY_MONARCHIST
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = POR_AI_RANDOM_DEMOCRATIC
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = POR_AI_RANDOM_COMMUNIST_COMINTERN
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = POR_AI_RANDOM_COMMUNIST_INDEPENDENT
						}
					}
				}
			}
			BUL = {
				if = {
					limit = {
						has_dlc = "Battle for the Bosporus"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = BUL_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = BUL_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = { #What ideology even is this diplomatically
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_country_flag = BUL_AI_RANDOM_HISTORICAL
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = BUL_AI_RANDOM_COMMUNIST
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = BUL_AI_RANDOM_COMMUNIST_BALKAN_FEDERATION
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = BUL_AI_RANDOM_FASCIST_AXIS
						}
						15 = {
							modifier = {
								factor = 0.40
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = BUL_AI_RANDOM_THE_RETURN_OF_FERDINAND
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = BUL_AI_RANDOM_DEMOCRATIC_LIBERAL
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = BUL_AI_RANDOM_DEMOCRATIC_SOCIALIST
						}
					}
				}
			}
			GRE = {
				if = {
					limit = {
						has_dlc = "Battle for the Bosporus"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = GRE_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = GRE_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}		
								}
							}
							set_country_flag = GRE_AI_RANDOM_NEUTRALITY_HISTORICAL
							set_add_unaligned_weight_small = yes
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = GRE_AI_RANDOM_MONARCHIST
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = GRE_AI_RANDOM_MONARCHIST_ALTERNATE
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = GRE_AI_RANDOM_COMMUNIST
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = GRE_AI_RANDOM_COMMUNIST_ALTERNATE
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = GRE_AI_RANDOM_DEMOCRATIC
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = GRE_AI_RANDOM_FASCISM
						}
						5 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = GRE_AI_RANDOM_FASCISM_ALTERNATE
						}
					}
				}
			}
			TUR = {
				if = {
					limit = {
						has_dlc = "Battle for the Bosporus"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = TUR_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = TUR_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_NEUTRALITY_HISTORICAL
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_ALT_KEMALIST
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_COMMUNISM
						}
						5 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_COMMUNISM_ALTERNATE
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_DEMOCRATIC
						}
						5 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_DEMOCRATIC_ALTERNATE
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_FASCISM
						}
						5 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_FASCISM_ALTERNATE
						}
						10 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_BALKAN_ENTENTE
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = TUR_AI_RANDOM_OTTOMAN
						}
					}
				}
			}
			LIT = {
				if = {
					limit = {
						has_dlc = "No Step Back"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = LIT_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = LIT_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}		
								}
							}
							set_country_flag = LIT_AI_RANDOM_HISTORICAL 
						}
						5 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0.25
								OR = {
									has_game_rule = {
										rule = ENG_ai_behavior
										option = NEUTRALITY
									}	
									ENG = {
										has_country_flag = ENG_AI_RANDOM_NEUTRALITY
									}
								}
								OR = {
									has_game_rule = {
										rule = GER_ai_behavior
										option = KAISER
									}	
									ENG = {
										has_country_flag = GER_AI_RANDOM_KAISER
									}
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = LIT_AI_RANDOM_COMMUNIST
						}
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							set_add_fascist_weight_small = yes
							set_country_flag = LIT_AI_RANDOM_FASCIST
						}
						20 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = LIT_AI_RANDOM_MONARCHY
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							set_add_democratic_weight_small = yes
							set_country_flag = LIT_AI_RANDOM_DEMOCRATIC
						}
					}
				}
			}
			LAT = {
				if = {
					limit = {
						has_dlc = "No Step Back"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = LAT_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = LAT_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}		
								}
							}
							set_country_flag = LAT_AI_RANDOM_HISTORICAL 
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = LAT_AI_RANDOM_COMMUNIST
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							set_country_flag = LAT_AI_RANDOM_FASCIST
						}
						25 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_democratic_weight_small = yes
							set_country_flag = LAT_AI_RANDOM_DEMOCRATIC
						}
					}
				}
			}
			EST = {
				if = {
					limit = {
						has_dlc = "No Step Back"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = EST_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = EST_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						15 = {
							
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_country_flag = EST_AI_RANDOM_HISTORICAL
						}
						15 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							set_add_communist_weight_small = yes
							set_country_flag = EST_AI_RANDOM_COMMUNIST
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							set_add_fascist_weight_small = yes
							set_country_flag = EST_AI_RANDOM_FASCIST
						}
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							set_add_democratic_weight_small = yes
							set_country_flag = EST_AI_RANDOM_DEMOCRATIC
						}
					}
				}
			}
			ETH = {
				if = {
					limit = {
						has_dlc = "By Blood Alone"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = ETH_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = ETH_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_country_flag = ETH_AI_RANDOM_HISTORICAL 
						}
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ETH_AI_RANDOM_IMPERIAL 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ETH_AI_RANDOM_STALINIST
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ETH_AI_RANDOM_ANARCHIST
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ETH_AI_RANDOM_COLLABORATIONIST
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ETH_AI_RANDOM_INDEPENDENT_FASCIST
						}
					}
				}
			}
			SWI = {
				if = {
					limit = {
						has_dlc = "By Blood Alone"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = SWI_AI_BEHAVIOR
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = SWI_AI_BEHAVIOR
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							set_country_flag = SWI_AI_RANDOM_HISTORICAL 
						}
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SWI_AI_RANDOM_ALLIED_DEMOCRATIC 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SWI_AI_RANDOM_EXPANSIONIST_DEMOCRATIC 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SWI_AI_RANDOM_IMPERIAL 
						}
						25 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = SWI_AI_RANDOM_FASCIST 
						}
					}
				}
			}
			RAJ = {
				if = {
					limit = { has_dlc = "Together for Victory" }
					
					set_variable = { RAJ_agrarian_society_value = -0.70 }
					add_dynamic_modifier = { modifier = RAJ_agrarian_society_dynamic }
					remove_ideas = RAJ_agrarian_society #For startup screen
				}
			}
			SWE = {
				if = {
					limit = {
						has_dlc = "Arms Against Tyranny"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = SWE_AI_BEHAVIOR
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = SWE_AI_BEHAVIOR
								option = RANDOM
							}
						}
					}
					random_list = {
						20 = { #Go fascist
							modifier = {
								factor = 0.25
								game_weight_can_add_fascist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_fascist_weight_small = yes
							random_list = { #Which type of fascist
								25 = {
									modifier = {
										factor = 0
										GER = {
											OR = { #Dont go fascist puppet unless Germany is going fascist 
												has_game_rule = {
													rule = GER_ai_behavior
													option = DEFAULT
												}
												has_country_flag = GER_AI_RANDOM_FASCIST
												has_game_rule = {
													rule = GER_ai_behavior
													option = FASCIST
												}
											}
										}
									}

									modifier = {
										factor = 0.1 #unlikely to become backstabber if GER is Player
										GER = { is_ai = no }
									}
									set_country_flag = SWE_AI_RANDOM_PUPPET_BACKSTABBER
								}

								25 = {
									modifier = { #Dont go fascist puppet unless Germany is going fascist 
										factor = 0
										GER = {
											OR = {
												has_game_rule = {
													rule = GER_ai_behavior
													option = DEFAULT
												}
												has_country_flag = GER_AI_RANDOM_FASCIST
												has_game_rule = {
													rule = GER_ai_behavior
													option = FASCIST
												}
											}
										}
									}
									set_country_flag = SWE_AI_RANDOM_FASCIST_PUPPET
								}

								50 = {
									set_country_flag = SWE_AI_RANDOM_FASCIST_INDEPENDENT
								}
							}
						}

						40 = { 
							modifier = {
								factor = 0.25
								game_weight_can_add_democratic = no
							}
							set_add_democratic_weight_small = yes

							random_list = {
								40 = {
									modifier = {
										factor = 0
										OR = {
											has_game_rule = {
												rule = NONHIST_ai_behavior
												option = ANTI_HISTORICAL
											}			
										}
									}
									set_country_flag = SWE_AI_RANDOM_HISTORICAL
								}

								45 = {
									modifier = {
										factor = 0
										OR = {
											has_game_rule = {
												rule = NONHIST_ai_behavior
												option = HISTORICAL_PATHS 
											}
											has_game_rule = {
												rule = NONHIST_ai_behavior
												option = MAJORS_ONLY
											}			
										}
									}
									set_country_flag = SWE_AI_RANDOM_DEMOCRATIC_ALT
								}

								15 = {
									modifier = {
										factor = 0
										OR = {
											has_game_rule = {
												rule = NONHIST_ai_behavior
												option = HISTORICAL_PATHS 
											}
											has_game_rule = {
												rule = NONHIST_ai_behavior
												option = MAJORS_ONLY
											}			
										}
									}
									set_country_flag = SWE_AI_RANDOM_DEMOCRATIC_NORDIC_DEFENCE_COUNCIL
								}
							}

						}

						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_communist = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_communist_weight_small = yes
							set_country_flag = SWE_AI_RANDOM_COMMUNISM
							
						}
						20 = {
							modifier = {
								factor = 0.25
								game_weight_can_add_unaligned = no
							}
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_add_unaligned_weight_small = yes
							set_country_flag = SWE_AI_RANDOM_UNALIGNED
						}
					}
				}
			}
			FIN = {
				if = {
					limit = {
						has_dlc = "Arms Against Tyranny"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = FIN_AI_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = FIN_AI_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							FIN = {
								set_country_flag = FIN_AI_RANDOM_HISTORICAL
							}
						}
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							FIN = {
								set_country_flag = FIN_AI_RANDOM_FASCIST_PLAN
							}
						}
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							FIN = {
								set_country_flag = FIN_AI_RANDOM_COMMUNIST_PLAN
							}
						}
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							FIN = {
								set_country_flag = FIN_AI_RANDOM_DEMOCRATIC_PLAN
							}
						}
					}
				}
			}
			NOR = {
				if = {
					limit = {
						has_dlc = "Arms Against Tyranny"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = NOR_AI_BEHAVIOR
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = NOR_AI_BEHAVIOR
								option = RANDOM
							}
						}
					}
					random_list = {
						18 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							NOR = {
								set_country_flag = NOR_AI_RANDOM_ALTERNATE_HISTORICAL
							}
						}
						12 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							NOR = {
								set_country_flag = NOR_AI_RANDOM_HISTORICAL
							}
						}
						28 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							NOR = {
								set_country_flag = NOR_AI_RANDOM_FASCIST
							}
						}
						14 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							NOR = {
								set_country_flag = NOR_AI_RANDOM_STALINIST
							}
						}
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							NOR = {
								set_country_flag = NOR_AI_RANDOM_TROSTSKYIST
							}
						}
						18 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							NOR = {
								set_country_flag = NOR_AI_RANDOM_MONARCHIST
							}
						}
					}
				}
			}
			DEN = {
				if = {
					limit = {
						has_dlc = "Arms Against Tyranny"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = DEN_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = DEN_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						30 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							set_country_flag = DEN_AI_RANDOM_HISTORICAL 
						}
						25 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = DEN_AI_RANDOM_ALLIANCE_PLAN 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = DEN_AI_RANDOM_MONARCHIST_PLAN 
						}
						15 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = DEN_AI_RANDOM_FASCIST_PLAN 
						}
						#10 = { set_country_flag = COMMUNIST }
					}
				}
			}
			ICE = {
				if = {
					limit = {
						has_dlc = "Arms Against Tyranny"
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = ICE_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = ICE_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						60 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}		
								}
							}
							set_country_flag = ICE_AI_RANDOM_HISTORICAL 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}		
								}
							}
							modifier = {
								factor = 5
								DEN = {
									OR = {
										has_country_flag = DEN_AI_RANDOM_ALLIANCE_PLAN
										has_game_rule = {
											rule = DEN_ai_behavior
											option = DEN_rearmament_plan
										}
									}
								}
							}
							set_country_flag = ICE_AI_RANDOM_ALT_DEMOCRATIC_PLAN 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ICE_AI_RANDOM_FASCIST_PLAN 
						}
						20 = { 
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							set_country_flag = ICE_AI_RANDOM_COMMUNIST_PLAN 
						}
					
						#10 = { set_country_flag = COMMUNIST }
					}
				}
			}
			CHL = {
				IF = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = CHL_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = CHL_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							CHL = { set_country_flag = CHL_AI_RANDOM_HISTORICAL }
						}
						8 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 2
								SOV = {
									OR = {
										has_country_flag = SOV_AI_RANDOM_COMMUNIST_HISTORICAL
										has_game_rule = {
											rule = SOV_ai_behavior
											option = HISTORICAL
										}
									}
								}
							}
							CHL = { set_country_flag = CHL_AI_RANDOM_COMMUNIST }
						}
						8 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 2
								GER = {
									OR = {
										has_country_flag = GER_AI_RANDOM_FASCIST
										has_game_rule = {
											rule = GER_ai_behavior
											option = FASCIST
										}
									}
								}
							}
							CHL = { set_country_flag = CHL_AI_RANDOM_OPERATION_BOLIVAR }
						}
						5 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							CHL = { set_country_flag = CHL_AI_RANDOM_PAN_HISPANISM }
						}
						8 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							CHL = { set_country_flag = CHL_AI_RANDOM_ANTI_IMPERIALISM }
						}
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							modifier = {
								factor = 3
								FRA = {
									OR = {
										has_country_flag = FRA_AI_ORLEANIST
										has_country_flag = FRA_AI_LEGITIMIST
										has_country_flag = FRA_AI_BONAPARTIST
										has_game_rule = {
											rule = FRA_ai_behavior
											option = ORLEANIST
										}
										has_game_rule = {
											rule = FRA_ai_behavior
											option = LEGITIMIST
										}
										has_game_rule = {
											rule = FRA_ai_behavior
											option = BONAPARTIST
										}
									}
								}
							}
							CHL = { set_country_flag = CHL_AI_RANDOM_LE_DELUGE }
						}
					}
				}
			}
			BRA = {
				IF = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = BRA_AI_BEHAVIOR
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = BRA_AI_BEHAVIOR
								option = RANDOM
							}
						}
					}
					random_list = {
						30 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							BRA = { set_country_flag = BRA_AI_RANDOM_HISTORICAL }
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							BRA = { set_country_flag = BRA_AI_RANDOM_FASCISM }
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							BRA = { set_country_flag = BRA_AI_RANDOM_DEMOCRATIC }
						}
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							BRA = { set_country_flag = BRA_AI_RANDOM_MONARCHIST_HENRIQUE }
						}
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							BRA = { set_country_flag = BRA_AI_RANDOM_MONARCHIST_ALCANTARA }
						}
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							BRA = { set_country_flag = BRA_AI_RANDOM_STALINIST }
						}
						10 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							BRA = { set_country_flag = BRA_AI_RANDOM_INDEPENDENT_COMMUNIST }
						}
					}
				}
			}

			PAR = {
				IF = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = PAR_AI_BEHAVIOR
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = PAR_AI_BEHAVIOR
								option = RANDOM
							}
						}
					}
					random_list = {
						70 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}			
								}
							}
							PAR = { set_country_flag = PAR_AI_RANDOM_HISTORICAL }
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							PAR = { set_country_flag = PAR_AI_RANDOM_COMMUNIST }
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							PAR = { set_country_flag = PAR_AI_RANDOM_DEMOCRATIC }
						}
					}
				}
			}

			URG = {
				IF = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = URG_AI_BEHAVIOR
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = URG_AI_BEHAVIOR
								option = RANDOM
							}
						}
					}
					random_list = {
						60 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							URG = { set_country_flag = URG_AI_RANDOM_DEMOCRATIC_ALT }
						}
						25 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							URG = { set_country_flag = URG_AI_RANDOM_FASCIST }
						}
						15 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL
									}		
								}
							}
							URG = { set_country_flag = URG_AI_RANDOM_HISTORICAL }
						}
					}
				}
			}




			ARG = {
				IF = {
					limit = {
						OR = {
							AND = {
								is_historical_focus_on = no
								has_game_rule = {
									rule = ARG_ai_behavior
									option = DEFAULT
								}
							}
							has_game_rule = {
								rule = ARG_ai_behavior
								option = RANDOM
							}
						}
					}
					random_list = {
						1 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							ARG = { set_country_flag = ARG_AI_RANDOM_FASCISM }
						}
						1 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							ARG = { set_country_flag = ARG_AI_RANDOM_COMMUNIST }
						}
						1 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = HISTORICAL_PATHS 
									}
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = MAJORS_ONLY
									}			
								}
							}
							ARG = { set_country_flag = ARG_AI_RANDOM_DEMOCRATIC }
						}

						1 = {
							modifier = {
								factor = 0
								OR = {
									has_game_rule = {
										rule = NONHIST_ai_behavior
										option = ANTI_HISTORICAL 
									}			
								}
							}
							ARG = { set_country_flag = ARG_AI_RANDOM_HISTORICAL }
						}
					}
				}
			}		
		}
	}


	#ROOT = country that joined a war
	#Fired when a country goes to war against anyone and is not fired again when it enters war against another country unless it went to peace first
	on_war = { 
		effect = {
			if = {
				limit = {
					tag = USA
					has_war_with = JAP
					NOT = { has_global_flag = day_of_infamy_happened }
					has_country_leader = { character = USA_franklin_delano_roosevelt ruling_only = yes }
				}
				play_day_of_infamy_effect = yes
			}
			if = {
				limit = {
					tag = ENG
					has_war_with = GER
					has_country_leader = { character = ENG_neville_chamberlain ruling_only = yes }
				}
				play_war_with_germany_effect = yes
			}
		}
	}
	#ROOT = attacking side
	#FROM = defending side
	#fired when two countries end up at war with each other (on_war is fired when a country goes to war against anyone and is not fired again when it enters war against another country unless it went to peace first)
	on_war_relation_added = {
		effect = {
			if = {
				limit = {
					tag = GER
					FROM = {
						tag = SOV
						has_government = communism
					}
				}
				set_global_flag = { flag = barbarossa_counter value = 1 days = 60 }
			}
			if = {
				limit = {
					ROOT = { original_tag = GER }
					ROOT = { GER_has_mefo_bills = yes }
					NOT = { FROM = { original_tag = GER } }
				}
				ROOT = {
					GER_remove_mefo_bills = yes
					set_country_flag = mefo_bills_removed_through_war
				}
			}
			if = {
				limit = {
					FROM = { original_tag = GER }
					FROM = { GER_has_mefo_bills = yes }
					NOT = { ROOT = { original_tag = GER } }
				}
				FROM = {
					GER_remove_mefo_bills = yes
					set_country_flag = mefo_bills_removed_through_war
				}
			}
		}
	}
	#ROOT - country that just went to peace
	on_peaceconference_ended = {
		effect = {
			if = {
				limit = {
					tag = USA
					is_historical_focus_on = yes
					has_global_flag = day_of_infamy_happened
					has_government = democratic
					JAP = { has_government = democratic }
				}
				play_guns_are_silent_effect = yes
			}
		}
	}

	#ROOT is new controller #FROM is old controller #FROM.FROM is state ID
	on_state_control_changed = {
		effect = {
			if = {
				limit = {
					tag = FRA #to avoid third party taking over
					FROM = {
						is_in_faction_with = GER
					}
					FROM.FROM = {
						is_core_of = FRA
						NOT = {
							state = 459
							state = 460
							state = 513
							state = 1
						}
					}
					FRA = {
						has_capitulated = yes
						is_in_faction_with = USA
					}
					NOT = { has_global_flag = d_day_happened }
				}
				play_order_of_the_day_effect = yes
			}
			if = {
				limit = {
					OR = {
						tag = ENG
						tag = USA
						tag = HOL
						tag = BEL
					}
					FROM = {
						is_in_faction_with = GER
					}
					FROM.FROM = {
						OR = {
							is_core_of = HOL
							is_core_of = BEL
						}
					}
					is_in_faction_with = USA
					has_global_flag = d_day_happened_fake
					NOT = { has_global_flag = d_day_happened }
				}
				play_order_of_the_day_effect = yes
			}
			if = {
				limit = {
					OR = {
						tag = ENG
						tag = USA
						tag = HOL
						tag = BEL
					}
					FROM = {
						is_in_faction_with = GER
					}
					FROM.FROM = {
						OR = {
							is_core_of = HOL
							is_core_of = BEL
						}
					}
					is_in_faction_with = USA
					NOT = { has_global_flag = d_day_happened_fake }
				}
				set_global_flag = d_day_happened_fake
			}
			if = {
				limit = {
					tag = "PHI"
					FROM = {
						is_in_faction_with = JAP
					}
					FROM.FROM = {
						is_core_of = "PHI"
					}
					"PHI" = {
						has_capitulated = yes
						is_in_faction_with = USA
					}
					NOT = { has_global_flag = i_have_returned_happened }
				}
				play_i_have_returned_effect = yes
			}
			if = {
				limit = {
					OR = {
						TAG = ENG
						TAG = USA
						TAG = AST
						TAG = FRA
						TAG = CAN
						TAG = NZL
						TAG = SAF
					}
					FROM = { original_tag = GER }
					FROM = { has_war_with = ROOT }
					FROM.FROM = { state = 16 }
				}
				news_event = news.134
			}
			if = {
				limit = {
					OR = {
						TAG = ENG
						TAG = USA
					}
					FROM = { original_tag = GER }
					FROM = { has_war_with = ROOT }
					FROM.FROM = { state = 126 }
				}
				news_event = news.137
			}
			if = {
				limit = {
					OR = {
						# TAG = POL # don't include POL as the event is about Soviet capture of Warsaw
						TAG = SOV
					}
					NOT = { SOV = { has_war_with = POL } }
					FROM = { original_tag = GER }
					FROM = { has_war_with = ROOT }
					FROM.FROM = { state = 10 }
				}
				news_event = news.139
			}
			if = {
				limit = {
					tag = GER
					divisions_in_state = { state = FROM.FROM size > 0 }
					FROM = {
						original_tag = GER
						has_government = fascism
						has_civil_war = yes
					}
				}
				FROM.FROM = {
					set_state_flag = nazi_state_withdrawn
					random_list = {
						20 = {
							set_state_flag = nazi_state_withdrawn1
						}
						20 = {
							set_state_flag = nazi_state_withdrawn2
						}
						20 = {
							set_state_flag = nazi_state_withdrawn3
						}
						20 = {
							set_state_flag = nazi_state_withdrawn4
						}
						20 = {
							set_state_flag = nazi_state_withdrawn5
						}
					}
					state_event = { id = wtt_germany.49 trigger_for = controller }
				}
			}
			if = {
				limit = {
					tag = GER
					64 = { is_controlled_by = GER }
					any_other_country = {
						original_tag = GER
						has_government = fascism
						has_civil_war = yes
						owns_state = 64
					}
					NOT = { has_global_flag = fall_of_berlin_civil_war }
				}
				set_global_flag = fall_of_berlin_civil_war
				country_event = { id = wtt_germany.50 days = 1 random_hours = 3 }
			}
			if = {
				limit = {
					tag = GER
					has_country_flag = germany_war_return_kaiser
					has_government = neutrality
					FROM = {
						original_tag = HOL
						has_country_flag = netherlands_refused_return_kaiser
					}
					OR = {
						7 = { is_controlled_by = GER }
						HOL = { is_subject_of = GER }
					}
				}
				country_event = { id = wtt_germany.6 }
			}
			if = {
				limit = {
					tag = CSA
					has_war = yes
					FROM = {
						tag = USA
					}
					FROM.FROM = {
						is_core_of = USA
						not = { has_state_flag = USA_civil_war_state_cooldown }
					}
				}
				FROM.FROM = {
					save_event_target_as = CSA_liberated_state
					set_state_flag = {
						flag = USA_civil_war_state_cooldown
						days = 180
						value = 1
					}
					state_event = { id = mtg_usa_civil_war_fascists.201 trigger_for = controller }
				}
			}
			if = {
				limit = {
					tag = USA
					has_war_with = CSA
					FROM = {
						tag = CSA
					}
					FROM.FROM = {
						OR = {
							is_core_of = CSA
							is_claimed_by = USA
						}
						not = { has_state_flag = USA_civil_war_state_cooldown }
					}
				}
				FROM.FROM = {
					save_event_target_as = USA_liberated_state
					set_state_flag = {
						flag = USA_civil_war_state_cooldown
						days = 180
						value = 1
					}
					state_event = { id = mtg_usa_civil_war_fascists.202 trigger_for = controller }
				}
			}
			if = {
				limit = {
					original_tag = USA
					has_civil_war = yes
					tag = event_target:USA_civil_war_democrats
					has_country_flag = citizen_militia_spawned
					FROM.FROM = {
						is_core_of = USA
						has_state_flag = USA_citizen_militia
						not = { has_state_flag = USA_militia_spawned }
					}
				}
				FROM.FROM = {
					set_state_flag = USA_militia_spawned
					state_event = { id = mtg_usa_civil_war_fascists.1000 trigger_for = controller }
				}
			}
			if = {
				limit = {
					FROM.FROM = {
						state = 85
						has_dynamic_modifier = { modifier = international_city }
					}
					FROM = {
						OR = {
							original_tag = POL
							tag = POL
						}
					}
				}
				FROM.FROM = { remove_dynamic_modifier = { modifier = international_city } }
			}

			if = {
				limit = {
					FROM = {
						is_in_faction = yes
					}

					FROM.FROM = {
						has_state_flag = prevent_auto_flip_after_capitulation
					}
				}

				FROM.FROM = { clr_state_flag = prevent_auto_flip_after_capitulation }
				FROM = {
					set_state_controller = FROM.FROM
				}
				
			}
		}
	}



	# From is owner country
	on_army_leader_daily = {
		effect = {
			if = {
				limit = {
					check_variable = { random < 0.02 }
					NOT = { has_trait = sick }
					set_temp_variable = { temp = sum_unit_terrain_modifier@sickness_chance }
					divide_temp_variable = { temp = num_units }
					check_variable = { temp > 0.75 }
					NOT = { has_unit_leader_flag = recently_sick }
				}
				add_timed_unit_leader_trait = {
					trait = sick
					days = 30
				}
				unit_leader_event = { id = generic.17 }
			}
		}
	}

	# From is owner country
	on_army_leader_won_combat = {
		effect = {
			if = {
				limit = {
					set_temp_variable = { chance = 0.001 }
					set_temp_variable = { factor = 1.0 }
					add_to_temp_variable = { factor = leader_modifier@wounded_chance_factor }
					multiply_temp_variable = { chance = factor }
					check_variable = { random < chance }
					NOT = { has_trait = wounded }
				}
				add_timed_unit_leader_trait = {
					trait = wounded
					days = 90
				}
				unit_leader_event = { id = generic.18 }
			}
		}
	}

	# From is owner country
	on_army_leader_lost_combat = {
		effect = {
			if = {
				limit = {
					set_temp_variable = { chance = 0.005 }
					set_temp_variable = { factor = 1.0 }
					add_to_temp_variable = { factor = leader_modifier@wounded_chance_factor }
					multiply_temp_variable = { chance = factor }
					check_variable = { random < chance }
					NOT = { has_trait = wounded }
				}
				add_timed_unit_leader_trait = {
					trait = wounded
					days = 90
				}
				unit_leader_event = { id = generic.18 }
			}
		}
	}

	on_army_leader_promoted = {
		effect = {
			add_timed_unit_leader_trait = {
				trait = recently_promoted
				days = 100
			}
		}
	}

	# root country that invades
	# scope state that is invaded
	# from scope state that the invasion started
	on_naval_invasion = {
	 	effect = {
		 	if = {
				limit = {
					ROOT = {
						divisions_in_state = {
							 unit = marine_commando
							 size > 0
							 state = PREV
						}
						 has_tech = marines_commandos_demolition 
					}
					NOT = { has_state_flag = marines_commando_effect }
					OWNER = { NOT = { tag = ROOT } }
				}
				SF_marine_demoliton_effect = yes # Note that the state flag condition is not preventing it from doing 1 damage per division 
			}
	 	}
	}


	# root country that paradrops
	# scope state that is paradroped into
	# from scope state that the paradrop started
	on_paradrop = {
	    effect = {
		    ROOT = { set_country_flag = has_paradropped_flag }
		}
	}
	on_ruling_party_change = {
		# temp var old_ideology_token is available for effects
		effect = {
			every_controlled_state = {
				limit = {
					has_resistance = yes
				}
				set_temp_variable = { new_compliance = compliance }
				multiply_temp_variable = { new_compliance = 0.5 }
				set_compliance = new_compliance
			}
		}
	}

	on_unit_leader_promote_from_ranks_veteran = { #Unit leader scope, FROM is unit
		effect = {
			FROM = {
				add_random_valid_trait_from_unit = {
					character = ROOT
				}
			}
			set_unit_leader_flag = field_promotion_achievement
		}
	}

	on_unit_leader_promote_from_ranks_green = { #Unit leader scope, FROM is unit
		effect = {
			set_unit_leader_flag = field_promotion_achievement
		}
	}

	on_add_history = { #Unit Scope
		effect = {
			#add_unit_medal_to_latest_entry = {
			#	unit_medals = iron_cross_second_class
			#} #This would add a unit medal to the history entry you just received
		}
	}

	on_weekly_GER = {
		effect = {
			GER = {
				every_core_state = {
					limit = {
						has_dynamic_modifier = {
							modifier = GER_poor_iron_quality
						}
					}
					SWE_update_iron_ore_calc = yes
				}
			}
		}
	}
	
	# root is the state that was dropped into
	# from is the dropping country
	# this differs from on_paradrop in that it is run once per paradrop, not once per unit dropped
	on_units_paradropped_in_state = {
		effect = {
			if = {
				limit = { 
					FROM = { has_tech = paras_dispersed_drop } 
					NOT = { has_state_flag = para_drop_effect }
					CONTROLLER = { NOT = { tag = FROM } }
				}
				SF_PARA_sabotage_effect = yes
			}
			if = {
				limit = { 
					FROM = { has_tech = paras_combat_drop } 
					NOT = { has_state_flag = para_drop_effect }
				}
				SF_PARA_combat_effect_lsm = yes
			}
		}
	}

	on_peaceconference_started = {
		effect = {
			if = {
				limit = {
					295 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				295 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}

			if = {
				limit = {
					538 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				538 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}

			if = {
				limit = {
					888 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				888 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}

			if = {
				limit = {
					889 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				889 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}

			if = {
				limit = {
					890 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				890 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}


			if = {
				limit = {
					769 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				769 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}

			if = {
				limit = {
					768 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				768 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}

			if = {
				limit = {
					718 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				718 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}

			if = {
				limit = {
					635 = { has_state_flag = prevent_auto_flip_after_capitulation }
				}
				635 = { clr_state_flag = prevent_auto_flip_after_capitulation }
			}
		}
	}



	on_monthly_GER = {
		effect = {
			if = {
				limit = {
					144 = { is_fully_controlled_by = GER }
					check_variable = { GER_narvik_civs < 8 }
					
					666 = {
						NOT = {
							has_dynamic_modifier = {
								modifier = SWE_blown_up_mines
							}
						}
					}
				}

				add_to_variable = { GER_narvik_shipments = 1 }
				if = {
					limit = {
						check_variable = { GER_narvik_shipments > 5 }
					}

					add_offsite_building = {
						type = industrial_complex
						level = 1
					}

					set_variable = { GER_narvik_shipments = 0 }
					add_to_variable = { GER_narvik_civs = 1 }
				}
			}
		}
	}
}
