#Unlisted on_actions by haveabeard
#http://forum.paradoxplaza.com/forum/index.php?threads/list-of-currently-hardcoded-features-mechanics-etc-in-hoi4.957265/page-25#post-22275603
#on_military_access
#on_offer_military_access
#on_improve_relation
#on_guarantee
#on_non_aggression_pact
#on_call_allies
#on_join_allies
#on_declare_war
#on_create_faction
#on_join_faction
#on_offer_join_faction
#on_peace_proposal
#on_add_wargoal
#on_lend_lease
#on_incoming_lend_lease
#on_send_volunteers
#on_send_expeditionary_force
#on_return_expeditionary_forces
#on_request_expeditionary_forces
#on_generate_wargoal
#on_boost_party_popularity
#on_stage_coup
#on_leave_faction
#on_dismantle_faction
#on_ask_for_state_control
#on_give_state_control
#on_reduce_autonomy
#on_increase_autonomy

on_actions = {
	# country

	#Timed pulses, four year and thri yearly pulses copied from EUIV, weekly and monthly from the top of my head, doesn't given an error at least?
	on_daily = {
	
	}
	
	on_weekly = {
	
	}
	
	on_monthly = {
	
	}
	
	on_thri_yearly_pulse = {
	
	}
	
	on_bi_yearly_pulse = {
		effect = {
			every_country = { 
				update_AI_NO_WANT_DEBT = yes
				2017_state_init_setup = yes #updates all global state categories
			}
		}
	}
	
	on_four_year_pulse = {
	
	}

	on_five_year_pulse = {

	}
	
	on_peace_proposal = {
		effect = {
			THIS = { update_AI_NO_WANT_DEBT = yes }
		}
	}

	on_new_term_election = {

		random_events = {
			100 = poland_election.1
			100 = taiwan.3
		}

		random_events = {
			100 = MD4_election_campaign.0
			# 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 = {

	}

	# country, FROM = ace, PREV = enemy ace
	# This event fires twice, once for each ace.
	on_aces_killed_each_other = {

	}

	# country, FROM = our ace,
	# PREV = enemy ace, has killed FROM
	on_ace_killed_by_ace = {

	}

	# country, FROM = our ace,
	# PREV = enemy ace, killed by FROM
	on_ace_killed_other_ace = {

	}

	# country, FROM = ace
	on_ace_killed = {

	}

	# 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 = {
			1000 = NATO.1
		}
	}

	on_wargoal_expire = {
		effect = {

		}
	}

	#FROM is state #ROOT is broken as hell
	on_nuke_drop = {
		effect = {
		}
	}

	on_border_war_lost = {
		effect = {

		}
	}

	on_leave_faction = {
		effect = {

		}
	}

	#FROM is the one that joins the faction
	on_create_faction = {

	}

	#FROM is country getting invited.
	on_offer_join_faction = {
		effect = {

		}
	}

	#FROM is faction leader on join faction requests.
	on_join_faction = {
		effect = {
			THIS = { update_AI_NO_WANT_DEBT = yes }
		}
	}

	# ROOT is capitulated country, FROM is winner
	on_capitulation = {
		effect = {
			news_event = { id = country_capitulated.0 days = 1 }
			
			#Special capitulation for ISIS
			if = {
				limit = { 
					original_tag = ISI
					has_start_date > 2016.1.1
				}
				# Give Iraqi states first Kurdistan if they've capture them, otherwise return to Iraq
				every_owned_state = {
					limit = { 
						is_core_of = IRQ
						is_controlled_by = KUR
					}
					KUR = {
						set_state_owner = PREV
					}
				}
				every_owned_state = {
					limit = { 
						is_core_of = IRQ
					}
					IRQ = {
						set_state_owner = PREV
					}
				}
				# In Syria, give every non-capital state to its current controller
				every_owned_state = {
					limit = { 
						is_core_of = SYR
					}
					controller = {
						transfer_state = PREV
					}
				}
				# Rest to the winner
				FROM = { annex_country = { target = ISI } }
			}			
		}
		
	}

	#FROM is war target
	on_declare_war = {
		effect = {
			if = {
				limit = {
					#both in civil war
					ROOT = { original_tag = FROM }
					FROM = { NOT = { has_country_flag = no_leader_change } }
				}
				#assumes ROOT = civil war tag
				ROOT = {
					#Politics
					if = {
						limit = {
							NOT = { has_variable = ruling_party^0 }
						}
						start_politics_input = yes
						
						#copy politics
						for_loop_effect = {
							end = party_pop_array^num
							value = v
							set_variable = { party_pop_array^v = FROM.party_pop_array^v }
						}
						
						#realign with new outlook percentages
						add_up_party_totals = yes
						set_party_positions = yes
						
						#check FROM for flag to NOT set leader
						if = {
							limit = {
								NOT = { has_country_flag = no_leader_change }
							}
							set_failsafe_change_leader = yes
							startup_politics = yes
						}
					}
					#VARIABLES
					set_variable = { tax_rate = FROM.tax_rate }
					set_variable = { treasury = FROM.treasury }
					
					#don't get values of original yet - REMINDER -> add it on_civil_war_end
					set_variable = { debt = 0 }
					set_variable = { int_investments = 0 }
					
					#influence
					set_variable = { domestic_influence_amount = FROM.domestic_influence_amount }
					#just copy all
					for_loop_effect = {
						end = FROM.influence_array^num
						value = v
						
						add_to_array = { influence_array = FROM.influence_array^v }
						add_to_array = { influence_array_val = FROM.influence_array_val^v }
					}
					recalculate_influence = yes
					
					#GAME VARIABLES
					add_political_power = FROM.political_power
					add_political_power = 400 #bonus
					
					#LAWS
					set_variable = { gdp_capita = FROM.gdp_capita }
					meta_effect = {
						text = {
							add_ideas = gdp_[GDP_LEVEL]
						}
						GDP_LEVEL = "[?gdp_capita|0]"
					}
					set_variable = { bureaucracy = FROM.bureaucracy }
					meta_effect = {
						text = {
							add_ideas = bureau_0[BUREAU_LEVEL]
						}
						BUREAU_LEVEL = "[?bureaucracy|0]"
					}
					set_variable = { crime_fighting = FROM.crime_fighting }
					meta_effect = {
						text = {
							add_ideas = police_0[POLICE_LEVEL]
						}
						POLICE_LEVEL = "[?crime_fighting|0]"
					}
					set_variable = { education_budget = FROM.education_budget }
					meta_effect = {
						text = {
							add_ideas = edu_0[EDU_LEVEL]
						}
						EDU_LEVEL = "[?education_budget|0]"
					}
					set_variable = { health_budget = FROM.health_budget }
					meta_effect = {
						text = {
							add_ideas = health_0[HEALTH_LEVEL]
						}
						HEALTH_LEVEL = "[?health_budget|0]"
					}
					set_variable = { social_budget = FROM.social_budget }
					meta_effect = {
						text = {
							add_ideas = social_0[WELFARE_LEVEL]
						}
						WELFARE_LEVEL = "[?social_budget|0]"
					}
					
					set_variable = { Military_Spending = FROM.Military_Spending }
					subtract_from_variable = { Military_Spending = 1 }
					meta_effect = {
						text = {
							add_ideas = defence_0[DEFENCE_LEVEL]
						}
						DEFENCE_LEVEL = "[?Military_Spending|0]"
					}
					set_variable = { Military_Spending = FROM.Military_Spending }
					
					set_variable = { economic_cycles = FROM.economic_cycles }
					if = { limit = { check_variable = { economic_cycles = 6 } }
						add_ideas = depression
					}
					else_if = { limit = { check_variable = { economic_cycles = 5 } }
						add_ideas = recession
					}
					else_if = { limit = { check_variable = { economic_cycles = 4 } }
						add_ideas = stagnation
					}
					else_if = { limit = { check_variable = { economic_cycles = 3 } }
						add_ideas = stable_growth
					}
					else_if = { limit = { check_variable = { economic_cycles = 2 } }
						add_ideas = fast_growth
					}
					else_if = { limit = { check_variable = { economic_cycles = 1 } }
						add_ideas = economic_boom
					}
					
					if = { limit = { FROM = { has_idea = paralyzing_corruption } }
						add_ideas = paralyzing_corruption
					}
					else_if = { limit = { FROM = { has_idea = crippling_corruption } }
						add_ideas = crippling_corruption
					}
					else_if = { limit = { FROM = { has_idea = rampant_corruption } }
						add_ideas = rampant_corruption
					}
					else_if = { limit = { FROM = { has_idea = unrestrained_corruption } }
						add_ideas = unrestrained_corruption
					}
					else_if = { limit = { FROM = { has_idea = systematic_corruption } }
						add_ideas = systematic_corruption
					}
					else_if = { limit = { FROM = { has_idea = widespread_corruption } }
						add_ideas = widespread_corruption
					}
					else_if = { limit = { FROM = { has_idea = medium_corruption } }
						add_ideas = medium_corruption
					}
					else_if = { limit = { FROM = { has_idea = modest_corruption } }
						add_ideas = modest_corruption
					}
					else_if = { limit = { FROM = { has_idea = slight_corruption } }
						add_ideas = slight_corruption
					}
					else_if = { limit = { FROM = { has_idea = negligible_corruption } }
						add_ideas = negligible_corruption
					}
					
					if = { limit = { FROM = { has_idea = consumption_economy } }
						add_ideas = consumption_economy
					}
					else_if = { limit = { FROM = { has_idea = mixed_economy } }
						add_ideas = mixed_economy
					}
					else_if = { limit = { FROM = { has_idea = export_economy } }
						add_ideas = export_economy
					}
					
					if = { limit = { FROM = { has_idea = no_military } }
						add_ideas = no_military
					}
					else_if = { limit = { FROM = { has_idea = volunteer_army } }
						add_ideas = volunteer_army
					}
					else_if = { limit = { FROM = { has_idea = partial_draft_army } }
						add_ideas = partial_draft_army
					}
					else_if = { limit = { FROM = { has_idea = draft_army } }
						add_ideas = draft_army
					}
					
					if = { limit = { FROM = { has_idea = no_women_in_military } }
						add_ideas = no_women_in_military
					}
					else_if = { limit = { FROM = { has_idea = volunteer_women } }
						add_ideas = volunteer_women
					}
					else_if = { limit = { FROM = { has_idea = drafted_women } }
						add_ideas = drafted_women
					}
					
					if = { limit = { FROM = { has_idea = intervention_isolation } }
						add_ideas = intervention_isolation
					}
					else_if = { limit = { FROM = { has_idea = intervention_local_security } }
						add_ideas = intervention_local_security
					}
					else_if = { limit = { FROM = { has_idea = intervention_limited_interventionism } }
						add_ideas = intervention_limited_interventionism
					}
					else_if = { limit = { FROM = { has_idea = intervention_regional_interventionism } }
						add_ideas = intervention_regional_interventionism
					}
					else_if = { limit = { FROM = { has_idea = intervention_global_interventionism } }
						add_ideas = intervention_global_interventionism
					}
					else_if = { limit = { FROM = { has_idea = intervention_neo_imperialism } }
						add_ideas = intervention_neo_imperialism
					}
					
					if = { limit = { FROM = { has_idea = officer_baptism_by_fire } }
						add_ideas = officer_baptism_by_fire
					}
					else_if = { limit = { FROM = { has_idea = officer_basic_training } }
						add_ideas = officer_basic_training
					}
					else_if = { limit = { FROM = { has_idea = officer_advanced_training } }
						add_ideas = officer_advanced_training
					}
					else_if = { limit = { FROM = { has_idea = officer_military_school } }
						add_ideas = officer_military_school
					}
					else_if = { limit = { FROM = { has_idea = officer_military_academy } }
						add_ideas = officer_military_academy
					}
					else_if = { limit = { FROM = { has_idea = officer_international_education } }
						add_ideas = officer_international_education
					}
					
					### Internal factions
					if = { limit = { FROM = { has_idea = small_medium_business_owners } }
						add_ideas = small_medium_business_owners
					}
					if = { limit = { FROM = { has_idea = international_bankers } }
						add_ideas = international_bankers
					}
					if = { limit = { FROM = { has_idea = fossil_fuel_industry } }
						add_ideas = fossil_fuel_industry
					}
					if = { limit = { FROM = { has_idea = industrial_conglomerates } }
						add_ideas = industrial_conglomerates
					}
					if = { limit = { FROM = { has_idea = oligarchs } }
						add_ideas = oligarchs
					}
					if = { limit = { FROM = { has_idea = maritime_industry } }
						add_ideas = maritime_industry
					}
					if = { limit = { FROM = { has_idea = defense_industry } }
						add_ideas = defense_industry
					}
					if = { limit = { FROM = { has_idea = the_military } }
						add_ideas = the_military
					}
					if = { limit = { FROM = { has_idea = intelligence_community } }
						add_ideas = intelligence_community
					}
					if = { limit = { FROM = { has_idea = labour_unions } }
						add_ideas = labour_unions
					}
					if = { limit = { FROM = { has_idea = landowners } }
						add_ideas = landowners
					}
					if = { limit = { FROM = { has_idea = farmers } }
						add_ideas = farmers
					}
					if = {
						limit = { 
							FROM = {
								has_idea = communist_cadres
								ROOT = {
									OR = {
										is_in_array = { ruling_party = 4 }
										is_in_array = { ruling_party = 19 }
									}
								}
							}
						}
						add_ideas = communist_cadres
					}
					if = { limit = { FROM = { has_idea = the_priesthood } }
						add_ideas = the_priesthood
					}
					if = { limit = { FROM = { has_idea = The_Ulema } }
						add_ideas = The_Ulema
					}
					if = { limit = { FROM = { has_idea = The_Clergy } }
						add_ideas = The_Clergy
					}
					if = { limit = { FROM = { has_idea = wahabi_ulema } }
						add_ideas = wahabi_ulema
					}
					if = { limit = { FROM = { has_idea = the_donju } }
						add_ideas = the_donju
					}
					if = { limit = { FROM = { has_idea = the_bazaar } }
						add_ideas = the_bazaar
					}
					if = {
						limit = { 
							FROM = {
								has_idea = saudi_royal_family
								ROOT = {
									OR = {
										is_in_array = { ruling_party = 10 }
										is_in_array = { ruling_party = 23 }
										is_in_array = { ruling_party = 0 }
									}
								}
							}
						}
						add_ideas = saudi_royal_family
					}
					if = {
						limit = { 
							FROM = {
								has_idea = irgc
								ROOT = {
									NOT = {
										OR = {
											has_government = democratic
											has_government = fascism
										}
									}
								}
							}
						}
						add_ideas = irgc
					}
					if = {
						limit = { 
							FROM = {
								has_idea = iranian_quds_force
								ROOT = {
									NOT = {
										OR = {
											has_government = democratic
											has_government = fascism
										}
									}
								}
							}
						}
						add_ideas = iranian_quds_force
					}
					if = {
						limit = { 
							FROM = {
								has_idea = vevak
								ROOT = {
									NOT = {
										OR = {
											has_government = democratic
											has_government = fascism
										}
									}
								}
							}
						}
						add_ideas = vevak
					}
					if = {
						limit = { 
							FROM = {
								has_idea = foreign_jihadis
								ROOT = {
									OR = {
										is_in_array = { ruling_party = 11 }
									}
								}
							}
						}
						add_ideas = foreign_jihadis
					}
					if = { limit = { FROM = { has_idea = isi_pakistan } }
						add_ideas = isi_pakistan
					}
					if = { limit = { FROM = { has_idea = wall_street } }
						add_ideas = wall_street
					}
					if = { limit = { FROM = { has_idea = chaebols } }
						add_ideas = chaebols
					}
					
					#copy leader throughput
					set_variable = { Western_Autocracy_leader = FROM.Western_Autocracy_leader?0 }
					set_variable = { conservatism_leader = FROM.conservatism_leader?0 }
					set_variable = { liberalism_leader = FROM.liberalism_leader?0 }
					set_variable = { socialism_leader = FROM.socialism_leader?0 }
					
					set_variable = { Communist-State_leader = FROM.Communist-State_leader?0 }
					set_variable = { anarchist_communism_leader = FROM.anarchist_communism_leader?0 }
					set_variable = { Conservative_leader = FROM.Conservative_leader?0 }
					set_variable = { Autocracy_leader = FROM.Autocracy_leader?0 }
					set_variable = { Mod_Vilayat_e_Faqih_leader = FROM.Mod_Vilayat_e_Faqih_leader?0 }
					set_variable = { Vilayat_e_Faqih_leader = FROM.Vilayat_e_Faqih_leader?0 }
					
					set_variable = { Kingdom_leader = FROM.Kingdom_leader?0 }
					set_variable = { Caliphate_leader = FROM.Caliphate_leader?0 }
					
					set_variable = { Neutral_Muslim_Brotherhood_leader = FROM.Neutral_Muslim_Brotherhood_leader?0 }
					set_variable = { Neutral_Autocracy_leader = FROM.Neutral_Autocracy_leader?0 }
					set_variable = { Neutral_conservatism_leader = FROM.Neutral_conservatism_leader?0 }
					set_variable = { oligarchism_leader = FROM.oligarchism_leader?0 }
					set_variable = { Neutral_Libertarian_leader = FROM.Neutral_Libertarian_leader?0 }
					set_variable = { Neutral_green_leader = FROM.Neutral_green_leader?0 }
					set_variable = { neutral_Social_leader = FROM.neutral_Social_leader?0 }
					set_variable = { Neutral_Communism_leader = FROM.Neutral_Communism_leader?0 }
					set_variable = { Nat_Populism_leader = FROM.Nat_Populism_leader?0 }
					set_variable = { Nat_Fascism_leader = FROM.Nat_Fascism_leader?0 }
					set_variable = { Nat_Autocracy_leader = FROM.Nat_Autocracy_leader?0 }
					set_variable = { Monarchist_leader = FROM.Monarchist_leader?0 }
					
					add_tax_laws = yes
					calculate_influence_percentage = yes #set alignment drifts from influence
					startup_extra_setup = yes 	#money system
					setup_init_factions = yes 	#flags for int. factions
					init_neighbor_drift_1 = yes #drift from neighbor
					init_neighbor_drift_2 = yes #drift from neighbor
					
					country_event = { id = brotherhood.0 } #Sets muslim_brotherhood relations
					country_event = { id = brotherhood.2 }
				}
			}
			hidden_effect = {
				FROM = {
					update_AI_NO_WANT_DEBT = yes
					update_military_rate = yes
					every_neighbor_country = { country_event = low_stability.4 }
				}
				ROOT = {
					update_AI_NO_WANT_DEBT = yes
					update_military_rate = yes
					every_neighbor_country = { country_event = low_stability.4 }
				}
				log = "FROM IS [From.GetName] hello"
				log = "ROOT IS [ROOT.GetName] hello"
			}
			#Used in MD4_Anti_bully decisions
			hidden_effect = { add_timed_idea = { idea = three_months_of_war days = 6 } }
			FROM = { hidden_effect = {  add_timed_idea = { idea = three_months_of_war days = 6 } } }

			#NATO
			if = {
				limit = {
					FROM = { has_idea = NATO_member }
					NOT = { ROOT = { original_tag = FROM } }
				}
				custom_effect_tooltip = TT_CALL_NATO
				if = {
					limit = {
						NOT = { has_global_flag = NATO_called_to_arms }
					}
					FROM = { country_event = NATO.2 }
				}
				set_country_flag = Attacked_NATO
			}

			#Starts Anti-Bully War
			if = {
				limit = {
					has_game_rule = {
						rule = rule_disable_anti_bully
						option = no  
					}
					FROM = { is_major = no }
					FROM = { ic_ratio = { tag = ROOT ratio < 0.4 } }
					not = { has_government = fascism }
					threat < 0.60
					FROM = { any_owned_state = { not = { is_core_of = ROOT } } }
				}
				hidden_effect = {
					save_event_target_as = AB_ATT
					FROM = {
						save_event_target_as = AB_DEFF
					}
					country_event = { id = anti_bully.1 }
				}

			}

			###Activates US Brigade In Poland If US has done USA_Reinforce_NATO_EAST focus
			if = {
				limit = {
					FROM = {
						is_in_faction_with = USA
						or = {
							tag = EST
							tag = LAT
							tag = LIT
							tag = POL
							tag = SLO
							tag = HUN
							tag = ROM

						}
					}
					POL = {
						is_in_faction_with = USA
					}
					USA = {
						has_country_flag = Reinforce_NATO_EAST
					}
				}
				hidden_effect = {
					country_event = { id = USA_FOCUS.2 }
				}

				country_event = { id = USA_FOCUS.2 days = 1 }
				add_threat = 5

			}

			###Activates US Brigade In Turkey If US has done USA_REINFORCE_Bosphorus focus
			if = {
				limit = {
					FROM = {
						is_in_faction_with = USA
						or = {
							tag = BUL
							tag = GRE
							tag = ALB
							tag = TUR

						}
					}
					TUR = {
						is_in_faction_with = USA
					}
					USA = {
						has_country_flag = REINFORCE_Bosphorus
					}
				}
				hidden_effect = {
					USA = {
						country_event = { id = USA_FOCUS.4 }
					}
					USA = {
						country_event = { id = USA_FOCUS.4 days = 1 }
					}
				}

			}

			#Rio Pact
			if = {
				limit = {
					FROM = {
						has_idea = rio_pact_member
					}
					NOT = { ROOT = { original_tag = FROM } }
					ROOT = {
						not = {
							or = {
								tag = ISI
								tag = TAL
								tag = TTP
								tag = NUS
								tag = AQY
								has_country_flag = terrorist_group
							}
						}
					}
				}
				custom_effect_tooltip = TT_RIO_PACT
				hidden_effect = {
					FROM = { country_event = { id = USA.6 } }
				}
				ROOT = { country_event = { id = USA.8 days = 20 } }
			}

		}
	}

	#Ask for Mil access - From is target country
	on_military_access = {
		effect = {
			#country_event = { id = init.1 }
			#FROM = { add_ideas = USA_usaid }
			# if = {
				# limit = { has_government = fascism } #Salafist
			# }
			# if = {
				# limit = { has_government = democratic } #Western
			# }
			# if = {
				# limit = { has_government = communism  } #Emerging
			# }
			# if = {
				# limit = { has_government = neutrality  } #neutrality
			# }
			# if = {
				# limit = { has_government = nationalist  } #nationalist
			# }

		}
	}

	#offer for Mil access to your country - From is target country
	on_offer_military_access = {
		effect = {
			#FROM = { country_event = { id = init.1 } }
			#add_ideas = USA_usaid
		}
	}
	#try on_revoke_guarantee

	# When a new faction is formed
	on_faction_formed = {
		effect = {
		}
	}
	#From is
	on_stage_coup = {
		effect = {
			FROM = {
				every_neighbor_country = { country_event = low_stability.3 }
			}
		}
	}

	on_coup_succeeded = {
		effect = {
			ROOT = {
				country_event = { id = init.2 }
			}
		}
	}

	#ROOT is winner #FROM gets annexed
	on_civil_war_end = {
		effect = {
			ROOT = {
			
				if = {
					limit = {
						check_variable = { debt < FROM.debt } #less than
					}
					add_to_variable = { debt = FROM.debt }
				}
				if = {
					limit = {
						check_variable = { int_investments < FROM.int_investments } #less than
					}
					add_to_variable = { int_investments = FROM.int_investments }
				}
				if = {
					limit = {
						is_in_array = { ruling_party = 0 }
					}
					set_politics = {
						ruling_party = democratic
						elections_allowed = no
					}
				}
				else_if = {
					limit = {
						OR = {
							is_in_array = { ruling_party = 1 }
							is_in_array = { ruling_party = 2 }
							is_in_array = { ruling_party = 3 }
						}
					}
					set_politics = {
						ruling_party = democratic
						elections_allowed = yes
					}
				}
				else_if = {
					limit = {
						OR = {
							is_in_array = { ruling_party = 4 }
							is_in_array = { ruling_party = 7 }
						}
					}
					set_politics = {
						ruling_party = communism
						elections_allowed = no
					}
				}
				else_if = {
					limit = {
						OR = {
							is_in_array = { ruling_party = 5 }
							is_in_array = { ruling_party = 6 }
							is_in_array = { ruling_party = 8 }
							is_in_array = { ruling_party = 9 }
						}
					}
					set_politics = {
						ruling_party = communism
						elections_allowed = yes
					}
				}
				else_if = {
					limit = {
						OR = {
							is_in_array = { ruling_party = 10 }
							is_in_array = { ruling_party = 11 }
						}
					}
					set_politics = {
						ruling_party = fascism
						elections_allowed = no
					}
				}
				else_if = {
					limit = {
						OR = {
							is_in_array = { ruling_party = 13 }
							is_in_array = { ruling_party = 19 }
						}
					}
					set_politics = {
						ruling_party = neutrality
						elections_allowed = no
					}
				}
				else_if = {
					limit = {
						OR = {
							is_in_array = { ruling_party = 12 }
							is_in_array = { ruling_party = 14 }
							is_in_array = { ruling_party = 15 }
							is_in_array = { ruling_party = 16 }
							is_in_array = { ruling_party = 17 }
							is_in_array = { ruling_party = 18 }
						}
					}
					set_politics = {
						ruling_party = neutrality
						elections_allowed = yes
					}
				}
				else_if = {
					limit = {
						OR = {
							is_in_array = { ruling_party = 21 }
							is_in_array = { ruling_party = 22 }
							is_in_array = { ruling_party = 23 }
						}
					}
					set_politics = {
						ruling_party = nationalist
						elections_allowed = no
					}
				}
				else_if = {
					limit = {
						is_in_array = { ruling_party = 20 }
					}
					set_politics = {
						ruling_party = nationalist
						elections_allowed = yes
					}
				}
			}
		}
	}

	on_guarantee = {
	}

	on_improve_relation = {
	}

	on_startup = {
		effect = {
			log = "[GetDateText]: [This.GetName]: on_startup init begun"
			#Fixing war between a bunch of countries because raisins
			
			LIB = { if = { limit = { NOT = { country_exists = LUR } } white_peace = GUI white_peace = SIE } }
			DRC = { if = { limit = { NOT = { country_exists = MLC } } white_peace = UGA white_peace = RWA } }
			LIB = { set_law_attitudes = yes } #any country will do
			
			every_country = {
				add_tax_laws = yes
				calculate_influence_percentage = yes #set alignment drifts from influence
				startup_politics = yes
				startup_extra_setup = yes 	#money system
				setup_init_factions = yes 	#flags for int. factions
				set_law_vars = yes 	#vars for change laws secondary effects
				init_neighbor_drift_1 = yes #drift from neighbor
				init_neighbor_drift_2 = yes #drift from neighbor
				init_AI_strategy_1 = yes
				init_AI_strategy_2 = yes
				
				country_event = { id = brotherhood.0 } #Sets muslim_brotherhood relations
				country_event = { id = brotherhood.2 }
				set_country_flag = { flag = total_AB_wars value = 0 }
				#news_event = { id = USA_Russia_Investigation.0 days = 35 }
				
				if = {
					limit = { is_ai = no } country_event = { id = init.0 } #has no effects except startup text
				}
				else = {
					give_AI_templates = yes
				}
				
				set_variable = { AC_build_amount = 1 }
				if = { #Set NATO tech sharing
					limit = { has_dlc = "Together for Victory" }
					every_country = { limit = { has_idea = NATO_member } add_to_tech_sharing_group = NATO_Tech_Share }
				}
				if = {
					limit = { has_start_date > 2016.1.1 }		#2017 state category update
					2017_state_init_setup = yes
				}
				if = {
					limit = { has_stability < 0.36 }
					low_stability_init = yes
				}
				if = {
					limit = { has_focus_tree = generic_focus }
					if = {
						limit = { OR = { has_idea = gdp_3 has_idea = gdp_4 has_idea = gdp_5 } }
						hidden_effect = {
							complete_national_focus = GENERIC_build_primary_schools
						}
					}
					if = {
						limit = { OR = { has_idea = gdp_6 has_idea = gdp_7 has_idea = gdp_8 has_idea = gdp_9 has_idea = gdp_10 has_idea = gdp_11 has_idea = gdp_12 } }
						hidden_effect = {
							complete_national_focus = GENERIC_build_primary_schools
							complete_national_focus = GENERIC_assure_access_to_education
						}
					}
				}
			}
			
			random_country = {
				if = {
					limit = { has_start_date < 2001.1.1 }		#2000 relations
					country_event = { id = init_relations.1 }
				}
				if = {
					limit = { has_start_date > 2016.1.1 }		#2017 relations
					country_event = { id = init_relations.0 }
				}
			}
			
			USA = {
				if = { 
					limit = { has_start_date > 2016.1.1 } 
					country_event = { id = USA.1 days = 1 } 
					country_event = { id = USA.2 days = 19 }
				}
				#9/11
				if = {
					limit = { has_start_date < 2001.1.1 }
					country_event = { id = wot.1 days = 450 random = 8760 }
				}				
			}
			CAN = {
				CAN_update_french_happiness = yes
				country_event = canada.4
			}

			# ISI = {
				# if = { limit = { is_ai = yes } set_technology = { ISIS_JIHAD = 1 } }
				# if = { limit = { is_ai = no } set_technology = { ISIS_JIHAD_HUMAN = 1 } }
			# }
			AFG = {
				if = {
					limit = { has_start_date < 2001.1.1 }
					country_event = { id = Afghanistan.3 days = 635 random = 1440 }
				}
			}
			
			log = "[GetDateText]: [This.GetName]: on_startup init completed"
		}

	}
	on_government_change = {
		effect = {
			
			every_neighbor_country = {
				clear_neighbor_count_ideas = yes
				set_country_flag = { flag = neighbor_count value = 0 }

					every_neighbor_country = {
						limit = {
							has_government = fascism
							is_major = no
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 }
						}
					}

				salafist_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

					every_neighbor_country = {
						limit = {
							has_government = fascism
							is_major = yes
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				salafist_major_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

					every_neighbor_country = {
						limit = {
							has_government = democratic
							is_major = no
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				western_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

					every_neighbor_country = {
						limit = {
							has_government = democratic
							is_major = yes
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				western_major_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

				every_neighbor_country = {
						limit = {
							has_government = communism
							is_major = no
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				emerging_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

					every_neighbor_country = {
						limit = {
							has_government = communism
							is_major = yes
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				emerging_major_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

				every_neighbor_country = {
						limit = {
							has_government = neutrality
							is_major = no
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				non_alligned_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

					every_neighbor_country = {
						limit = {
							has_government = neutrality
							is_major = yes
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				non_alligned_major_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

				every_neighbor_country = {
						limit = {
							has_government = nationalist
							is_major = no
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				nationalist_count = yes
				clr_country_flag = neighbor_count
				set_country_flag = { flag = neighbor_count value = 0 }

					every_neighbor_country = {
						limit = {
							has_government = nationalist
							is_major = yes
						}
						PREV = { modify_country_flag = { flag = neighbor_count value = 1 } }
					}

				nationalist_major_count = yes
				clr_country_flag = neighbor_count

			}
			clear_own_ideology_drift = yes
			### Boost to ruling parties ###
			if = {
				limit = {
					has_government = fascism
					is_major = no
				}
				add_ideas = ruling_party_salafist
			}
			if = {
				limit = {
					has_government = fascism
					is_major = yes
				}
				add_ideas = major_ruling_party_salafist
			}
			if = {
				limit = {
					has_government = democratic
					is_major = no
				}
				add_ideas = ruling_party_western
			}
			if = {
				limit = {
					has_government = democratic
					is_major = yes
				}
				add_ideas = major_ruling_party_western
			}
			if = {
				limit = {
					has_government = communism
					is_major = no
				}
				add_ideas = ruling_party_emerging
			}
			if = {
				limit = {
					has_government = communism
					is_major = yes
				}
				add_ideas = major_ruling_party_emerging
			}
			if = {
				limit = {
					has_government = neutrality
					is_major = no
				}
				add_ideas = ruling_party_non_alligned
			}
			if = {
				limit = {
					has_government = neutrality
					is_major = yes
				}
				add_ideas = major_ruling_party_non_alligned
			}
			if = {
				limit = {
					has_government = nationalist
					is_major = no
				}
				add_ideas = ruling_party_nationalist
			}
			if = {
				limit = {
					has_government = nationalist
					is_major = yes
				}
				add_ideas = major_ruling_party_nationalist
			}
			clear_previous_economic_drift = yes
			if = {
				limit = {
					has_idea = economic_boom
				}
				update_drift_economic_boom = yes
			}
			if = {
				limit = {
					has_idea = fast_growth
				}
				update_drift_fast_growth = yes
			}
			if = {
				limit = {
					has_idea = stagnation
				}
				update_drift_stagnation = yes
			}
			if = {
				limit = {
					has_idea = recession
				}
				update_drift_recession = yes
			}
			if = {
				limit = {
					has_idea = depression
				}
				update_drift_depression = yes
			}
		}
	}
}
