﻿add_namespace = spain
add_namespace = calc_spain_debt
add_namespace = spain_caribbean
add_namespace = SPR_bankruptcy_events
add_namespace = spanishflavour

# Not organized events, Write events here if not sure where to put it




#########################################
#										#
#				Focus Tree				#
#										#
#########################################

country_event = { #New heir born, Alfonso
	id = spain.1
	title = spain.1.t
	desc = spain.1.d
	
	is_triggered_only = yes

	option = {
		name = spain.1.a
		ai_chance = { factor = 100 }
		#swap_ideas = {
		#	remove_idea = no_heir
		#	add_idea = has_heir
		#}
	}
}

country_event = { #New Quinta
	id = spain.2
	title = spain.2.t
	desc = spain.2.d
	
	is_triggered_only = yes
	
	option = {
		name = spain.2.a
		ai_chance = { factor = 0 }
		add_manpower = 50000
		804 = {
			add_manpower = -50000
		}
		add_equipment_to_stockpile = {
			type = infantry_equipment_rifle_1
			amount = 5000
			producer = SPR
		}
		add_equipment_to_stockpile = {
			type = uniform_equipment_0
			amount = 5000
			producer = SPR
		}
		add_ideas = SPR_rigged_quinta
	}
	
	option = {
		name = spain.2.b
		ai_chance = { factor = 100 }
		add_manpower = 50000
		804 = {
			add_manpower = -50000
		}
		add_equipment_to_stockpile = {
			type = infantry_equipment_rifle_1
			amount = 2500
			producer = SPR
		}
		add_equipment_to_stockpile = {
			type = uniform_equipment_0
			amount = 2500
			producer = SPR
		}
		add_ideas = SPR_fair_quinta
	}
	
	option = {
		name = spain.2.c
		ai_chance = { factor = 0 }
		add_manpower = 50000
		804 = {
			add_manpower = -50000
		}
	}
	
}

country_event = { #Queen's coup 1858
	id = spain.3
	title = spain.3.t
	desc = spain.3.d
	
	is_triggered_only = yes

	option = {
		name = spain.3.a
		ai_chance = { factor = 100 }
		set_politics = {
			ruling_party = centrism
		}
		add_popularity = {
			ideology = centrism
			popularity = 0.15
		}
		complete_national_focus = SPR_the_queen
	}
	
	option = {
		name = spain.3.b
		ai_chance = { factor = 0 }
		start_civil_war = {
			ruling_party = traditional_conservatism
			ideology = centrism
			size = 0.4
			capital = 169
			states = { 
				168 169 170 173 174 175 1270
			}
			keep_unit_leaders = {
			}
		}
		#swap_ideas = {
		#	remove_idea = has_heir
		#	add_idea = no_heir
		#}
		complete_national_focus = SPR_the_president
		random_other_country = {
			limit = {
				original_tag = SPR
				has_government = centrism
			}
			complete_national_focus = SPR_the_queen
		}
	}
}

country_event = { #Guinea selling
	id = spain.4
	title = spain.4.t
	desc = spain.4.d
	
	is_triggered_only = yes

	option = { 
		name = spain.4.a
		ai_chance = { factor = 100 }
		complete_national_focus = SPR_keep_it
	}
	
	option = {
		name = spain.4.b
		trigger = { country_exists = ENG }
		ai_chance = { factor = 0 }
		ENG = {
			country_event = {
				id = britain.13
				days = 20
			}
		}
	}
}

country_event = { #Brits buy it
	id = spain.5
	title = spain.5.t
	desc = spain.5.d
	
	is_triggered_only = yes

	option = {
		name = spain.5.a
		ai_chance = { factor = 100 }
		complete_national_focus = SPR_sell_it
	}
}

country_event = { #Brits don't buy it
	id = spain.6
	title = spain.6.t
	desc = spain.6.d
	
	is_triggered_only = yes

	option = {
		name = spain.6.a
		ai_chance = { factor = 100 }
		complete_national_focus = SPR_keep_it
	}
}

country_event = { #Mexico stops paying announce
	id = spain.7
	title = spain.7.t
	desc = spain.7.d
	
	is_triggered_only = yes

	option = {
		name = spain.7.a
		ai_chance = { factor = 100 }
	}
}

country_event = { #Madrid-Zaragoza Railway Line Profitable (further debt reduction by 2)
	id = SPR_bankruptcy_events.5
	title = SPR_bankruptcy_events.5.t
	desc = SPR_bankruptcy_events.5.d 
	
	is_triggered_only = yes
	
	option = {
		name = SPR_bankruptcy_events.5.a
		add_political_power = 50
		set_temp_variable = { money_to_gain = -0.5 }
		add_money_with_tooltip_effect = yes 
	}
}

