namespace = dvg_spain

# War of Independence
dvg_spain.1 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.1.t
	desc = dvg_spain.1.d
	flavor = dvg_spain.1.f
	
	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
		set_variable = {
			name = dvg_castillian_tensions_var
			value = 0
		}
		add_journal_entry = {
			type = je_castillian_tensions
		}
		add_journal_entry = {
			type = je_keep_castillian_tensions_low
		}
	}
	
	# Vive!
	option = {
		name = dvg_spain.1.a
		default_option = yes
		add_journal_entry = {
			type = je_caladeran_war_of_independence_spain
		}
		add_radicals = {
			value = 0.1
		}
		ai_chance = {
			base = 1
		}
	}
}

# The Revolt is Quashed
dvg_spain.2 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.2.t
	desc = dvg_spain.2.d
	flavor = dvg_spain.2.f
	
	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	
	# Viceroy time
	option = {
		name = dvg_spain.2.a
		default_option = yes
		add_loyalists = {
			value = 0.4
		}
		add_journal_entry = {
			type = je_reconquer_new_spain
		}
		add_journal_entry = {
			type = je_army_reform_spain
		}
		trigger_event = { id = dvg_spain.16 days = 365 }
		ai_chance = {
			base = 1
		}
	}
}

# Oof we lost
dvg_spain.3 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.3.t
	desc = dvg_spain.3.d
	flavor = dvg_spain.3.f
	
	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3
	
	trigger = {
	}
	immediate = {
		save_scope_as = spain_scope
	}
	# No Viceroy Path 
	option = {
		name = dvg_spain.3.a
		default_option = yes
		add_radicals = {
			value = 0.1
		}
		add_journal_entry = {
			type = je_rebuild_spain
		}
		add_journal_entry = {
			type = je_army_reform_spain
		}
		c:SPA = {
			remove_diplomatic_pact = {
				country = c:VIJ
				type = protectorate
			}
		}
		add_modifier = {
			name = dvg_fallen_kingdom
		}
		ai_chance = {
			base = 1
		}
	}
}
#make an event for VIJ later once india is reworked!>!>!>

# Reconquered New Spain note that unless something weird af happens, ai spain shouldn't really be doing this path
dvg_spain.4 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.4.t
	desc = dvg_spain.4.d
	flavor = dvg_spain.4.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	
	# biiiig spain
	option = {
		name = dvg_spain.4.a
		default_option = yes
		add_loyalists = {
			value = 0.25
		}
#		add_journal_entry = {
#			type = je_spanish_china
#		}
		add_journal_entry = {
			type = je_spanish_india
		}
		add_journal_entry = {
			type = je_spanish_africa
		}
		add_modifier = {
			name = dvg_giant_big_spain
		}
		ai_chance = {
			base = 1
		}
	}
}

# A Rebuilt Spain!
dvg_spain.5 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.5.t
	desc = dvg_spain.5.d
	flavor = dvg_spain.5.f
	
	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	
	# We must work on our remaining colonies
	option = {
		name = dvg_spain.5.a
		default_option = yes
		add_loyalists = {
			value = 0.3
		}
		add_journal_entry = {
			type = je_a_new_empire_in_an_old_world
		}
		add_journal_entry = {
			type = je_spanish_india
		}
		add_journal_entry = {
			type = je_spanish_africa
		}
		ai_chance = {
			base = 1
		}
	}
	
#	# Iberia
#	option = {
#		name = dvg_spain.5.b
#		default_option = yes
#		add_loyalists = {
#			value = 0.3
#		}
#		add_journal_entry = {
#			type = je_a_new_empire_in_an_old_world
#		}
#		set_variable = dvg_spain_iberia
#		ai_chance = {
#			base = 0
#		}
#	}
	
}

