﻿namespace = balkan_flavour


# Pannonian Things
# balkan_flavour.0001-0009													

# Savia to Slavonia
balkan_flavour.0001 = {
	type = character_event
	title = balkan_flavour.0001.t
	desc = balkan_flavour.0001.desc
	theme = realm
	override_background = { reference = farmland }
	left_portrait = {
		character = root
		animation = personality_rational
	}
	
	immediate = {
		
		hidden_effect = {
		
			culture:slavonian = {
				set_culture_name = {
                    noun = n_slavonian_noun
                    collective_noun = n_slavonian_collective_noun
                    prefix = n_slavonian_prefix
                }
			}
			
			title:d_slavonia = {
				set_title_name = d_slavonia_original
			}
			
		}
		
	}
	
	option = { # idk
		name = balkan_flavour.0001.a
	}
	
}


# Dissolve Biohrad (Mostly for compatibility reasons, might yeet this later)
balkan_flavour.0002 = {
	scope = none
	hidden = yes

	immediate = {
	
		every_held_title = {
			limit = {
				tier = tier_duchy
				this = title:d_szekesfehervar
			}
			scope:ruler = {
				destroy_title = prev
			}
		}
	
		title:c_szekesfehervar = {
			set_de_jure_liege_title = title:d_visegrad
		}
		title:c_esztergom = {
			set_de_jure_liege_title = title:d_visegrad
		}
		title:c_komarom = {
			set_de_jure_liege_title = title:d_visegrad
		}
		title:c_veszprem = {
			set_de_jure_liege_title = title:d_gyor
		}
	}
}

##### MAGYAR EVENTS #####

# The Arrival of the Magyars
balkan_flavour.0003 = {
	scope = none
 	hidden = yes
	
	immediate = {
		if = {
			limit = {
				title:d_slavonia = { is_title_created = yes }
			}
			title:d_slavonia.holder = {
				trigger_event = {
					id = balkan_flavour.0001
					days = { 365 3650 }
				}
			}
		}
		else_if = {
			limit = {
				title:d_slavonia = { is_title_created = no }
			}
			hidden_effect = {
				culture:slavonian = {
					set_culture_name = {
						noun = n_slavonian_noun
						collective_noun = n_slavonian_collective_noun
						prefix = n_slavonian_prefix
					}
				}
			
				title:d_slavonia = {
					set_title_name = d_slavonia_original
				}
			}
		}
		trigger_event = {
		 	id = balkan_culture.0003
		}
	}

}


##### DYNAMIC PANNONIAN ROMANCE EVENTS #####

scripted_trigger pannonian_romance_community_trigger = {
	tier = tier_county
	exists = holder
	title_province = {
		geographical_region = ce_custom_transdanubia
		OR = {
			culture = culture:dudlebian
			culture = culture:blatno_slavic
			culture = culture:pannonian
			culture = culture:pannonian_romance
		}
	}
}

# Whispers of an ancient town
balkan_flavour.0004 = {
	type = character_event
	title = balkan_flavour.0004.t
	desc = balkan_flavour.0004.desc
	theme = realm
	override_background = { reference = throne_room_west }
	
	left_portrait = {
		character = root
		animation = personality_rational
	}
	
	trigger = {
		ce_balkan_romance_region_trigger = yes
		NOT = { culture = culture:pannonian_romance }
		any_held_title = {
			pannonian_romance_community_trigger = yes
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_character_flag = ce_balkan_romance_already_spawned_guest
		}
		modifier = {
			add = -0.25
			AND = {
				is_ruler = yes
				has_government = tribal_government
			}
		}
	}
	
	option = { # Nice
		name = balkan_flavour.0004.a
		trigger_event = {
			id = balkan_flavour.0005
			days = { 5 10 }
		}
	}
	
	option = { # I don't want this
		name = balkan_flavour.0004.b
	}

}

# Pannonian Romance guest shows up at court
balkan_flavour.0005 = {
	type = character_event
	title = balkan_flavour.0005.t
	desc = balkan_flavour.0005.desc	
	theme = realm
	override_background = { reference = throne_room_west }
	
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:ce_pannonian_romance_guest_spawn
		animation = beg
	}

	immediate = {
		capital_province = { save_scope_as = capital_province } #For loc.
		add_character_flag = ce_balkan_romance_already_spawned_guest
		create_character = {
			location = root.location
			#template = wip
			gender = male
			save_scope_as = ce_pannonian_romance_guest_spawn
			culture = culture:pannonian_romance
			faith = faith:catholic
		}
	}

	# Wonderful
	option = {
		name = balkan_flavour.0005.a
		trigger = {
			can_start_scheme = {
				type = learn_language
				target_character = scope:ce_pannonian_romance_guest_spawn
			}
			scope:ce_pannonian_romance_guest_spawn.culture = {
				NOT = { has_same_culture_language = root.culture }
			}
		}
		add_courtier = scope:ce_pannonian_romance_guest_spawn
		start_scheme = {
			type = learn_language
			target_character = scope:ce_pannonian_romance_guest_spawn
		}
	}
	
	# Okay
	option = {
		name = balkan_flavour.0005.b
		add_courtier = scope:ce_pannonian_romance_guest_spawn
	}

	# Not interested
	option = {
		name = balkan_flavour.0005.c
		hidden_effect = {
			scope:ce_pannonian_romance_guest_spawn = {
				death = {
					death_reason = death_disappearance
				}
			}
		}
	}
}