country_event = { #Valladolid-Burgos Railway Line Profitable (further debt reduction by 1)
	id = SPR_bankruptcy_events.6
	title = SPR_bankruptcy_events.6.t
	desc = SPR_bankruptcy_events.6.d 
	
	is_triggered_only = yes
	
	option = {
		name = SPR_bankruptcy_events.6.a
		add_political_power = 40
		set_temp_variable = { money_to_gain = -0.5 }
		add_money_with_tooltip_effect = yes	 
	}
}

country_event = { #Nationalized Sugar in Cuba
	id = spain_caribbean.1
	title = spain_caribbean.1.t
	desc = spain_caribbean.1.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.1.a
		ai_chance = { factor = 50 }
		hidden_effect = {
			set_country_flag = SPR_invest_in_sugar_trade_nationalized_flag
		}
	}

	option = {
		name = spain_caribbean.1.b
		ai_chance = { factor = 50 }
		hidden_effect = {
			
		}
	}
}
country_event = { #Nationalized Tobacco in Cuba
	id = spain_caribbean.2
	title = spain_caribbean.2.t
	desc = spain_caribbean.2.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.2.a
		ai_chance = { factor = 50 }
		hidden_effect = {
			set_country_flag = SPR_expand_tobacco_plantations_nationalized_flag
		}
	}

	option = {
		name = spain_caribbean.2.b
		ai_chance = { factor = 50 }
		hidden_effect = {
			
		}
	}
}
country_event = { #Nationalized cattle in PR
	id = spain_caribbean.3
	title = spain_caribbean.3.t
	desc = spain_caribbean.3.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.3.a
		ai_chance = { factor = 50 }
		hidden_effect = {
			set_country_flag = SPR_increase_cattle_land_nationalized_flag
		}
	}

	option = {
		name = spain_caribbean.3.b
		ai_chance = { factor = 50 }
		hidden_effect = {
			
		}
	}
}
country_event = { #Nationalized Sugar in Hispaniola
	id = spain_caribbean.4
	title = spain_caribbean.4.t
	desc = spain_caribbean.4.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.4.a
		ai_chance = { factor = 50 }
		hidden_effect = {
			set_country_flag = SPR_invest_in_dominican_cattle_nationalized_flag
		}
	}

	option = {
		name = spain_caribbean.4.b
		ai_chance = { factor = 50 }
		hidden_effect = {
			
		}
	}
}

country_event = {	#Purto Rico rebells
    id = spain_caribbean.5
	title = spain_caribbean.5.t
	desc = spain_caribbean.5.d 
	picture = GFX_report_event_prt_lares 
	
	trigger = {
		AND = {
			TAG = SPR
			#date > 1868.9.23
			has_war = yes
			NOT = { owns_state = 1318 }
			owns_state = 686
		}	
	}
	is_triggered_only = yes
	fire_only_once = yes
	
	option = {
		name = spain_caribbean.5.a
		add_war_support = 0.015	
		add_state_claim = 686
		hidden_effect = {
			PRT = {
				transfer_state = 686
				set_country_flag = PRT_Lares
				add_ideas = PRT_disorganized_rebellion
				load_oob = PRT_1868_LARES
			}
			load_oob = SPR_1868_LARES	
		}
		PRT = { 
			declare_war_on = {
				target = SPR
				type = annex_everything
			}
		}
	}
}

country_event = { #we win
    id = spain_caribbean.6
	title = spain_caribbean.6.t
	desc = spain_caribbean.6.d 
	
	trigger = {
		AND = {
			TAG = SPR
			has_country_flag = SPR_Lares_end
		}	
	}
	
	is_triggered_only = yes
	fire_only_once = yes
	
	option = {
		name = spain_caribbean.6.a
		add_political_power = 20 
		hidden_effect = {
			clr_country_flag = SPR_Lares_end
			set_country_flag  = SPR_lares_focus
		}	
	}
}

country_event = { #Not intervened morals in Hispaniola
	id = spain_caribbean.7
	title = spain_caribbean.7.t
	desc = spain_caribbean.7.d
	
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.7.a
		ai_chance = { factor = 100 }
		#Heavily Tax Non-Catholics
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 319 = { clr_state_flag = spain_hispaniola_catholic_morals_flag } }
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 1318 = { clr_state_flag = spain_hispaniola_catholic_morals_flag } }
		}
	}

	option = {
		name = spain_caribbean.7.b
		ai_chance = { factor = 0 }
		#Discriminate Non-Catholics
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 319 = { clr_state_flag = spain_hispaniola_catholic_morals_flag } }
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 1318 = { clr_state_flag = spain_hispaniola_catholic_morals_flag } }
		}
	}
}