# A Spanish Revolution
dvg_spain.6 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.6.t
	desc = dvg_spain.6.d
	flavor = dvg_spain.6.f

	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	
	# For the republic!
	option = {
		name = dvg_spain.6.a
		default_option = yes
		add_loyalists = {
			value = 0.4
		}
		add_modifier = {
			name = dvg_overthrown_kingdom
		}
		add_journal_entry = {
			type = je_spanish_india
		}
		add_journal_entry = {
			type = je_spanish_africa
		}
		remove_modifier = dvg_fallen_kingdom
		ig:ig_landowners = {
			remove_ideology = ideology_patriarchal
			add_ideology = ideology_republican_paternalistic
		}
		hidden_effect = {
			remove_modifier = dvg_army_reform_spain
			if = {
				limit = {
					NOT = { has_law = law_type:law_presidential_republic }
				}
				activate_law = law_type:law_presidential_republic
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_national_militia }
				}
				activate_law = law_type:law_national_militia
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_census_voting }
				}
				activate_law = law_type:law_census_voting
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_right_of_assembly }
				}
				activate_law = law_type:law_right_of_assembly
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_per_capita_based_taxation }
				}
				activate_law = law_type:law_per_capita_based_taxation
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_freedom_of_conscience }
				}
				activate_law = law_type:law_freedom_of_conscience
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_public_schools }
				}
				activate_law = law_type:law_public_schools
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_elected_bureaucrats }
				}
				activate_law = law_type:law_elected_bureaucrats
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_serfdom_banned}
				}
				activate_law = law_type:law_serfdom_banned
			}
			if = {
				limit = {
					NOT = { has_law = law_type:law_interventionism}
				}
				activate_law = law_type:law_interventionism
			}
		}
	}
}

# Reformed spanish army
dvg_spain.8 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.8.t
	desc = dvg_spain.8.d
	flavor = dvg_spain.8.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	
	# army reformed
	option = {
		name = dvg_spain.8.a
		default_option = yes
		add_modifier = {
			name = dvg_army_reform_spain
		}
		ai_chance = {
			base = 1
		}
	}
}

# Angered Spanish Army!
dvg_spain.9 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.9.t
	desc = dvg_spain.9.d
	flavor = dvg_spain.9.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
	}
	
	# army angered
	option = {
		name = dvg_spain.9.a
		default_option = yes
		custom_tooltip = {
			text = dvg_raise_by_two_tt
			change_variable = {
				name = dvg_castillian_tensions_var
				add = 2
			}
		}
		ai_chance = {
			base = 1
		}
	}
}

# The Moroccan Revolt!
dvg_spain.10 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.10.t
	desc = dvg_spain.10.d
	flavor = dvg_spain.10.f
	
	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
		c:MOR = {
			save_scope_as = dvg_morocco_scope
		}
	}
	
	#This means war!
	option = {
		name = dvg_spain.10.a
		default_option = yes
		create_diplomatic_play = {
			target_country = scope:dvg_morocco_scope
			war = yes
			type = dp_annex_war
			
			add_war_goal = {
				holder = c:MOR
				type = conquer_state
				target_state = s:STATE_AL_RIF.region_state:SPA
			}
			add_war_goal = {
				holder = c:MOR
				type = conquer_state
				target_state = s:STATE_MARRAKECH.region_state:SPA
			}
				add_war_goal = {
				holder = c:MOR
				type = conquer_state
				target_state = s:STATE_INNER_MOROCCO.region_state:SPA
			}
		}
		hidden_effect = {
			c:SPA = {
				remove_diplomatic_pact = {
					country = c:MOR
					type = puppet
				}
			}
		}
		add_radicals = {
			value = 0.5
			culture = cu:maghrebi
		}
		c:MOR = {
			trigger_event = { id = dvg_morocco.5 }
		}

		ai_chance = {
			base = 0.99
		}
	}
	
	#We have to accept this for now
	option = {
		name = dvg_spain.10.b
		c:MOR = {
			trigger_event = { id = dvg_morocco.6 }
		}
		hidden_effect = {
			c:SPA = {
				remove_diplomatic_pact = {
					country = c:MOR
					type = puppet
				}
			}
		}
		ai_chance = {
			base = 0.01
		}
	}
}

