namespace = FEE_Jaffna_Events

# The Kingdom of Jaffna
country_event = {
	id = FEE_Jaffna_Events.1
	title = FEE_Jaffna_Events.1.T
	desc = FEE_Jaffna_Events.1.D
	picture = GOOD_WITH_MONARCH_eventPicture

	fire_only_once = yes

	trigger = {
		is_or_was_tag = { tag = JFN }
		current_age = age_of_discovery
	}

	mean_time_to_happen = {
		months = 6
	}

	major = yes
	major_trigger = {
		num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
			value = 1
			OR = {
				area = lanka_area
				area = south_lanka_area
			}
		}
	}

	option = {
		name = FEE_Jaffna_Events.1.OPT1
		ai_chance = {
			factor = 50
		}

		add_mercantilism_or_monarch_power = { amount = 3 }
		lanka_area = {
			remove_core = ROOT
			remove_claim = ROOT
		}
		south_lanka_area = {
			remove_core = ROOT
			remove_claim = ROOT
		}
	}

	option = {
		name = FEE_Jaffna_Events.1.OPT2
		ai_chance = {
			factor = 50
		}

		add_ruler_modifier = {
			name = fee_jfn_kalinga_freedom
			duration = -1
		}
		lanka_area = {
			add_core = ROOT
		}
		south_lanka_area = {
			add_core = ROOT
		}
	}
}

# Jaffna expansion in Ceylon
country_event = {
	id = FEE_Jaffna_Events.2
	title = FEE_Jaffna_Events.2.T
	desc = FEE_Jaffna_Events.2.D
	picture = CONQUEST_eventPicture

	fire_only_once = yes
	
	trigger = {
		is_or_was_tag = { tag = JFN }
		lanka_area = {
			type = all
			owned_by = ROOT
		}
		south_lanka_area = {
			type = all
			owned_by = ROOT
		}
	}

	mean_time_to_happen = {
		months = 3
	}

	option = {
		name = FEE_Jaffna_Events.2.OPT1
		ai_chance = {
			factor = 50
		}

		add_accepted_culture_or_dip_power = {
			culture = sinhala
		}
		lanka_area = {
			limit = { culture = sinhala }
			add_province_modifier = {
				name = fee_jfn_reconciliation
				duration = 3650
			}
		}
		south_lanka_area = {
			limit = { culture = sinhala }
			add_province_modifier = {
				name = fee_jfn_reconciliation
				duration = 3650
			}
		}
	}

	option = {
		name = FEE_Jaffna_Events.2.OPT2
		ai_chance = {
			factor = 50
		}

		add_mil_power = 50
		lanka_area = {
			limit = { culture = sinhala }
			add_province_modifier = {
				name = fee_jfn_local_oppression
				duration = 3650
			}
		}
		south_lanka_area = {
			limit = { culture = sinhala }
			add_province_modifier = {
				name = fee_jfn_local_oppression
				duration = 3650
			}
		}
	}
}

# Aryacakravarti rule in Ceylon
country_event = {
	id = FEE_Jaffna_Events.3
	title = FEE_Jaffna_Events.3.T
	desc = FEE_Jaffna_Events.3.D
	picture = CITY_DEVELOPMENT_eventPicture

	fire_only_once = yes
	
	trigger = {
		is_or_was_tag = { tag = JFN }
		lanka_area = {
			type = all
			owned_by = ROOT
			OR = {
				has_owner_accepted_culture = yes
				religion = ROOT
			}
		}
		south_lanka_area = {
			type = all
			owned_by = ROOT
			OR = {
				has_owner_accepted_culture = yes
				religion = ROOT
			}
		}
	}

	mean_time_to_happen = {
		months = 3
	}

	option = {
		name = FEE_Jaffna_Events.3.OPT1
		ai_chance = {
			factor = 75
		}

		capital_scope = {
			add_base_tax = 2
			add_base_production = 2
			add_base_manpower = 2
			add_or_upgrade_trade_building = yes
			add_or_upgrade_shipyard_building = yes
			create_or_add_center_of_trade_level_fee = { level = 1 }
		}
		lanka_area = {
			add_devastation = -100
			add_prosperity = 100
			random_province_in_state = {
				limit = {
					NOT = { is_capital = yes }
				}
				add_random_development = 1
				random_list = {
					50 = { add_or_upgrade_trade_building = yes }
					50 = { add_or_upgrade_shipyard_building = yes }
				}
			}
		}
		south_lanka_area = {
			add_devastation = -100
			add_prosperity = 100
			random_province_in_state = {
				limit = {
					NOT = { is_capital = yes }
				}
				add_random_development = 1
				random_list = {
					50 = { add_or_upgrade_trade_building = yes }
					50 = { add_or_upgrade_shipyard_building = yes }
				}
			}
		}
	}
}