country_event = { #Intervened morals in Hispaniola
	id = spain_caribbean.8
	title = spain_caribbean.8.t
	desc = spain_caribbean.8.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	immediate = { hidden_effect = { ROOT = { set_variable = { var = spain_dominican_decline_intervention value = FROM.id } } } }
	
	option = {
		name = spain_caribbean.8.a
		hidden_effect = {
			random_list = {
				25 = {
					country_event = { id = spain_caribbean.10 days = 7 }
				}
				75 = {
					country_event = { id = spain_caribbean.11 days = 7 }
				}
			}
		}
	}
	option = {
		name = spain_caribbean.8.b
		hidden_effect = {
			country_event = { id = spain_caribbean.9 days = 7 }
		}
		add_command_power = 50
	}
}

country_event = { #Timeout Outcome
	id = spain_caribbean.9
	title = spain_caribbean.9.t
	desc = spain_caribbean.9.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.9.a
		
		if = {
			limit = { has_variable = spain_dominican_decline_intervention }
			hidden_effect = {
				random_list = {
					50 = {
						country_event = { id = spain_caribbean.10 days = 7 }
					}
					50 = {
						clear_variable = spain_dominican_decline_intervention
					}
				}
			}
		}
	}
}

country_event = { #Bad Outcome
	id = spain_caribbean.10
	title = spain_caribbean.10.t
	desc = spain_caribbean.10.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.10.a
		hidden_effect = { clear_variable = spain_dominican_decline_intervention }
	}
}

country_event = { #Good Outcome
	id = spain_caribbean.11
	title = spain_caribbean.11.t
	desc = spain_caribbean.11.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.11.a
		hidden_effect = { clear_variable = spain_dominican_decline_intervention }
	}
}


country_event = { #Protestants in Hispaniola
	id = spain_caribbean.12
	title = spain_caribbean.12.t
	desc = spain_caribbean.12.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.12.a
		ai_chance = { factor = 0 }
		#Expel Protestants
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 319 = { clr_state_flag = spain_hispaniola_persecute_protestants_flag } }
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 1318 = { clr_state_flag = spain_hispaniola_persecute_protestants_flag } }
		}
	}

	option = {
		name = spain_caribbean.12.b
		ai_chance = { factor = 100 }
		#Reeducate Protestants
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 319 = { clr_state_flag = spain_hispaniola_persecute_protestants_flag } }
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 1318 = { clr_state_flag = spain_hispaniola_persecute_protestants_flag } }
		}
	}
	
	option = {
		name = spain_caribbean.12.c
		ai_chance = { factor = 0 }
		#Discriminate Protestants
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 319 = { clr_state_flag = spain_hispaniola_persecute_protestants_flag } }
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 1318 = { clr_state_flag = spain_hispaniola_persecute_protestants_flag } }
		}
	}
}

country_event = { #Outcome
	id = spain_caribbean.13
	title = spain_caribbean.13.t
	desc = spain_caribbean.13.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.13.a 
	}
	
	option = {
		name = spain_caribbean.13.b 
	}
}


country_event = { #Not intervened Masonry in Hispaniola
	id = spain_caribbean.14
	title = spain_caribbean.14.t
	desc = spain_caribbean.14.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.14.a
		trigger = { NOT = { has_completed_focus = SPR_give_power_to_the_landowners } }
		ai_chance = { base = 75 }
		#Persecuted Masonry
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 319 = { clr_state_flag = spain_hispaniola_persecute_masonry_flag } }
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 1318 = { clr_state_flag = spain_hispaniola_persecute_masonry_flag } }
		}
		if = {
			limit = { 1318 = { OWNER = { is_subject_of = SPR } } }
			1318 = { OWNER = { country_event = { id = spain_caribbean.19 } } }
		}
	}
	
	option = {
		name = spain_caribbean.14.b
		ai_chance = { 
			base = 25
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		#Sanctioned Masonry
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 319 = { set_state_flag = spain_hispaniola_sanctioned_masonry_flag } }
			hidden_effect = { 319 = { clr_state_flag = spain_hispaniola_persecute_masonry_flag } }
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 1318 = { set_state_flag = spain_hispaniola_sanctioned_masonry_flag } }
			hidden_effect = { 1318 = { clr_state_flag = spain_hispaniola_persecute_masonry_flag } }
		}
		if = {
			limit = { 1318 = { OWNER = { is_subject_of = SPR } } }
			1318 = { OWNER = { country_event = { id = spain_caribbean.20 } } }
		}
	}
}