#A Spanish East India Company, Companhia Real da Índia Espanhola
dvg_spain.11 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.11.t
	desc = dvg_spain.11.d
	flavor = dvg_spain.11.f

	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	
	# Yes, give them the go ahead.
	option = {
		name = dvg_spain.11.a
		default_option = yes
		add_treasury = 2000000
		create_country = {
			tag = CC2
			origin = this
			state = s:STATE_PEGU.region_state:SPA
			state = s:STATE_BURMA.region_state:SPA
			state = s:STATE_SHAN_STATES.region_state:SPA
			state = s:STATE_KACHIN.region_state:SPA
			state = s:STATE_ASSAM.region_state:SPA
			state = s:STATE_NORTH_BENGAL.region_state:SPA
			state = s:STATE_SOUTH_BENGAL.region_state:SPA
		}
		hidden_effect = {
			c:SPA = {
				create_diplomatic_pact = {
					country = c:CC2
					type = dominion
				}
			}
		}
		ai_chance = {
			base = 1
		}

	}
	# We will oversee it directly
	option = {
		name = dvg_spain.11.b
		ai_chance = {
			base = 0
		}
	}
}

#End of Castillian Nationalism
dvg_spain.12 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.12.t
	desc = dvg_spain.12.d
	flavor = dvg_spain.12.f

	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {

		c:SPA = {
			random_scope_state = {
				limit = {
					state_region = s:STATE_CARTAGENA
				}
				save_scope_as = dvg_cartagena
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_GRANADA
				}
				save_scope_as = dvg_granada
			}
				random_scope_state = {
				limit = {
					state_region = s:STATE_ASTURIAS
				}
				save_scope_as = dvg_asturias
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_CASTILE
				}
				save_scope_as = dvg_castilee
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_BADAJOZ
				}
				save_scope_as = dvg_badajoz
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_TOLEDO
				}
				save_scope_as = dvg_toledo
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_ANDALUSIA
				}
				save_scope_as = dvg_andalusia
			}
		}
	}
	
	
	# Yes, give them the go ahead.
	option = {
		name = dvg_spain.12.a
		default_option = yes
		add_radicals = {
			value = 0.1
			culture = cu:spanish
		}
		custom_tooltip = {
			text = dvg_spain_end_castile_tt
			s:STATE_TOLEDO = { 
				remove_homeland = spanish
			}
			scope:dvg_toledo = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_CASTILE = { 
				remove_homeland = spanish
			}
			scope:dvg_castilee = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_ASTURIAS = {
				remove_homeland = spanish
			}
			scope:dvg_asturias = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_CARTAGENA = {
				remove_homeland = spanish
			}
			scope:dvg_cartagena = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_GRANADA = {
				remove_homeland = spanish
			}
			scope:dvg_granada = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_BADAJOZ = {
				remove_homeland = spanish
			}
			scope:dvg_badajoz = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_ANDALUSIA = {
				remove_homeland = spanish
			}
			scope:dvg_andalusia = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
		}
		ai_chance = {
			base = 1
		}
	}
}

# Castillians Rise up due to Tension
dvg_spain.13 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.13.t
	desc = dvg_spain.13.d
	flavor = dvg_spain.13.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
		create_country = {
			tag = CAS
			origin = this
			state = s:STATE_TOLEDO.region_state:SPA
			state = s:STATE_CASTILE.region_state:SPA
			state = s:STATE_ASTURIAS.region_state:SPA
			state = s:STATE_CARTAGENA.region_state:SPA
		}
		c:CAS = {
			save_scope_as = dvg_castile_scope
		}
	}
	
	# castile angered
	option = {
		name = dvg_spain.13.a
		default_option = yes
		create_diplomatic_play = {
			target_country = scope:dvg_castile_scope
			war = yes
			type = dp_annex_war
			
			add_war_goal = {
				holder = c:CAS
				type = conquer_state
				target_state = s:STATE_GRANADA.region_state:SPA
			}
		}
#		trigger_event = { id = dvg_spain.14 days = 180 } trigger galician revolt?
		hidden_effect = {
			set_variable = dvg_spain_castille
		}
		ai_chance = {
			base = 1
		}
	}
}

