namespace = ate_advisor_plantation_owner_events

country_event = {
	id = ate_advisor_plantation_owner_events.1
	title = ate_advisor_plantation_owner_events.EVTNAME1
	desc = ate_advisor_plantation_owner_events.EVTDESC1
	picture = ADVISOR_eventPicture

	is_triggered_only = yes

	trigger = {
		num_of_cities = 2
		NOT = { advisor = ate_advisor_plantation_owner }
		any_owned_province = {
			is_capital = no
			is_overseas = no
			has_manufactory_trigger = yes
			NOT = { has_province_modifier = ate_advisor_plantation_owner_province_modifier }
			OR = {
				trade_goods = grain
				trade_goods = wine
				trade_goods = tea
				trade_goods = spices
				trade_goods = coffee
				trade_goods = cotton
				trade_goods = sugar
				trade_goods = tobacco
				trade_goods = cocoa
				trade_goods = incense
				trade_goods = cloves
				AND = {
					is_expanded_mod_active = { mod = trade_goods }
					OR = {
						trade_goods = palm_oil
						trade_goods = cinnamon
						trade_goods = saffron
						trade_goods = rice
						trade_goods = opium
						trade_goods = olive_oil
						trade_goods = citrus
						trade_goods = nutmeg
						trade_goods = maize
						trade_goods = vanilla
						trade_goods = potato
						trade_goods = tomato
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		hidden_effect = {
			random_owned_province = {
				limit = {
					is_capital = no
					is_overseas = no
					has_manufactory_trigger = yes
					NOT = { has_province_modifier = ate_advisor_plantation_owner_province_modifier }
					OR = {
						trade_goods = grain
						trade_goods = wine
						trade_goods = tea
						trade_goods = spices
						trade_goods = coffee
						trade_goods = cotton
						trade_goods = sugar
						trade_goods = tobacco
						trade_goods = cocoa
						trade_goods = incense
						trade_goods = cloves
						AND = {
							is_expanded_mod_active = { mod = trade_goods }
							OR = {
								trade_goods = palm_oil
								trade_goods = cinnamon
								trade_goods = saffron
								trade_goods = rice
								trade_goods = opium
								trade_goods = olive_oil
								trade_goods = citrus
								trade_goods = nutmeg
								trade_goods = maize
								trade_goods = vanilla
								trade_goods = potato
								trade_goods = tomato
							}
						}
					}
				}
				save_event_target_as = advisor_province
				ROOT = {
					set_saved_name = {
						key = local_ate_advisor_plantation_owner
						type = advisor
						scope = PREV
					}
				}
			}
		}
	}

	option = {
		name = ate_advisor_plantation_owner_events1.EVTOPT1

		ai_chance = { factor = 0.4 }

		add_meritocracy_effect = yes
		define_advisor = {
			name = local_ate_advisor_plantation_owner
			type = ate_advisor_plantation_owner
			skill = 2
			discount = yes
			female = no
			religion = event_target:advisor_province
			culture = event_target:advisor_province
			location = event_target:advisor_province
		}
	}

	option = {
		name = ate_advisor_plantation_owner_events1.EVTOPT2

		goto = advisor_province

		ai_chance = { factor = 0.6 }

		event_target:advisor_province = {
			add_province_modifier = {
				name = ate_advisor_plantation_owner_province_modifier
				duration = -1
			}
		}
	}

	option = {
		name = ate_advisor_plantation_owner_events1.EVTOPT3

		highlight = yes

		trigger = {
			ruler_has_personality_ancestor = { key = well_connected }
		}

		ai_chance = { factor = 100 }

		add_meritocracy_effect = yes
		define_advisor = {
			name = local_ate_advisor_plantation_owner
			type = ate_advisor_plantation_owner
			skill = 3
			discount = yes
			female = no
			religion = event_target:advisor_province
			culture = event_target:advisor_province
			location = event_target:advisor_province
		}
	}

	after = {
		clear_saved_name = local_ate_advisor_plantation_owner
	}
}