country_event = { #Intervened Masonry in Hispaniola
	id = spain_caribbean.15
	title = spain_caribbean.15.t
	desc = spain_caribbean.15.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	immediate = { hidden_effect = { ROOT = { set_variable = { var = spain_dominican_decline_intervention value = FROM.id } } } }
	
	option = {
		name = spain_caribbean.15.a
		trigger = { has_political_power > -0.01 }
		hidden_effect = {
			random_list = {
				25 = {
					country_event = { id = spain_caribbean.17 days = 7 }
				}
				75 = {
					country_event = { id = spain_caribbean.18 days = 7 }
				}
			}
		}
		add_political_power = -50
	}
	option = {
		name = spain_caribbean.15.b
		trigger = { has_political_power < 0 }
		hidden_effect = {
			country_event = { id = spain_caribbean.16 days = 7 }
		}

		add_command_power = 50
	}
	option = {
		name = spain_caribbean.15.c
		trigger = { has_political_power > -0.01 }
		hidden_effect = {
			country_event = { id = spain_caribbean.16 days = 7 }
		}

		add_command_power = 50
	}
}

country_event = { #Timeout Outcome
	id = spain_caribbean.16
	title = spain_caribbean.16.t
	desc = spain_caribbean.16.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.16.a
		if = {
			limit = { has_variable = spain_dominican_decline_intervention }
			hidden_effect = { clear_variable = spain_dominican_decline_intervention }
		}
	}
}

country_event = { #Bad Outcome
	id = spain_caribbean.17
	title = spain_caribbean.17.t
	desc = spain_caribbean.17.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.17.a
		hidden_effect = { clear_variable = spain_dominican_decline_intervention }
	}
}

country_event = { #Good Outcome
	id = spain_caribbean.18
	title = spain_caribbean.18.t
	desc = spain_caribbean.18.d
	#picture = GFX_Muhammad
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.18.a
		hidden_effect = { clear_variable = spain_dominican_decline_intervention }
	}
}

country_event = { 
	id = spain_caribbean.19
	title = spain_caribbean.19.t
	desc = spain_caribbean.19.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.19.a
		ai_chance = { factor = 100 }
		#Persecuted Masonry
		if = {
			limit = { 1318 = { OWNER = { is_subject_of = SPR } } }
			if = {
				limit = { 1318 = { OWNER = { has_idea = DOM_the_masonry_lodge_0 } } }
				swap_ideas = {
					remove_idea = DOM_the_masonry_lodge_0
					add_idea = DOM_the_masonry_lodge_1
				}
			}
			else = { add_ideas = DOM_the_masonry_lodge_1 }
		}
	}
	
	option = {
		name = spain_caribbean.19.b
		ai_chance = { factor = 100 }
		#Persecuted Masonry
		if = {
			limit = { 1318 = { OWNER = { is_subject_of = SPR } } }
			if = {
				limit = { 1318 = { OWNER = { has_idea = DOM_the_masonry_lodge_0 } } }
				swap_ideas = {
					remove_idea = DOM_the_masonry_lodge_0
					add_idea = DOM_the_masonry_lodge_1
				}
			}
			else = { add_ideas = DOM_the_masonry_lodge_1 }
		}
	}
}

country_event = { 
	id = spain_caribbean.20
	title = spain_caribbean.20.t
	desc = spain_caribbean.20.d
	
	is_triggered_only = yes
	
	option = {
		name = spain_caribbean.20.a
		ai_chance = { factor = 100 }
		#Sanctioned Masonry
		if = {
			limit = { 1318 = { OWNER = { is_subject_of = SPR } } }
			if = {
				limit = { 1318 = { OWNER = { NOT = { has_idea = DOM_the_masonry_lodge_0 } } } }
				add_ideas = DOM_the_masonry_lodge_0
			}
		}
	}
}

country_event = { #Welcome back Hispaniola
	id = spain_caribbean.21
	title = spain_caribbean.21.t
	desc = spain_caribbean.21.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.21.a
		trigger = { NOT = { has_completed_focus = SPR_give_power_to_the_landowners } }
		ai_chance = { 
			base = 80
		}
		#This is my office now
		custom_effect_tooltip = SPR_welcome_back_la_hispaniola_unlocked_tooltip
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 
				319 = { 
					set_state_flag = spain_hispaniola_catholic_morals_flag
					set_state_flag = spain_hispaniola_persecute_protestants_flag
					set_state_flag = spain_hispaniola_persecute_masonry_flag
				}
			}
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }
			hidden_effect = { 
				1318 = { 
					set_state_flag = spain_hispaniola_catholic_morals_flag
					set_state_flag = spain_hispaniola_persecute_protestants_flag
					set_state_flag = spain_hispaniola_persecute_masonry_flag
				}
			}
		}
		hidden_effect = {
			set_country_flag = SPR_welcome_back_la_hispaniola_flag
		}
	}
	
	option = {
		name = spain_caribbean.21.b
		ai_chance = { 
			base = 20
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		#Compromise
		custom_effect_tooltip = SPR_welcome_back_la_hispaniola_unlocked_tooltip
		if = {
			limit = { 319 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 
				319 = { 
					set_state_flag = spain_hispaniola_catholic_morals_flag
					set_state_flag = spain_hispaniola_persecute_protestants_flag
					set_state_flag = spain_hispaniola_persecute_masonry_flag
				}
			}
		}
		if = {
			limit = { 1318 = { OR = { ROOT = { owns_state = PREV } any_country = { is_subject_of = ROOT owns_state = PREV } } } }

			hidden_effect = { 
				1318 = { 
					set_state_flag = spain_hispaniola_catholic_morals_flag
					set_state_flag = spain_hispaniola_persecute_protestants_flag
					set_state_flag = spain_hispaniola_persecute_masonry_flag
				}
			}
		}
		hidden_effect = {
			set_country_flag = SPR_welcome_back_la_hispaniola_flag
		}
	}

	option = {
		name = spain_caribbean.21.c
		ai_chance = { 
			base = 5
			modifier = {
				factor = 0
				is_historical_focus_on = yes
			}
		}
		#Status Quo in La Hispanoila
		custom_effect_tooltip = SPR_welcome_back_la_hispaniola_locked_tooltip
	}
}