#End of Portu-Galician Nationalism
dvg_spain.14 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.14.t
	desc = dvg_spain.14.d
	flavor = dvg_spain.14.f

	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {

		c:SPA = {
			random_scope_state = {
				limit = {
					state_region = s:STATE_ESTREMADURA
				}
				save_scope_as = dvg_estremadura
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_BEIRA
				}
				save_scope_as = dvg_beira
			}
				random_scope_state = {
				limit = {
					state_region = s:STATE_ALENTEJO
				}
				save_scope_as = dvg_alentejo
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_GALICIA
				}
				save_scope_as = dvg_galicia
			}
		}
	}
	
	
	# Yes, give them the go ahead.
	option = {
		name = dvg_spain.14.a
		default_option = yes
		add_radicals = {
			value = 0.1
			culture = cu:spanish
		}
		custom_tooltip = {
			text = dvg_spain_end_galicia_tt
			s:STATE_ESTREMADURA = { 
				remove_homeland = galician
			}
			scope:dvg_estremadura = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_BEIRA = { 
				remove_homeland = galician
			}
			scope:dvg_beira = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_ALENTEJO = {
				remove_homeland = galician
			}
			scope:dvg_alentejo = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
			s:STATE_GALICIA = {
				remove_homeland = galician
			}
			scope:dvg_galicia = {
				add_modifier = {
					name = dvg_assimilate
					months = 60
				}
			}
		}
		ai_chance = {
			base = 1
		}
	}
}

# Castillian Tensions Resolved
dvg_spain.15 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.15.t
	desc = dvg_spain.15.d
	flavor = dvg_spain.15.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
	}
	
	# castile happied
	option = {
		name = dvg_spain.15.a
		default_option = yes
		hidden_effect = {
			set_variable = dvg_spain_castille
			set_variable = dvg_spain_galicia
			remove_variable = dvg_castillian_spanish
			remove_variable = dvg_castillian_crown_debate
			remove_variable = dvg_castillian_tensions
			remove_variable = dvg_mateo
		}
		ai_chance = {
			base = 1
		}
	}
}

# Trial of Martin Ballivian
dvg_spain.16 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.16.t
	desc = dvg_spain.16.d
	flavor = dvg_spain.16.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
	}
	
	# Inno
	option = {
		name = dvg_spain.16.a
		default_option = yes
		random_list = {
			40 = {
				trigger_event = { id = dvg_spain.17 days = 90 }
			}
			60 = {
				trigger_event = { id = dvg_spain.18 days = 90 }
			}
		}
		ai_chance = {
			base = 0.5
		}
	}
	
	# SUS
	option = {
		name = dvg_spain.16.b
		add_radicals = {
			value = 0.1
			culture = cu:spanish
		}
		ai_chance = {
			base = 0.5
		}
	}
}

# Martin Ballivian inspires castillian nationalists!
dvg_spain.17 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.17.t
	desc = dvg_spain.17.d
	flavor = dvg_spain.17.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
	}
	
	# dangit
	option = {
		name = dvg_spain.17.a
		default_option = yes
		custom_tooltip = {
			text = dvg_raise_by_one_tt
			change_variable = {
				name = dvg_castillian_tensions_var
				add = 1
			}
		}
		ai_chance = {
			base = 1
		}
	}
}

# Martin Ballivian calms down castillian nationalists!
dvg_spain.18 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.18.t
	desc = dvg_spain.18.d
	flavor = dvg_spain.18.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {
	}
	
	# nice
	option = {
		name = dvg_spain.18.a
		default_option = yes
		custom_tooltip = {
			text = dvg_lower_by_one_tt
			change_variable = {
				name = dvg_castillian_tensions_var
				add = -1
			}
		}
		add_loyalists = {
			value = 0.15
			culture = cu:spanish
		}
		ai_chance = {
			base = 1
		}
	}
}

