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
		}
		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
		}
	}

	# 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
		}
	}

	# country, FROM = ace
	on_ace_killed = {
		random_events = {
			100 = ace_died.1
		}
	}

	# 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
			#Soviet demands

		}
	}

	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 = {
				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
			}
			if = {
				limit = {
					FROM = {
						is_core_of = JAP
					}
					NOT = {
						has_global_flag = JAP_nuke_1
					}
				}
				set_global_flag = JAP_nuke_1
			}
			
			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 = { 
					AND = {
						tag = CAN 	
						NOT = { has_dlc = "Together for Victory" }
					}
				}
				drop_cosmetic_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 = {
			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 = { tag = SOV }
					FROM = { has_idea = anti_soviet_pact }
				}
				FROM = {
					country_event = { id = germany.84 days = 1 }
				}
			}

			#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
						has_completed_focus = FRA_support_the_right
					}
					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 = {
					NOT = { original_tag = GER }
					NOT = { has_government = fascism }
					NOT = { has_civil_war = yes }
				}
			}
			news_event = { id = country_capitulated.0 days = 0 }
			if = {
				limit = { 
					original_tag = POL
					has_government = neutrality
				}
				retire_country_leader = yes
			}
			if = {
				limit = {
					original_tag = YUG
				}
				remove_ideas = YUG_idea_economic_aid
			}
			if = {
				limit = {
					original_tag = DEN
				}
				country_event = { id = wtt_denmark.1 days = 1 }
			}
		}
	}

	# ROOT is previously capitulated country
	on_uncapitulation = {
		effect = {
			if = {
				limit = {
					original_tag = FRA
					has_government = democratic
					is_puppet = no
				}
				drop_cosmetic_tag = yes
			}
		}
	}

	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 = {
					elections_allowed = yes
				}
			}
		}
	}

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

			#End of SCW / not any longer
			if = {
				limit = {
					has_government = democratic			
				}
				set_politics = {
					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 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 }
			}
		}
	}

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

	#Can be used for Ned Stark!
	
	on_puppet = {
		effect = {
			if = {
				limit = {
					OR = {
						original_tag = DDR
						original_tag = WGR
						original_tag = GER
					}
					has_government = communism
					has_country_leader = { name = "Wilhelm Pieck" }
					FROM = {
						original_tag = SOV
						has_government = communism
						has_country_leader = { name = "Joseph Stalin" } # Would look silly if Trotsky released Stalin's Puppet
					}
				}
				add_country_leader_trait = stalins_puppet
			}
		}
	}
	
	#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
					has_country_leader = { name = "Wilhelm Pieck" }
					FROM = {
						original_tag = SOV
						has_government = communism
						has_country_leader = { name = "Joseph Stalin" } # Would look silly if Trotsky released Stalin's Puppet
					}
				}
				add_country_leader_trait = stalins_puppet
			}
		}
	}
	
	#ROOT is winner #FROM gets annexed - For civil wars on_civil_war_end is also fired
	on_annex = {
		effect = {
			
		}
	}

	#Not run on a specific country.
	on_startup = {
		effect = {
#			ITA = {
#				if = {
#					limit = {
#						has_game_rule = {
#							rule = ITA_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						50 = { ITA = { set_country_flag = ITA_AI_RANDOM_FASCIST_HISTORICAL } }
#						50 = { ITA = { set_country_flag = ITA_AI_RANDOM_FASCIST_ALTERNATE } }
#					}
#				}
#			}
#			CHI = {
#				if = {
#					limit = {
#						has_dlc = "Waking the Tiger"
#						has_game_rule = {
#							rule = CHI_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						50 = { CHI = { set_country_flag = CHI_AI_RANDOM_HISTORICAL } }
#						50 = { CHI = { set_country_flag = CHI_AI_RANDOM_ALTERNATE } }
#					}
#				}
#			}
#			MAN = {
#				if = {
#					limit = {
#						has_dlc = "Waking the Tiger"
#						has_game_rule = {
#							rule = MAN_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						40 = { MAN = { set_country_flag = MAN_AI_RANDOM_OBEDIENCE } }
#						60 = { MAN = { set_country_flag = MAN_AI_RANDOM_INDEPENDENCE } }
#					}
#				}
#			}
#			SOV = {
#				if = {
#					limit = {
#						has_game_rule = {
#							rule = SOV_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						50 = { SOV = { set_country_flag = ITA_SOV_RANDOM_COMMUNIST_HISTORICAL } }
#						50 = { SOV = { set_country_flag = ITA_SOV_RANDOM_COMMUNIST_ALTERNATE } }
#					}
#				}
#			}
#			FRA = {
#				if = { 
#					limit = {
#						has_game_rule = {
#							rule = FRA_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						15 = { set_country_flag = FRA_AI_RANDOM_COMMUNIST }
#						40 = { set_country_flag = FRA_AI_RANDOM_DEMOCRATIC_ALTERNATE }
#						30 = { set_country_flag = FRA_AI_DEMOCRATIC_HISTORICAL }
#						15 = { set_country_flag = FRA_AI_RANDOM_FASCIST }
#					}
#				}
#			}
#			ROM = {
#				if = { 
#					limit = {
#						has_dlc = "Death or Dishonor"
#						has_game_rule = {
#							rule = ROM_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						25 = { set_country_flag = ROM_AI_RANDOM_BALKAN_DOMINANCE }
#						10 = { set_country_flag = ROM_AI_RANDOM_DEMOCRATIC }
#						40 = { set_country_flag = ROM_AI_RANDOM_FASCIST_HISTORICAL }
#						25 = { set_country_flag = ROM_AI_RANDOM_COMMUNIST }
#					}
#				}
#			}
#			HUN = {
#				if = { 
#					limit = {
#						has_dlc = "Death or Dishonor"
#						has_game_rule = {
#							rule = HUN_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						5 = { set_country_flag = HUN_AI_RANDOM_COMMUNIST }
#						20 = { set_country_flag = HUN_AI_RANDOM_AUSTRIA_HUNGARY }
#						10 = { set_country_flag = HUN_AI_RANDOM_DEMOCRATIC }
#						40 = { set_country_flag = HUN_AI_RANDOM_FASCIST_HISTORICAL }
#						25 = { set_country_flag = HUN_AI_RANDOM_FASCIST_ALTERNATE }
#					}
#				}
#			}
#			CAN = {
#				if = { 
#					limit = {
#						has_dlc = "Together for Victory"
#						has_game_rule = {
#							rule = CAN_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						15 = { set_country_flag = CAN_AI_RANDOM_COMMUNIST }
#						30 = { set_country_flag = CAN_AI_RANDOM_DEMOCRATIC_ALTERNATE }
#						40 = { set_country_flag = CAN_AI_DEMOCRATIC_HISTORICAL }
#						15 = { set_country_flag = CAN_AI_RANDOM_FASCIST }
#					}
#				}
#			}
#			RAJ = {
#				if = { 
#					limit = {
#						has_dlc = "Together for Victory"
#						has_game_rule = {
#							rule = RAJ_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						25 = { set_country_flag = RAJ_AI_RANDOM_COMMUNIST }
#						50 = { set_country_flag = RAJ_AI_DEMOCRATIC_HISTORICAL }
#						25 = { set_country_flag = RAJ_AI_RANDOM_FASCIST }
#					}
#				}
#			}
#			POL = {
#				if = { 
#					limit = {
#						has_dlc = "Poland: United and Ready"
#						has_game_rule = {
#							rule = POL_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						25 = { set_country_flag = POL_AI_RANDOM_COMMUNIST }
#						50 = { set_country_flag = POL_AI_DEMOCRATIC_HISTORICAL }
#						25 = { set_country_flag = POL_AI_RANDOM_FASCIST }
#					}
#				}
#			}
#			ENG = {
#				if = { 
#					limit = {
#						has_dlc = "Man the Guns"
#						has_game_rule = {
#							rule = ENG_ai_behavior
#							option = RANDOM
#						}
#					}
#					random_list = {
#						15 = { set_country_flag = ENG_AI_RANDOM_COMMUNIST }
#						25 = { set_country_flag = ENG_AI_RANDOM_DEMOCRATIC_ALTERNATE }
#						30 = { set_country_flag = ENG_AI_DEMOCRATIC_HISTORICAL }
#						20 = { set_country_flag = ENG_AI_RANDOM_NEUTRALITY }
#						20 = { set_country_flag = ENG_AI_RANDOM_FASCIST }
#					}
#				}
#			}
		}
	}
	
	on_unit_leader_created = {
		effect = {
		}
	}
	
	on_unit_leader_level_up = {
		effect = {
			
		}
	}	

	# Scope is the country owner of the PotF, FROM is the country of the killer
	on_pride_of_the_fleet_sunk = {
	}

	# 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 = {
	# 	}
	# }


	# root country that paradrops
	# scope state that is paradroped into
	# from scope state that the paradrop started
	on_paradrop = {
	    effect = {
		    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
		}
	}

}