# Golden Age of Aryacakravarti
country_event = {
	id = FEE_Jaffna_Events.4
	title = FEE_Jaffna_Events.4.T
	desc = FEE_Jaffna_Events.4.D
	picture = GOLDEN_CITY_eventPicture

	fire_only_once = yes
	
	trigger = {
		is_or_was_tag = { tag = JFN }
		lanka_area = {
			type = all
			owned_by = ROOT
			fee_province_does_not_lack_any_institution = yes
			OR = {
				num_of_times_improved = 2
				prosperity = 100
			}
		}
		south_lanka_area = {
			type = all
			owned_by = ROOT
			fee_province_does_not_lack_any_institution = yes
			OR = {
				num_of_times_improved = 2
				prosperity = 100
			}
		}
	}

	mean_time_to_happen = {
		months = 24
	}

	option = {
		name = FEE_Jaffna_Events.4.OPT1
		ai_chance = {
			factor = 75
		}

		add_country_modifier = {
			name = fee_jfn_tamil_trade_adventures
			duration = 7300
		}
		capital_scope = {
			add_or_upgrade_courthouse_building = yes
		}
		lanka_area = {
			add_permanent_province_modifier = {
				name = fee_jfn_golden_age_aryacakravarti
				duration = -1
			}
		}
		south_lanka_area = {
			add_permanent_province_modifier = {
				name = fee_jfn_golden_age_aryacakravarti
				duration = -1
			}
		}
		504 = {
			add_trade_modifier = {
				who = ROOT
				duration = 7300
				power = 15
				key = fee_jfn_tamil_trade_adventures
			}
		}
		1340 = {
			add_trade_modifier = {
				who = ROOT
				duration = 7300
				power = 15
				key = fee_jfn_tamil_trade_adventures
			}
		}
		1343 = {
			add_trade_modifier = {
				who = ROOT
				duration = 7300
				power = 15
				key = fee_jfn_tamil_trade_adventures
			}
		}
		584 = {
			add_trade_modifier = {
				who = ROOT
				duration = 7300
				power = 15
				key = fee_jfn_tamil_trade_adventures
			}
		}
		1365 = {
			add_trade_modifier = {
				who = ROOT
				duration = 7300
				power = 15
				key = fee_jfn_tamil_trade_adventures
			}
		}
		1361 = {
			add_trade_modifier = {
				who = ROOT
				duration = 7300
				power = 15
				key = fee_jfn_tamil_trade_adventures
			}
		}
		1371 = {
			add_trade_modifier = {
				who = ROOT
				duration = 7300
				power = 15
				key = fee_jfn_tamil_trade_adventures
			}
		}
	}
}

# Muslim Arrival in Jaffna
country_event = {
	id = FEE_Jaffna_Events.5
	title = FEE_Jaffna_Events.5.T
	desc = FEE_Jaffna_Events.5.D
	picture = MERCHANTS_TALKING_eventPicture

	fire_only_once = yes
	
	trigger = {
		owns = 1854 # Jaffna
	}

	mean_time_to_happen = {
		months = 24
	}

	goto = 1854

	option = {
		name = FEE_Jaffna_Events.5.OPT1
		ai_chance = {
			factor = 75
		}

		1854 = {
			add_random_development = 1
			add_permanent_province_modifier = {
				name = fee_jfn_muslim_minority
				duration = -1
			}
		}
	}

	after = {
		hidden_effect = {
			1854 = {
				province_event = {
					id = FEE_Jaffna_Events.6
					days = 7300
				}
			}
		}
	}
}

#Growing Muslim Community
province_event = {
	id = FEE_Jaffna_Events.6
	title = FEE_Jaffna_Events.6.T
	desc = FEE_Jaffna_Events.6.D
	picture = MERCHANTS_TALKING_eventPicture

	fire_only_once = yes
	is_triggered_only = yes

	goto = 1854

	option = {
		name = FEE_Jaffna_Events.6.OPT1
		ai_chance = {
			factor = 75
		}

		remove_province_modifier = fee_jfn_muslim_minority
		add_permanent_province_modifier = {
			name = fee_jfn_flourishing_muslim_community
			duration = -1
		}
		hidden_effect = {
			1854 = {
				province_event = {
					id = FEE_Jaffna_Events.7
					days = 7300
				}
			}
		}
	}

	option = {
		name = FEE_Jaffna_Events.6.OPT2
		ai_chance = {
			factor = 25
		}

		add_devastation = -33
		add_random_development = -1
		remove_province_modifier = fee_jfn_muslim_minority
	}
}