# Dilemma, recognition of Castillian Spanish?
dvg_spain.19 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.19.t
	desc = dvg_spain.19.d
	flavor = dvg_spain.19.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
		c:SPA = ROOT
		c:SPA = {
			has_journal_entry = je_castillian_tensions
		}
		NOT = { has_variable = dvg_castillian_spanish }
	}
	
	immediate = {
	}
	
	# It is its own language
	option = {
		name = dvg_spain.19.a
		default_option = yes
		add_loyalists = {
			value = 0.15
			culture = cu:spanish
		}
		hidden_effect = {
			set_variable = dvg_castillian_spanish
		}
		ai_chance = {
			base = 0
		}
	}
	
	# It is a dialect
	option = {
		name = dvg_spain.19.b
		custom_tooltip = {
			text = dvg_raise_by_one_tt
			change_variable = {
				name = dvg_castillian_tensions_var
				add = 1
			}
		}
		add_radicals = {
			value = 0.15
			culture = cu:spanish
		}
		custom_tooltip = {
			text = dvg_spain_end_castillian_tt
			set_variable = dvg_spain_end_castillian_mega
		}
		hidden_effect = {
			set_variable = dvg_castillian_spanish
		}
		ai_chance = {
			base = 1
		}
	}
}

#End of Castillian Nationalism mega
dvg_spain.20 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.12.t
	desc = dvg_spain.12.d
	flavor = dvg_spain.12.f

	event_image = {
		video = "gfx/event_pictures/southamerica_war_civilians.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/war_civilians"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
	}
	
	immediate = {

		c:SPA = {
			random_scope_state = {
				limit = {
					state_region = s:STATE_CARTAGENA
				}
				save_scope_as = dvg_cartagena
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_GRANADA
				}
				save_scope_as = dvg_granada
			}
				random_scope_state = {
				limit = {
					state_region = s:STATE_ASTURIAS
				}
				save_scope_as = dvg_asturias
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_CASTILE
				}
				save_scope_as = dvg_castilee
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_BADAJOZ
				}
				save_scope_as = dvg_badajoz
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_TOLEDO
				}
				save_scope_as = dvg_toledo
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_ANDALUSIA
				}
				save_scope_as = dvg_andalusia
			}
		}
	}
	
	
	# Yes, give them the go ahead.
	option = {
		name = dvg_spain.12.a
		default_option = yes
		add_radicals = {
			value = 0.1
			culture = cu:spanish
		}
		custom_tooltip = {
			text = dvg_spain_end_castile_tt
			s:STATE_TOLEDO = { 
				remove_homeland = spanish
			}
			scope:dvg_toledo = {
				add_modifier = {
					name = dvg_assimilate_mega
					months = 60
				}
			}
			s:STATE_CASTILE = { 
				remove_homeland = spanish
			}
			scope:dvg_castilee = {
				add_modifier = {
					name = dvg_assimilate_mega
					months = 60
				}
			}
			s:STATE_ASTURIAS = {
				remove_homeland = spanish
			}
			scope:dvg_asturias = {
				add_modifier = {
					name = dvg_assimilate_mega
					months = 60
				}
			}
			s:STATE_CARTAGENA = {
				remove_homeland = spanish
			}
			scope:dvg_cartagena = {
				add_modifier = {
					name = dvg_assimilate_mega
					months = 60
				}
			}
			s:STATE_GRANADA = {
				remove_homeland = spanish
			}
			scope:dvg_granada = {
				add_modifier = {
					name = dvg_assimilate_mega
					months = 60
				}
			}
			s:STATE_BADAJOZ = {
				remove_homeland = spanish
			}
			scope:dvg_badajoz = {
				add_modifier = {
					name = dvg_assimilate_mega
					months = 60
				}
			}
			s:STATE_ANDALUSIA = {
				remove_homeland = spanish
			}
			scope:dvg_andalusia = {
				add_modifier = {
					name = dvg_assimilate_mega
					months = 60
				}
			}
		}
		ai_chance = {
			base = 1
		}
	}
}