country_event = { #Queen's or King's coup 1866
	id = spain.9
	hidden = yes
	is_triggered_only = yes

	immediate = {
		if = {
			limit = { has_government = centrism }
			hidden_effect = { SPR = { country_event = { id = spain.10 days = 1 } } }
		}
		else = {
			hidden_effect = { SPR = { country_event = { id = spain.11 days = 1 } } }
		}
	}
}

country_event = { #Queen's coup 1866
	id = spain.10
	title = spain.10.t
	desc = spain.10.d
	
	is_triggered_only = yes

	option = {
		name = spain.10.a
		ai_chance = { factor = 100 }
		set_politics = {
			ruling_party = traditional_conservatism
		}
		complete_national_focus = SPR_the_queens_will
	}
	
	option = {
		name = spain.10.b
		ai_chance = { factor = 0 }
		start_civil_war = {
			ruling_party = centrism
			ideology = traditional_conservatism
			size = 0.3
			capital = 165
			states = { 
				165 166 167 177 172 176 1059 41 171
			}
			keep_unit_leaders = {
			}
		}
		complete_national_focus = SPR_a_liberal_spain
		random_other_country = {
			limit = {
				original_tag = SPR
				has_government = traditional_conservatism
			}
			complete_national_focus = SPR_the_queens_will
		}
	}
}



country_event = { #Kings's coup 1858
	id = spain.11 #was also spain.3?
	title = spain.11.t
	desc = spain.11.d
	
	is_triggered_only = yes

	option = {
		name = spain.11.a
		ai_chance = { factor = 100 }
		set_politics = {
			ruling_party = autocracy
		}
		complete_national_focus = SPR_obey_the_king
	}
	
	option = {
		name = spain.11.b
		ai_chance = { factor = 0 }
		start_civil_war = {
			ruling_party = traditional_conservatism
			ideology = autocracy
			size = 0.2
			capital = 165
			states = { 
				165 166 167 177 172 176 1059 41 171
			}
			keep_unit_leaders = {
			}
		}
		complete_national_focus = SPR_defend_the_goverment
		random_other_country = {
			limit = {
				original_tag = SPR
				has_government = autocracy
			}
			complete_national_focus = SPR_obey_the_king
		}
	}
}

#Volunteers Return Home
country_event = { 
	id = spain.12
	title = spain.12.t
	desc = spain.12.d
	
	trigger = {
		OR = {
			has_template = "Carlist Volunteers"
			has_template = "Progressive Volunteers"
		}
	}
	
	is_triggered_only = yes

	option = {
		name = spain.12.a
		ai_chance = { factor = 100 }
		if = {
			limit = {
				has_template = "Carlist Volunteers"
			}
			delete_unit_template_and_units = {
				division_template = "Carlist Volunteers"
			}
		}
		if = {
			limit = {
				has_template = "Progressive Volunteers"
			}
			delete_unit_template_and_units = {
				division_template = "Progressive Volunteers"
			}
		}
	}
}



#########################################
#										#
#			Custom Mechanics			#
#										#
#########################################

country_event = { #Debt system initial announcement
	id = spain.8
	title = spain.8.t
	desc = spain.8.d
	
	is_triggered_only = yes

	option = {
		name = spain.8.a
		ai_chance = { factor = 100 }
	}
}

country_event = { #Debt system
	id = calc_spain_debt.1
	hidden = yes
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			ROOT = {
				 
			}
		}
	}
}