#Flourishing Muslim Community
province_event = {
	id = FEE_Jaffna_Events.7
	title = FEE_Jaffna_Events.7.T
	desc = FEE_Jaffna_Events.7.D
	picture = MERCHANTS_TALKING_eventPicture

	fire_only_once = yes
	is_triggered_only = yes

	goto = 1854

	option = {
		name = FEE_Jaffna_Events.7.OPT1
		ai_chance = {
			factor = 75
		}

		remove_province_modifier = fee_jfn_flourishing_muslim_community
		add_permanent_province_modifier = {
			name = fee_jfn_strong_muslim_community
			duration = -1
		}
		hidden_effect = {
			1854 = {
				province_event = {
					id = FEE_Jaffna_Events.8
					days = 1825
				}
			}
		}
	}

	option = {
		name = FEE_Jaffna_Events.7.OPT2
		ai_chance = {
			factor = 25
		}

		add_devastation = -75
		add_base_tax = -1
		add_base_production = -1
		add_base_manpower = -1
		remove_province_modifier = fee_jfn_flourishing_muslim_community
	}
}

#Imposing Muslim Community
province_event = {
	id = FEE_Jaffna_Events.8
	title = FEE_Jaffna_Events.8.T
	desc = FEE_Jaffna_Events.8.D
	picture = RELIGION_eventPicture

	fire_only_once = yes
	is_triggered_only = yes

	trigger = {
		NOT = { religion_group = muslim }
	}

	goto = 1854

	option = {
		name = FEE_Jaffna_Events.8.OPT1
		ai_chance = {
			factor = 75
		}

		change_religion = ibadi
	}
}

#The Arrival of the Aliens
country_event = {
	id = FEE_Jaffna_Events.9
	title = FEE_Jaffna_Events.9.T
	desc = FEE_Jaffna_Events.9.D
	picture = EXPLORERS_eventPicture

	fire_only_once = yes

	trigger = {
		is_or_was_tag = { tag = JFN }
		any_country = {
			capital_scope = { continent = europe }
			num_of_explorers = 1
			OR = {
				lanka_area = {
					has_discovered = PREV
					owned_by = ROOT
				}
				south_lanka_area = {
					has_discovered = PREV
					owned_by = ROOT
				}
			}
		}
	}

	major = yes
	major_trigger = {
		any_country = {
			has_country_flag = fee_jfn_discovered_ceylon_flag
		}
	}
	
	immediate = {
		hidden_effect = {
			random_country = {
				limit = {
					capital_scope = { continent = europe }
					OR = {
						lanka_area = {
							has_discovered = PREV
							owned_by = ROOT
						}
						south_lanka_area = {
							has_discovered = PREV
							owned_by = ROOT
						}
					}
				}
				set_country_flag = fee_jfn_discovered_ceylon_flag
			}
		}
	}

	option = {
		name = FEE_Jaffna_Events.9.OPT1
		ai_chance = {
			factor = 75
		}

		change_dip = 1
		add_treasury = -25
		random_country = {
			limit = { has_country_flag = fee_jfn_discovered_ceylon_flag }
			add_opinion = {
				who = ROOT
				modifier = fee_jfn_diplomatic_meddling
			}
			reverse_add_opinion = {
				who = ROOT
				modifier = fee_jfn_diplomatic_meddling
			}
			2100 = {
				add_trade_modifier = {
					who = PREV
					duration = 18250
					power = 10
					key = fee_jfn_diplomatic_meddling
				}
			}
		}
	}

	option = {
		name = FEE_Jaffna_Events.9.OPT2
		ai_chance = {
			factor = 25
		}

		change_mil = 1
		add_country_modifier = {
			name = fee_jfn_fighting_aliens
			duration = 7300
		}
		custom_tooltip = FEE_JFN_ALIENS_TT
		random_country = {
			limit = { has_country_flag = fee_jfn_discovered_ceylon_flag }
			country_event = {
				id = FEE_Jaffna_Events.10
				days = 90
			}
		}
	}

}

#European Trade Request
country_event = {
	id = FEE_Jaffna_Events.10
	title = FEE_Jaffna_Events.10.T
	desc = FEE_Jaffna_Events.10.D
	picture = DIPLOMACY_SIGNING_eventPicture

	fire_only_once = yes
	is_triggered_only = yes

	major = yes
	major_trigger = {
		is_or_was_tag = { tag = JFN }
	}

	option = {
		name = FEE_Jaffna_Events.10.OPT1
		ai_chance = {
			factor = 75
		}

		lanka_area = { add_permanent_claim = ROOT }
		south_lanka_area = { add_permanent_claim = ROOT }
	}

	option = {
		name = FEE_Jaffna_Events.10.OPT2
		trigger = {
			OR = {
				lanka_area = {
					owner = {
						NOT = {
							is_or_was_tag = { tag = JFN }
						}
					}
				}
				south_lanka_area = {
					owner = {
						NOT = {
							is_or_was_tag = { tag = JFN }
						}
					}
				}
			}
		}
		ai_chance = {
			factor = 25
		}

		random_country = {
			limit = {
				NOT = {
					is_or_was_tag = { tag = JFN }
				}
				any_owned_province = {
					area = lanka_area
					area = south_lanka_area
				}
			}
			country_event = {
				id = FEE_Jaffna_Events.11
				days = 90
			}
		}
	}
}