# Dilemma, status of the Crown of Castile
dvg_spain.21 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.21.t
	desc = dvg_spain.21.d
	flavor = dvg_spain.21.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
		c:SPA = ROOT
		c:SPA = {
			has_journal_entry = je_castillian_tensions
		}
		NOT = { has_variable = dvg_castillian_crown_debate }
	}
	
	immediate = {
		c:SPA = {
			random_scope_state = {
				limit = {
					state_region = s:STATE_CARTAGENA
				}
				save_scope_as = dvg_cartagena
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_GRANADA
				}
				save_scope_as = dvg_granada
			}
				random_scope_state = {
				limit = {
					state_region = s:STATE_ASTURIAS
				}
				save_scope_as = dvg_asturias
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_CASTILE
				}
				save_scope_as = dvg_castilee
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_BADAJOZ
				}
				save_scope_as = dvg_badajoz
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_TOLEDO
				}
				save_scope_as = dvg_toledo
			}
			random_scope_state = {
				limit = {
					state_region = s:STATE_ANDALUSIA
				}
				save_scope_as = dvg_andalusia
			}
		}
	}
	
	# It is equal
	option = {
		name = dvg_spain.21.a
		default_option = yes
		custom_tooltip = {
			text = dvg_lower_by_one_tt
			change_variable = {
				name = dvg_castillian_tensions_var
				add = -1
			}
		}
		add_loyalists = {
			value = 0.1
			culture = cu:spanish
		}
		add_radicals = {
			value = 0.25
			culture = cu:portuguese
		}
		hidden_effect = {
			set_variable = dvg_castillian_crown_debate
		}
		custom_tooltip = {
			text = dvg_spain_equal_castile_tt
			scope:dvg_toledo = {
				add_modifier = {
					name = dvg_bad_taxation
					months = 60
				}
			}
			scope:dvg_castilee = {
				add_modifier = {
					name = dvg_bad_taxation
					months = 60
				}
			}
			scope:dvg_asturias = {
				add_modifier = {
					name = dvg_bad_taxation
					months = 60
				}
			}
			scope:dvg_cartagena = {
				add_modifier = {
					name = dvg_bad_taxation
					months = 60
				}
			}
			scope:dvg_granada = {
				add_modifier = {
					name = dvg_bad_taxation
					months = 60
				}
			}
			scope:dvg_badajoz = {
				add_modifier = {
					name = dvg_bad_taxation
					months = 60
				}
			}
			scope:dvg_andalusia = {
				add_modifier = {
					name = dvg_bad_taxation
					months = 60
				}
			}
		}
		ai_chance = {
			base = 0.5
		}
	}
	
	# It is of course, lower
	option = {
		name = dvg_spain.21.b
		add_radicals = {
			value = 0.1
			culture = cu:spanish
		}
		add_loyalists = {
			value = 0.1
			culture = cu:portuguese
		}
		custom_tooltip = {
			text = dvg_raise_by_one_tt
			change_variable = {
				name = dvg_castillian_tensions_var
				add = 1
			}
		}
		hidden_effect = {
			set_variable = dvg_castillian_crown_debate
		}
		ai_chance = {
			base = 0.5
		}
	}
}