country_event = { #Debt system bankrupcy avoiding
	id = SPR_bankruptcy_events.1
	title = SPR_bankruptcy_events.1.t
	desc = SPR_bankruptcy_events.1.d 
	
	is_triggered_only = yes
	
	option = {
		name = SPR_bankruptcy_events.1.a
		ai_chance = { 
			base = 100 
		}
		SPR = { give_resource_rights = { receiver = ENG state = 169 } }
		hidden_effect = { 
			169 = { set_state_flag = SPR_sold_andalusia_mining_rights_flag } 
			SPR = { country_event = { id = SPR_bankruptcy_events.2 days = 3 } }
		}
	}
	
	option = {
		name = SPR_bankruptcy_events.1.b
		ai_chance = { 
			base = 0 
			modifier = {
				factor = 0 
				is_historical_focus_on = yes
			}
		}
		hidden_effect = { SPR = { country_event = { id = SPR_bankruptcy_events.3 days = 3 } } }
	}
}

country_event = { #Debt system bankrupcy avoiding succes
	id = SPR_bankruptcy_events.2
	title = SPR_bankruptcy_events.2.t
	desc = SPR_bankruptcy_events.2.d 
	
	is_triggered_only = yes
	
	option = {
		name = SPR_bankruptcy_events.2.a
		remove_ideas = edc_bankrupt
		add_timed_idea = {
			idea = edc_bankrupt_reduced
			days = 1277
		}
	}
}

country_event = { #Debt system bankrupcy avoiding failiure
	id = SPR_bankruptcy_events.3
	title = SPR_bankruptcy_events.3.t
	desc = SPR_bankruptcy_events.3.d 
	
	is_triggered_only = yes
	
	option = {
		name = SPR_bankruptcy_events.3.a
		hidden_effect = { 
			if = {
				limit = { NOT = { has_dlc = "Man the Guns" } }
				add_political_power = 200 
			}
		}
	}
}

country_event = { #Debt system bankrupcy avoiding restoration
	id = SPR_bankruptcy_events.4
	title = SPR_bankruptcy_events.4.t
	desc = SPR_bankruptcy_events.4.d 
	
	is_triggered_only = yes
	
	option = {
		name = SPR_bankruptcy_events.4.a
		add_political_power = 200
	}
}

#state_event = { #Colonial profits system		#Old eco system 	#Next dev dont use 'colonial_profits_in_state_test' as namespace
#	id = colonial_profits_in_state_test.1
#	hidden = yes
#	is_triggered_only = yes
#	
#	immediate = {
#		ROOT = { add_to_variable = { var = colonial_profits_in_state value = 1 } }
#	}
#}

country_event = { #Debt system for Hispaniola
	id = spain_caribbean.22
	title = spain_caribbean.22.t
	desc = spain_caribbean.22.d
	
	is_triggered_only = yes

	option = {
		name = spain_caribbean.22.a
		ai_chance = { factor = 100 }
		#Dominican Debt Repayments End
		custom_effect_tooltip = SPR_debt_repayment_profits_minus_10
		hidden_effect = { SPR = { subtract_from_variable = {var = SPR_debt_repayment_profits value = 0.10 } } }
	}
}

country_event = {#Spain benefitting from the sale of cuba, 20 installments of -6 over the course of 20y
	id = spain_caribbean.23
	title = spain_caribbean.23.t
	desc = spain_caribbean.23.d

	is_triggered_only = yes

	option = {
		name = spain_caribbean.23.a
		set_temp_variable = { money_to_gain = -0.5 }
		add_money_with_tooltip_effect = yes
		hidden_effect = {
			add_to_variable = {
				var = USA_installments_to_SPR_left
				value = -1
			}
			if = {
				limit = {
					check_variable = {
						var = USA_installments_to_SPR_left
						value = 0
						compare = equals
					}
				}
				#do nothing
			}
			else_if = {
				limit = {
					check_variable = {
						var = USA_installments_to_SPR_left
						value = 0
						compare = greater_than_or_equals
					}
				}
				SPR = {
					country_event = {
						id = spain_caribbean.23
						days = 365
					}
				}
			}
		}
	}
}

#########################################
#										#
#				Flavour					#
#										#
#########################################

country_event = { #Worker’s Congress of Barcelona

	id = spanishflavour.3
	title = spanishflavour.3.t
	desc = spanishflavour.3.d

	fire_only_once = yes
	is_triggered_only = yes

	option = { 
		name = spanishflavour.3.a
		ai_chance = { factor = 100 }
		add_popularity = { ideology = social_egalitarianism popularity = 0.05 }
	}
}
	
country_event = { #Naipes Heraclio Fournier

	id = spanishflavour.4
	title = spanishflavour.4.t
	desc = spanishflavour.4.d

	fire_only_once = yes
	is_triggered_only = yes

	option = { 
		name = spanishflavour.4.a
		ai_chance = { factor = 100 }
		add_stability = 0.01
		add_political_power = 20
	}
}
	
country_event = { #Second Worker’s Congress of Barcelona

	id = spanishflavour.5
	title = spanishflavour.5.t
	desc = spanishflavour.5.d

	fire_only_once = yes
	is_triggered_only = yes

	option = { 
		name = spanishflavour.5.a
		ai_chance = { factor = 100 }
		add_popularity = { ideology = social_egalitarianism popularity = 0.05 }
		add_war_support = -0.05
		country_event = { id = spanishflavour.6 days = 10 } 
	}
}
	
