########################################
# Events for Malacca
#
# written by Henrik Lohmander
########################################

namespace = flavor_mlc
normal_or_historical_nations = yes

	
# The Plot against Raja Ibrahim
country_event = {
	id = flavor_mlc.1
	title = flavor_mlc.1.t
	desc = flavor_mlc.1.d
	picture = ASSASSINATION_eventPicture
	fire_only_once = yes

	trigger = {
		tag = MLC
		has_ruler = "0000000"
		has_heir = yes #The Bendahara won't initiate this plot unless the succession is secure.
		NOT = { is_year = 1450 }
	}

	mean_time_to_happen = {
		months = 18
	}
	
	
	option = { 
		name = flavor_mlc.1.a #Raja Ibrahim will not be forgotten.
		kill_ruler = yes
		set_ruler_flag = mlc_death_or_raja_ibrahim
	}
}

# Bendahara Tun Perak
country_event = {
	id = flavor_mlc.2
	title = flavor_mlc.2.t
	desc = flavor_mlc.2.d
	picture = GOOD_WITH_MONARCH_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = MLC
		has_ruler_flag = mlc_death_or_raja_ibrahim
	}

	mean_time_to_happen = {
		months = 45
	}
	
	option = {
		name = flavor_mlc.2.a #Appoint Tun Perak
		ai_chance = { factor = 90 }
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		add_country_modifier = {
			name = mlc_tun_perak
			duration = 3650
		}
	}
	option = {
		name = flavor_mlc.2.b #Appoint a puppet and marginalize the Bendahara. 
		ai_chance = { factor = 10 }
		add_prestige = 15
		add_stability_or_adm_power = yes
	}
}


# Piracy in the Malayan Sea (Repeating)
country_event = {
	id = flavor_mlc.3
	title = flavor_mlc.3.t
	desc = flavor_mlc.3.d
	picture = NAVAL_MILITARY_eventPicture

	trigger = {
		tag = MLC
		NOT = { has_country_modifier = mlc_piracy_controlled }
		NOT = { dip_tech = 10 } #Pirates less of a problem at this point.
	}

	mean_time_to_happen = {
		months = 180
		
		modifier = {
			factor = 0.8
			any_owned_province = {
				OR = {
					area = malaya_area
					area = malacca_area
				}
				has_discovered = POR
			}
		}
	}
	
	
	option = { 
		name = flavor_mlc.3.a #Assign the task to one of the trader communities.
		add_stability = -1
		add_country_modifier = {
			name = mlc_piracy_controlled
			duration = 3650
		}
	}
	option = { 
		name = flavor_mlc.3.b #We will use our own resources to sort this out.
		add_years_of_income = -0.15
		add_country_modifier = {
			name = mlc_piracy_controlled
			duration = 3650
		}
	}
}

# Islam and the Malaccan state
country_event = {
	id = flavor_mlc.4
	title = flavor_mlc.4.t
	desc = flavor_mlc.4.d
	picture = CITY_VIEW_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = MLC
		religion_group = muslim
		is_year = 1460
		NOT = { is_year = 1500 }
	}

	mean_time_to_happen = {
		months = 120
	}
	
	
	option = { 
		name = flavor_mlc.4.a #Yes, in the name of Allah.
		add_piety = 0.1
		add_country_modifier = {
			name = mlc_islamic_laws_enforced
			duration = -1
		}
	}
	option = {
		name = flavor_mlc.4.b #No, let us keep with our old traditions.
		add_piety = -0.1
		add_stability_or_adm_power = yes
	}
}

# Customs and Duties
country_event = {
	id = flavor_mlc.5
	title = flavor_mlc.5.t
	desc = flavor_mlc.5.d
	picture = ECONOMY_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = MLC
		is_year = 1450
		NOT = { is_year = 1500 }
	}

	mean_time_to_happen = {
		months = 150
		modifier = {
			factor = 0.8
			has_country_modifier = mlc_tun_perak
		}
	}
	
	
	option = {
		name = flavor_mlc.5.a #Malacca has nothing of its own, and has everything of the world.
		add_years_of_income = -0.1
		add_country_modifier = {
			name = mlc_economic_boom
			duration = 3650
		}
	}
	option = {
		name = flavor_mlc.5.b #We cannot afford to lower these fees.
		add_years_of_income = 0.1
	}
}

# Hang Tuah
country_event = {
	id = flavor_mlc.6
	title = flavor_mlc.6.t
	desc = flavor_mlc.6.d
	picture = ECONOMY_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = MLC
		is_year = 1460
		NOT = { is_year = 1480 }
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	option = {
		name = flavor_mlc.6.a #May our people never vanish from this earth.
		define_admiral = {
			name = "Hang Tuah"
			shock = 5
			fire = 3
			manuever = 3
		}
	}
}

# Arrival of the Portuguese
country_event = {
	id = flavor_mlc.7
	title = flavor_mlc.7.t
	desc = flavor_mlc.7.d
	picture = HARBOUR_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = MLC
		exists = POR
		any_owned_province = {
			OR = {
				area = malaya_area
				area = malacca_area
			}
			has_discovered = POR
		}
	}

	mean_time_to_happen = {
		months = 12
	}
	
	
	option = {
		name = flavor_mlc.7.a #Lambaste the Gujaratis and attempt to save the situation.
		ai_chance = { factor = 0 }
		custom_tooltip = flavor_mlc.7.a.tt
		add_stability = -1
		POR = {
			add_casus_belli = {
				target = MLC
				type = cb_trade_war_triggered
				months = 24
			}
			country_event = { id = flavor_mlc.8 }
		}
	}
	
	option = {
		name = flavor_mlc.7.b #We must not allow the Portuguese to gain a hold in this part of the world.
		ai_chance = { factor = 1 }
		custom_tooltip = flavor_mlc.7.b.tt
		POR = {
			add_casus_belli = {
				target = MLC
				type = cb_trade_war_triggered
				months = 60
			}
			country_event = { id = flavor_mlc.8 }
		}
	}
}

country_event = {
	id = flavor_mlc.8
	title = flavor_mlc.8.t
	desc = flavor_mlc.8.d
	picture = ANGRY_MOB_eventPicture
	
	is_triggered_only = yes
	
	
	option = {
		name = flavor_mlc.8.a #Ok.
		ai_chance = { factor = 10 }
		tooltip = {
			add_casus_belli = {
				target = MLC
				type = cb_trade_war_triggered
				months = 24 #Not displayed in tooltip.
			}
		}
	}
}

# Pick a name and capital for Malaya
country_event = {
	id = flavor_mlc.9
	title = flavor_mlc.9.t
	desc = flavor_mlc.9.desc
	picture = ANGRY_MOB_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = flavor_mlc.9.a
		trigger = {
			dynasty = "000000000"
		}
		override_country_name = SRIVIJAYA
		set_country_flag = is_srijivaya_flag
		ai_chance = {
			factor = 1000
		}
	}
	option = {
		name = flavor_mlc.9.b
		trigger = {
			primary_culture = javanese
		}
		override_country_name = MAJAPAHIT_EMPIRE
		set_country_flag = is_majapahit_empire_flag
		ai_chance = {
			factor = 100
		}
	}
	option = {
		name = flavor_mlc.9.c
		override_country_name = NUSANTARA
		set_country_flag = is_nusantara_flag
		ai_chance = {
			factor = 5
		}
	}
	option = {
		name = flavor_mlc.9.d
		ai_chance = {
			factor = 1
		}
	}
}