#Euro-Ceylon ruling
country_event = {
	id = FEE_Jaffna_Events.11
	title = FEE_Jaffna_Events.11.T
	desc = FEE_Jaffna_Events.11.D
	picture = DIPLOMACY_SIGNING_eventPicture

	fire_only_once = yes
	is_triggered_only = yes

	major = yes
	major_trigger = {
		is_or_was_tag = { tag = JFN }
	}

	option = {
		name = FEE_Jaffna_Events.11.OPT1
		trigger = {
			OR = {
				lanka_area = {
					NOT = { owned_by = ROOT }
				}
				south_lanka_area = {
					NOT = { owned_by = ROOT }
				}
			}
		}
		ai_chance = {
			factor = 75
		}

		lanka_area = { add_permanent_claim = ROOT }
		south_lanka_area = { add_permanent_claim = ROOT }
		add_country_modifier = {
			name = fee_jfn_drive_off_invaders
			duration = 3650
		}
		random_country = {
			limit = { has_country_flag = fee_jfn_discovered_ceylon_flag }
			add_casus_belli = {
				type = cb_vassalize_mission
				target = ROOT
			}
		}
		random_country = {
			limit = { has_country_modifier = fee_jfn_fighting_aliens }
			country_event = {
				id = FEE_Jaffna_Events.12
				days = 18250
			}
		}
	}

	option = {
		name = FEE_Jaffna_Events.11.OPT2
		trigger = {
			is_free_or_tributary_trigger = yes
		}
		ai_chance = {
			factor = 25
		}

		add_country_modifier = {
			name = fee_jfn_euro_ceylon_cooperation
			duration = 3650
		}
		random_country = {
			limit = { has_country_flag = fee_jfn_discovered_ceylon_flag }
			vassalize = ROOT
			add_trust = {
				who = ROOT
				value = 100
				mutual = yes
			}
			add_opinion = {
				who = ROOT
				modifier = opinion_eased_tension
			}
			reverse_add_opinion = {
				who = ROOT
				modifier = opinion_eased_tension
			}
		}
	}
}

#Euro-Ceylon ruling
country_event = {
	id = FEE_Jaffna_Events.12
	title = FEE_Jaffna_Events.12.T
	desc = {
		desc = FEE_Jaffna_Events.12.D_GOOD
		trigger = {
			NOT = {
				any_country = {
					capital_scope = { superregion = europe_superregion }
					any_owned_province = { superregion = india_superregion }
				}
			}
		}
	}
	desc = {
		desc = FEE_Jaffna_Events.12.D_BAD
		trigger = {
			any_country = {
				capital_scope = { superregion = europe_superregion }
				any_owned_province = { superregion = india_superregion }
			}
		}
	}
	picture = {
		picture = GOOD_WITH_MONARCH_eventPicture
		trigger = {
			NOT = {
				any_country = {
					capital_scope = { superregion = europe_superregion }
					any_owned_province = { superregion = india_superregion }
				}
			}
		}
	}
	picture = {
		picture = BAD_WITH_MONARCH_EVENTPICTURE
		trigger = {
			any_country = {
				capital_scope = { superregion = europe_superregion }
				any_owned_province = { superregion = india_superregion }
			}
		}
	}

	fire_only_once = yes
	is_triggered_only = yes

	option = {
		name = FEE_Jaffna_Events.12.OPT1
		trigger = {
			NOT = {
				any_country = {
					capital_scope = { superregion = europe_superregion }
					any_owned_province = { superregion = india_superregion }
				}
			}
		}
		ai_chance = {
			factor = 75
		}

		add_adm_power = 100
		add_dip_power = 100
		add_mil_power = 100
		add_power_projection = {
			type = mission_rewards_power_projection
			amount = 25
		}
		change_adm = 1
		change_dip = 1
		change_mil = 1
		capital_scope = {
			add_base_tax = 3
			add_base_production = 3
			add_base_manpower = 3
		}
	}

	option = {
		name = FEE_Jaffna_Events.12.OPT2
		trigger = {
			any_country = {
				capital_scope = { superregion = europe_superregion }
				any_owned_province = { superregion = india_superregion }
			}
		}
		ai_chance = {
			factor = 25
		}

		add_adm_power = -100
		add_dip_power = -100
		add_mil_power = -100
		add_power_projection = {
			type = mission_rewards_power_projection
			amount = -25
		}
		change_adm = -1
		change_dip = -1
		change_mil = -1
		capital_scope = {
			add_base_tax = -3
			add_base_production = -3
			add_base_manpower = -3
		}
	}
}