country_event = { #Creation of the Federación Regional Española de la AIT

	id = spanishflavour.6
	title = spanishflavour.6.t
	desc = spanishflavour.6.d
	
	fire_only_once = yes
	is_triggered_only = yes

	option = { 
		name = spanishflavour.6.a
		ai_chance = { factor = 100 }
		add_popularity = { ideology = anarchism popularity = 0.05 }
		add_political_power = -30
	}
}

country_event = { #Construction of the National Archeologic Museum

	id = spanishflavour.7
	title = spanishflavour.7.t
	desc = spanishflavour.7.d
	
	fire_only_once = yes
	is_triggered_only = yes

	option = { 
		name = spanishflavour.7.a
		ai_chance = { factor = 100 }
		add_stability = 0.01
		add_political_power = 25
	}
}

country_event = { #Petrol Revolution
	id = spanishflavour.8
	title = spanishflavour.8.t
	desc = spanishflavour.8.d
	
	is_triggered_only = yes
	fire_only_once = yes

	option = {
		name = spanishflavour.8.a
		ai_chance = { factor = 50 }
		add_political_power = -100
		add_stability =  -0.02
		167 = { add_manpower = -300 }
		167 = { damage_building = { type = infrastructure damage = 1 } }
		add_popularity = { ideology = anarchism popularity = 0.05 }
	}
	option = {
		name = spanishflavour.8.b
		ai_chance = { factor = 50 }
		add_political_power = 100
		add_stability = -0.05
		167 = { add_manpower = -600 }
		167 = { damage_building = { type = infrastructure damage = 2 } }
		add_popularity = { ideology = anarchism popularity = 0.10 }
	}
}

country_event = { #Rememberance of Farmer's Speach

	id = spanishflavour.9
	title = spanishflavour.9.t
	desc = spanishflavour.9.d
	
	fire_only_once = yes
	is_triggered_only = yes

	option = { 
		name = spanishflavour.9.a
		ai_chance = { factor = 100 }
		
	}
}

#########################################
#										#
#	Events for Spanish Navy				#
#										#
#########################################

country_event = { #Definitive Colonization of Fernando Po
	id = spain.13
	title = spain.13.t
	desc = spain.13.d
	picture = GFX_report_event_colonization_fernando_poo
	
	is_triggered_only = yes
	fire_only_once = yes

	option = { 
		name = spain.13.a
		ai_chance = { factor = 100 }
		navy_experience = 15
	}
}

country_event = { #Plan de Escuadra 1848-1855
	id = spain.14
	title = spain.14.t
	desc = spain.14.d
	picture = GFX_report_event_plan_de_escuadra
	
	is_triggered_only = yes
	fire_only_once = yes

	option = {
		name = spain.14.a
		ai_chance = { factor = 100 }
		add_ideas = SPR_idea_plan_de_escuadra
	}
}


country_event = { #Cochinchina French-Spanish Campaign
	id = spain.15
	title = spain.15.t
	desc = spain.15.d
	picture = GFX_report_event_cochinchina_campaign
	
	is_triggered_only = yes
	fire_only_once = yes

	option = {
		name = spain.15.a
		ai_chance = { factor = 100 }
		navy_experience = 30
		army_experience = 15
	}
}

# Spanish Joan of Arc
country_event = {
	id = spain.16
	title = spain.16.t
	desc = spain.16.d
	#picture = 
	is_triggered_only = yes
	fire_only_once = yes
	option = {
		name = spain.16.a
	}
}

state_event = { #Colonial profits system
	id = spain.17
	hidden = yes
	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			every_state = {
				limit = { 
					has_variable = colonial_profits_in_state 
					OWNER = {
						OR = { 
							set_temp_variable = { loan_size_to_check = 0 }
							has_less_than_specific_loan_size = no
							AND = {
								is_subject = yes
								OVERLORD = {
									set_temp_variable = { loan_size_to_check = 0 }
									has_less_than_specific_loan_size = no
								}
							}
						}
					}
				}
				OWNER = {
					if = {
						limit = { 
							THIS = { is_subject = yes } 
							OVERLORD = {
								set_temp_variable = { loan_size_to_check = 0 }
    							has_less_than_specific_loan_size = no
							}
						}
						OVERLORD = { add_to_variable = { var = THIS.colonial_profits_in_state_temp value = PREV.PREV.colonial_profits_in_state } }
					}
					else_if = { 
						limit = {
							set_temp_variable = { loan_size_to_check = 0 }
							has_less_than_specific_loan_size = no
						}
						add_to_variable = { var = THIS.colonial_profits_in_state_temp value = PREV.colonial_profits_in_state } 
					}
				}
			}
			every_country = {
				limit = { has_variable = colonial_profits_in_state_temp }
				set_variable = { var = THIS.total_colonial_profits value = THIS.colonial_profits_in_state_temp }
				clear_variable = THIS.colonial_profits_in_state_temp
				if = { 
					limit = { NOT = { has_active_mission = debt_colonial_profits_decision } }
					activate_mission = debt_colonial_profits_decision
				}
			}
			state_event = { id = spain.17 days = 30 }
		}
	}
}