# Generic Tensions
dvg_spain.22 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.22.t
	desc = dvg_spain.22.d
	flavor = dvg_spain.22.f

	event_image = {
		video = "gfx/event_pictures/europenorthamerica_springtime_of_nations.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
		c:SPA = ROOT
		c:SPA = {
			has_journal_entry = je_castillian_tensions
		}
		NOT = { has_variable = dvg_castillian_tensions }
	}
	
	immediate = {
	}
	
	# Spain
	option = {
		name = dvg_spain.22.a
		default_option = yes
		add_loyalists = {
			value = 0.1
			culture = cu:portuguese
		}
		add_radicals = {
			value = 0.25
			culture = cu:spanish
		}
		hidden_effect = {
			set_variable = dvg_castillian_tensions
		}
		ai_chance = {
			base = 0.5
		}
	}
	
	# Castile
	option = {
		name = dvg_spain.22.b
		add_radicals = {
			value = 0.25
			culture = cu:portuguese
		}
		hidden_effect = {
			set_variable = dvg_castillian_tensions
		}
		ai_chance = {
			base = 0.5
		}
	}
}

# Mateo
dvg_spain.23 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.23.t
	desc = dvg_spain.23.d
	flavor = dvg_spain.23.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
		c:SPA = ROOT
		c:SPA = {
			has_journal_entry = je_castillian_tensions
		}
		NOT = { has_variable = dvg_mateo }
	}
	
	immediate = {
	}
	
	# Unfortunate
	option = {
		name = dvg_spain.23.a
		default_option = yes
		hidden_effect = {
			set_variable = dvg_mateo
		}
		add_radicals = {
			value = 0.25
			culture = cu:spanish
		}
		custom_tooltip = {
			text = dvg_raise_by_one_tt
			change_variable = {
				name = dvg_castillian_tensions_var
				add = 1
			}
		}
		ai_chance = {
			base = 0.5
		}
	}
}

# Other Uprising
dvg_spain.24 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.24.t
	desc = dvg_spain.24.d
	flavor = dvg_spain.24.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
		c:SPA = ROOT
		c:SPA = {
			has_journal_entry = je_castillian_tensions
			NOT = {
				OR = {
					owns_entire_state_region = STATE_TOLEDO
					owns_entire_state_region = STATE_CASTILE
					owns_entire_state_region = STATE_ASTURIAS
					owns_entire_state_region = STATE_CARTAGENA
					owns_entire_state_region = STATE_GRANADA
					owns_entire_state_region = STATE_BADAJOZ
					owns_entire_state_region = STATE_ANDALUSIA
				}
			}
		}
	}
	
	immediate = {
	}
	
	# castile oofed
	option = {
		name = dvg_spain.24.a
		default_option = yes
		hidden_effect = {
			set_variable = dvg_spain_castille
			set_variable = dvg_spain_galicia
			remove_variable = dvg_castillian_spanish
			remove_variable = dvg_castillian_crown_debate
			remove_variable = dvg_castillian_tensions
			remove_variable = dvg_mateo
		}
		ai_chance = {
			base = 1
		}
	}
}

# Change to viceroyalty
dvg_spain.25 = {
	type = country_event
	placement = ROOT

	title = dvg_spain.25.t
	desc = dvg_spain.25.d
	flavor = dvg_spain.25.f

	event_image = {
		video = "gfx/event_pictures/southamerica_aristocrats.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/southamerica/aristocrats"

	icon = "gfx/interface/icons/event_icons/event_fire.dds"

	duration = 3

	trigger = {
		OR = {
			AND = {
				exists = c:MEX
				c:MEX = ROOT
			}
			AND = {
				exists = c:UCA
				c:UCA = ROOT
			}
			AND = {
				exists = c:GCO
				c:GCO = ROOT
			}
			AND = {
				exists = c:GRA
				c:GRA = ROOT
			}
			AND = {
				exists = c:QUI
				c:QUI = ROOT
			}
			AND = {
				exists = c:LUS
				c:LUS = ROOT
			}
		}
		is_subject_of = c:SPA
		NOT = { 
			has_law = law_type:law_monarchy 
		}
	}
	
	immediate = {
	}
	
	# we oofed
	option = {
		name = dvg_spain.25.a
		default_option = yes
		hidden_effect = {
			if = {
				limit = {
					NOT = { has_law = law_type:law_monarchy }
				}
				activate_law = law_type:law_monarchy
			}
		}
		ai_chance = {
			base = 1
		}
	}
}