﻿je_south_american_national_identity_emergence = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"

	group = je_group_internal_affairs

	is_shown_when_inactive = {
		capital = {
			state_is_in_south_america = yes
		}
		any_primary_culture = {
			NOR = { 
				cu:central_american = this 
				cu:caribeno = this
			}
			has_discrimination_trait = hispanophone
		}
		hidden_trigger = {
			NOT = { has_variable = completed_culture_genesis }
		}
		hidden_trigger = {
			NOR = {
				c:GCO ?= this
				c:PBC ?= this
				c:FND ?= this
				c:PLT ?= this
			}
		}
		is_revolutionary = no
	}

	possible = {
		has_technology_researched = nationalism
		hidden_trigger = {
			NOT = { has_variable = completed_culture_genesis }
		}
	}

	immediate = {
		set_national_identity_vars = yes
		set_variable = { name = national_identity_progress_var value = 0 }
		calculate_national_identity_progress = yes
		if = {
			limit = {
				c:ARG ?= this
			}
			cu:platinean = {
				save_scope_as = old_national_culture
			}
			cu:argentine = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:PEU ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:peruvian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:NPU ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:peruvian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:SPU ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:peruvian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:BOL ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:bolivian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:ECU ?= this
			}
			cu:north_andean = {
				save_scope_as = old_national_culture
			}
			cu:ecuadorian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:CHL ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:chilean = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:VNZ ?= this
			}
			cu:north_andean = {
				save_scope_as = old_national_culture
			}
			cu:venezuelan = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:URU ?= this
			}
			cu:platinean = {
				save_scope_as = old_national_culture
			}
			cu:uruguayan = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:PRG ?= this
			}
			cu:platinean = {
				save_scope_as = old_national_culture
			}
			cu:paraguayan = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:CLM ?= this
			}
			cu:north_andean = {
				save_scope_as = old_national_culture
			}
			cu:colombian = {
				save_scope_as = new_national_culture
			}
		}
		trigger_event = { id = culture_south_america.4 popup = yes }
	}

	on_weekly_pulse = {
		effect = {
			calculate_national_identity_progress = yes
		}
	}

	on_monthly_pulse = {
		effect = {
			add_national_identity_progress = yes
		}
	}

	complete = {
		scope:journal_entry = {
			is_goal_complete = yes
		}
	}

	on_complete = {
		clear_national_identity_vars = yes
		trigger_event = {
			id = culture_south_america.1 popup = yes
		}
		show_as_tooltip = {
			if = {
				limit = {
					c:ARG ?= this
				}
				add_primary_culture = cu:argentine
				remove_primary_culture = cu:platinean
			}
			if = {
				limit = {
					c:PEU ?= this
				}
				add_primary_culture = cu:peruvian
				remove_primary_culture = cu:south_andean
			}
			if = {
				limit = {
					c:NPU ?= this
				}
				add_primary_culture = cu:peruvian
				remove_primary_culture = cu:south_andean
			}
			if = {
				limit = {
					c:SPU ?= this
				}
				add_primary_culture = cu:peruvian
				remove_primary_culture = cu:south_andean
			}
			if = {
				limit = {
					c:BOL ?= this
				}
				add_primary_culture = cu:bolivian
				remove_primary_culture = cu:south_andean
			}
			if = {
				limit = {
					c:ECU ?= this
				}
				add_primary_culture = cu:ecuadorian
				remove_primary_culture = cu:north_andean
			}
			if = {
				limit = {
					c:CHL ?= this
				}
				add_primary_culture = cu:chilean
				remove_primary_culture = cu:south_andean
			}
			if = {
				limit = {
					c:VNZ ?= this
				}
				add_primary_culture = cu:venezuelan
				remove_primary_culture = cu:north_andean
			}
			if = {
				limit = {
					c:URU ?= this
				}
				add_primary_culture = cu:uruguayan
				remove_primary_culture = cu:platinean
			}
			if = {
				limit = {
					c:PRG ?= this
				}
				add_primary_culture = cu:paraguayan
				remove_primary_culture = cu:platinean
			}
			if = {
				limit = {
					c:CLM ?= this
				}
				add_primary_culture = cu:colombian
				remove_primary_culture = cu:north_andean
			}
		}
		hidden_effect = {
			set_variable = completed_culture_genesis
		}
	}

	fail = {
		custom_tooltip = {
			text = completed_pan_national_project_tt
			OR = {
				c:GCO ?= this
				c:FND ?= this
				c:PBC ?= this
				c:PLT ?= this
			}
		}
	}

	on_fail = {
		hidden_effect = {
			set_variable = completed_culture_genesis
		}
	}

	current_value = {
		value = root.var:national_identity_progress_var
	}

	goal_add_value = {
		add = 100
	}

	weight = 100

	progressbar = yes

	should_be_pinned_by_default = yes
}


je_south_american_national_identity = {
	icon = "gfx/interface/icons/event_icons/event_map.dds"

	group = je_group_internal_affairs

	# Now activated by event

	modifiers_while_active = {
		modifier_assimilation_nnc
	}

	immediate = {
		if = {
			limit = {
				c:ARG ?= this
			}
			cu:platinean = {
				save_scope_as = old_national_culture
			}
			cu:argentine = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:PEU ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:peruvian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:NPU ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:peruvian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:SPU ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:peruvian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:BOL ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:bolivian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:ECU ?= this
			}
			cu:north_andean = {
				save_scope_as = old_national_culture
			}
			cu:ecuadorian = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:CHL ?= this
			}
			cu:south_andean = {
				save_scope_as = old_national_culture
			}
			cu:chilean = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:VNZ ?= this
			}
			cu:north_andean = {
				save_scope_as = old_national_culture
			}
			cu:venezuelan = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:URU ?= this
			}
			cu:platinean = {
				save_scope_as = old_national_culture
			}
			cu:uruguayan = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:PRG ?= this
			}
			cu:platinean = {
				save_scope_as = old_national_culture
			}
			cu:paraguayan = {
				save_scope_as = new_national_culture
			}
		}
		if = {
			limit = {
				c:CLM ?= this
			}
			cu:north_andean = {
				save_scope_as = old_national_culture
			}
			cu:colombian = {
				save_scope_as = new_national_culture
			}
		}
	}

	complete = {
		NOR = {
			trigger_if = {
				limit = {
					OR = {
						c:ARG ?= this
						c:URU ?= this
						c:PRG ?= this
					}
				}
				any_scope_state = {
					state_region = {
						is_homeland = cu:platinean
					}
				}
			}
			trigger_if = {
				limit = {
					OR = {
						c:PEU ?= this
						c:NPU ?= this
						c:SPU ?= this
						c:BOL ?= this
						c:CHL ?= this
					}
				}
				any_scope_state = {
					state_region = {
						is_homeland = cu:south_andean
					}
				}
			}
			trigger_if = {
				limit = {
					OR = {
						c:ECU ?= this
						c:VNZ ?= this
						c:CLM ?= this
					}
				}
				any_scope_state = {
					state_region = {
						is_homeland = cu:north_andean
					}
				}
			}
		}
	}

	on_complete = {
		trigger_event = {
			id = culture_south_america.3
		}
		add_loyalists = {
			value = large_radicals
			culture = scope:new_national_culture
		}
	}

	scripted_button = je_south_american_national_identity_integrate_a_state

	weight = 100

	should_be_pinned_by_default = yes
}