country_event = { #Militia system
	id = spain.18
	hidden = yes
	is_triggered_only = yes

	immediate = {
		hidden_effect = { ROOT = { every_owned_state = { limit = { SPR_homeland_states = yes } SPR_call_national_militia_units = yes } } }
	}
}

country_event = { #Militia system
	id = spain.19
	hidden = yes
	is_triggered_only = yes

	immediate = {
		hidden_effect = { ROOT = { SPR_dismiss_national_militia_units = yes } }
	}
}

#########################################
############# Philippines ###############
#########################################


country_event = { #Philippines Captain Election System
	id = spain.20
	title = spain.20.t
	desc = spain.20.d

	is_triggered_only = yes
	
	trigger = { SPH = { is_subject_of = ROOT } }
	
	option = {
		name = spain.20.a
		ai_chance = {
			base = 75 
		}
		SPH = {
			if = {
				limit = { ROOT = { has_government = anarchism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = anarchism }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = ideology_radical_socialism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = ideology_radical_socialism }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = social_egalitarianism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = social_egalitarianism }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = centrism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = centrism }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = ideology_social_liberalism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = ideology_social_liberalism }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = traditional_conservatism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = traditional_conservatism }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = radical_democracy } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = radical_democracy }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = chauvinist_populism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = chauvinist_populism }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = autocracy } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = autocracy }
					retire_country_leader = yes
				}
			}
			else_if = {
				limit = { ROOT = { has_government = fundamentalism } }
				retire_country_leader = yes
				hidden_effect = { 
					set_politics = { ruling_party = fundamentalism }
					retire_country_leader = yes
				}
			}
		}
		hidden_effect = { SPH = { country_event = { id = spain.21 days = 3 } } }
	}
	
	option = {
		name = spain.20.b
		ai_chance = { 
			base = 25 
		}
		hidden_effect = { SPH = { country_event = { id = spain.22 days = 3 } } }
	}
}

country_event = { #Philippines Captain Election System
	id = spain.21
	title = spain.21.t
	desc = spain.21.d

	is_triggered_only = yes
	
	immediate = { hidden_effect = { FROM = { country_event = { id = spain.20 days = 1095 } } } }
	
	option = {
		name = spain.21.a
		ai_chance = { base = 100 }
		add_political_power = 25
		ROOT = {
			if = {
				limit = { FROM = { has_government = anarchism } }
				add_popularity = { ideology = anarchism popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = ideology_radical_socialism } }
				add_popularity = { ideology = ideology_radical_socialism popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = social_egalitarianism } }
				add_popularity = { ideology = social_egalitarianism popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = centrism } }
				add_popularity = { ideology = centrism popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = ideology_social_liberalism } }
				add_popularity = { ideology = ideology_social_liberalism popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = traditional_conservatism } }
				add_popularity = { ideology = traditional_conservatism popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = radical_democracy } }
				add_popularity = { ideology = radical_democracy popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = chauvinist_populism } }
				add_popularity = { ideology = chauvinist_populism popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = autocracy } }
				add_popularity = { ideology = autocracy popularity = 0.05 }
			}
			else_if = {
				limit = { FROM = { has_government = fundamentalism } }
				add_popularity = { ideology = fundamentalism popularity = 0.05 }
			}
		}
	}
}

country_event = { #Philippines Captain Election System
	id = spain.22
	title = spain.22.t
	desc = spain.22.d

	is_triggered_only = yes
	
	immediate = { hidden_effect = { FROM = { country_event = { id = spain.20 days = 1095 } } } }
	
	option = {
		name = spain.22.a
		ai_chance = { base = 100 }
		add_political_power = 100
	}
}


###### Activate Carlist FT ####  #Could be use later however do not use carlistft as namespace, use currently availableone  
#    country_event = {
#	id = carlistft.1
#	title = carlistft.1.t
#	desc = carlistft.1d
#
#	fire_only_once = yes
#	is_triggered_only = yes
#	
#	
#	trigger = {
#		#has_war = no
#        #SPR = { exists = no }
#		
#	}
#	
#    option = { 
#	        name = carlistft.1.a
#			ai_chance = {
#                factor = 100
#            }
#			#load_focus_tree = carlist_spain
#		}
#}