﻿# Outlook drift based on neighbors
#by Killerrabbit

add_namespace = neighbor_drift

#Pulse fired from init
#Will give each country one idea per outlook which country they border
#Effect is stronger from majors

country_event = {
	id = neighbor_drift.1
	
	hidden = yes
	is_triggered_only = yes
	
	immediate = {
	
		#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
		
		### Boost to ruling parties ###
		if = {
		  limit = {
			 has_government = fascism
				is_major = no
		  }
		  add_ideas = ruling_party_salafist
		}
		if = {
		  limit = {
				is_major = yes
			 has_government = fascism
				
		  }
		  add_ideas = major_ruling_party_salafist
		}
		if = {
		  limit = {
			 has_government = democratic
				is_major = no
		  }
		  add_ideas = ruling_party_western
		}
		if = {
		  limit = {
				is_major = yes
			 has_government = democratic
		  }
		  add_ideas = major_ruling_party_western
		}
		if = {
		  limit = {
			 has_government = communism
				is_major = no
		  }
		  add_ideas = ruling_party_emerging
		}
		if = {
		  limit = {
				is_major = yes
			 has_government = communism
		  }
		  add_ideas = major_ruling_party_emerging
		}
		if = {
		  limit = {
				has_government = neutrality
				is_major = no
		  }
		  add_ideas = ruling_party_non_alligned
		}
		if = {
		  limit = {
				is_major = yes
			 has_government = neutrality
		  }
		  add_ideas = major_ruling_party_non_alligned
		}
		if = {
		  limit = {
			 has_government = nationalist
				is_major = no
		  }
		  add_ideas = ruling_party_nationalist
		}
		if = {
		  limit = {
				is_major = yes
			 has_government = nationalist
		  }
		  add_ideas = major_ruling_party_nationalist
		}
	}
	
	option = {
	log = "[GetDateText]: [This.GetName]: neighbor_drift.1 completed"
	}
}

#Economic drift flags

country_event = {
	id = neighbor_drift.2
	
	hidden = yes
	is_triggered_only = yes
	
	immediate = {
	
		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
		}
		
	}
	
	option = {
		log = "[GetDateText]: [This.GetName]: neighbor_drift.2 completed"
	}
}