#######################################
#
# Roman Events
#
# Event ID LoR.1 - LoR.199 reserved
# Event ID LoR.1200 - Lor.1201 reserved
#
#######################################

# Written by Henrik Eklund

namespace = LoR

### Lost Roman Provinces
### WARNING: completely_controls is a very demanding trigger

# Provincia Syria Palaestina
narrative_event = {
	id = LoR.1
	title = EVTNAMELoR.1
	desc = EVTDESCLoR.1
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Aegyptus
narrative_event = {
	id = LoR.2
	title = EVTNAMELoR.2
	desc = EVTDESCLoR.2
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Doesn 't fit in with CK2Plus provincia titles
# Provincia Cyrenaica et Creta
# narrative_event = {
# 	id = LoR.3
# 	title = EVTNAMELoR.3
# 	desc = EVTDESCLoR.3
# 	picture = GFX_evt_victory_arch_byzantine
#
# 	only_independent = yes
# 	has_dlc = "Legacy of Rome"
#
# 	trigger = {
# 		OR = {
# 			has_landed_title = e_byzantium
# 			has_landed_title = e_roman_empire
# 		}
#
# 		is_alternate_start = no
# 		NOT = { has_global_flag = cyrenaica }
#
# 		OR = {
# 			religion_group = christian
# 			religion_openly_hellenic_or_reformed_trigger = yes
# 		}
#
# 		## k_africa
# 		completely_controls = d_cyrenaica
# 		completely_controls = d_krete
# 	}
#
# 	mean_time_to_happen = {
# 		days = 1
# 	}
#
# 	immediate = {
# 		set_global_flag = cyrenaica
# 	}
#
# 	option = {
# 		name = EVTOPTALoR.1
#
# 		prestige = 50
# 	}
# }

# Provincia Africa
narrative_event = {
	id = LoR.4
	title = EVTNAMELoR.4
	desc = EVTDESCLoR.4
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Illyricum
narrative_event = {
	id = LoR.5
	title = EVTNAMELoR.5
	desc = EVTDESCLoR.5
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Italia
narrative_event = {
	id = LoR.6
	title = EVTNAMELoR.6
	desc = EVTDESCLoR.6
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Gallia
narrative_event = {
	id = LoR.7
	title = EVTNAMELoR.7
	desc = EVTDESCLoR.7
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Germania
narrative_event = {
	id = LoR.8
	title = EVTNAMELoR.8
	desc = EVTDESCLoR.8
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Britannia
narrative_event = {
	id = LoR.9
	title = EVTNAMELoR.9
	desc = EVTDESCLoR.9
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Hispania
narrative_event = {
	id = LoR.10
	title = EVTNAMELoR.10
	desc = EVTDESCLoR.10
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Mauretania
narrative_event = {
	id = LoR.11
	title = EVTNAMELoR.11
	desc = EVTDESCLoR.11
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Mesopotamia
narrative_event = {
	id = LoR.12
	title = EVTNAMELoR.12
	desc = EVTDESCLoR.12
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Caledonia
narrative_event = {
	id = LoR.13
	title = EVTNAMELoR.13
	desc = EVTDESCLoR.13
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

# Provincia Hibernia
narrative_event = {
	id = LoR.14
	title = EVTNAMELoR.14
	desc = EVTDESCLoR.14
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.1
	}
}

### Roman Empire Restored

# The Restoration of Rome
narrative_event = {
	id = LoR.20
	title = EVTNAMELoR.20
	picture = GFX_evt_rome_restored_byzantine

	desc = {
		text = EVTDESCLoR.20
		trigger = { is_alternate_start = no }
	}
	desc = {
		text = EVTDESCLoR20_HF
		trigger = { is_alternate_start = yes }
	}

	is_triggered_only = yes # restore_roman_empire, realm_decisions.txt

	immediate = {
		set_global_flag = rome_restored

		if = {
			limit = {
				ai = no
				is_ironman = yes
			}

			set_character_flag = achievement_legacy_of_rome
		}

		primary_title = {
			any_direct_de_jure_vassal_title = {
				de_jure_liege = e_roman_empire
			}

			e_roman_empire = {
				set_title_flag = non_manual_law_change # No prestige loss
				copy_title_laws = PREV
				copy_title_history = PREV
				grant_title = ROOT
				make_primary_title = yes
				clr_title_flag = non_manual_law_change # No prestige loss
			}

			destroy_landed_title = THIS

			activate_title = {
				title = THIS
				status = no
			}
		}

		any_player = {
			limit = {
				NOT = { character = ROOT }
			}

			narrative_event = { id = LoR.21 }
		}

		if = { # Hellenic Resurgence
			limit = {
				has_dlc = "Holy Fury"
				religion_group = christian

				has_game_rule = {
					name = hellenism_rule
					value = on
				}

				OR = {
					culture = greek
					culture = italian
					culture = roman
				}
			}

			character_event = {
				id = HF.23106
				days = 15
			}
		}

		if = { # Burn and Rebuild Rome
			limit = {
				has_dlc = "Holy Fury"

				c_roma = {
					location = {
						# Check if Gengis Khan or whomever hasn't already leveled the place
						any_province_holding = {
							holding_type = temple
							count >= 2
						}
					}
				}
			}

			c_roma = { # Ping by province to ensure event fires in case the emperor dies in the meantime
				location = {
					province_event = {
						id = HF.23100
						days = 155
					}
				}
			}
		}

		any_title = {
			limit = {
				real_tier = EMPEROR

				OR = {
					has_title_flag = eastern_roman_successor
					has_title_flag = western_roman_successor
				}
			}

			clr_title_flag = eastern_roman_successor
			clr_title_flag = western_roman_successor
		}

		clr_global_flag = east_rome_lives
		clr_global_flag = west_rome_lives
	}

	option = {
		name = EVTOPTALoR.20

		tooltip = {
			grant_title = e_roman_empire
		}

		add_trait = augustus
		give_nickname = nick_the_glorious

		if = { # New Imperial Bloodline
			limit = {
				has_dlc = "Holy Fury"
				is_alternate_start = no

				OR = {
					religion_group = christian
					religion_openly_hellenic_or_reformed_trigger = yes
				}

				NOT = {
					any_owned_bloodline = {
						has_bloodline_flag = roman_bloodline # Not if already member of a famous historical Roman Bloodline
						bloodline_is_active_for = PREV
					}
				}
			}

			if = {
				limit = { is_female = no }

				create_bloodline = {
					type = roman_emperor_male
				}
			}
			else = {
				create_bloodline = {
					type = roman_emperor_female
				}
			}

			new_bloodline = {
				set_description = bloodline_desc_roman
			}

			sound_effect = bloodline_added
		}
	}
}

# Informed about Restoration of Rome
narrative_event = {
	id = LoR.21
	title = EVTNAMELoR.21
	picture = GFX_evt_rome_restored_byzantine

	desc = {
		text = EVTDESCLoR.21
		trigger = { is_alternate_start = no }
	}
	desc = {
		text = EVTDESCLoR21_HF
		trigger = { is_alternate_start = yes }
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.21

		trigger = {
			primary_title = {
				NOR = {
					has_title_flag = eastern_roman_successor
					has_title_flag = western_roman_successor
				}
			}
		}
	}

	option = {
		name = EVTOPTBLoR.21

		trigger = {
			primary_title = {
				OR = {
					has_title_flag = eastern_roman_successor
					has_title_flag = western_roman_successor
				}
			}
		}
		prestige = -500
	}
}

### Victory Triumphs

# Triumph Expected
character_event = {
	id = LoR.30
	desc = EVTDESCLoR.30
	picture = GFX_evt_victory_arch_byzantine

	hide_from = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			has_landed_title = e_byzantium
			has_landed_title = e_roman_empire

			trigger_if = {
				limit = { independent = yes }

				higher_real_tier_than = COUNT

				OR = {
					culture = roman
					religion_openly_hellenic_or_reformed_trigger = yes
				}
			}
		}

		OR = {
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}
	}

	option = {
		name = EVTOPTALoR.30

		character_event = {
			id = LoR.31
			days = 12
			tooltip = EVTTOOLTIPLoR.31
		}

		scaled_wealth = -0.3
		prestige = 75
	}

	option = {
		name = EVTOPTBLoR.30

		scaled_wealth = -0.1
		prestige = 25
	}

	option = {
		name = EVTOPTCLoR.30

		prestige = -30
	}
}

# Triumph Held
character_event = {
	id = LoR.31
	desc = EVTDESCLoR.31
	picture = GFX_evt_victory_arch_byzantine

	hide_from = yes
	is_triggered_only = yes

	option = {
		name = EVTOPTALoR.31

		custom_tooltip = {
			text = triumph_held

			any_realm_lord = {
				limit = {
					higher_real_tier_than = BARON
					NOT = { character = ROOT }
				}

				opinion = {
					name = opinion_triumph_held
					who = ROOT
				}

				character_event = { id = LoR.32 }
			}
		}
	}
}

# Triumph Held Vassals
character_event = {
	id = LoR.32
	desc = EVTDESCLoR.32
	picture = GFX_evt_victory_arch_byzantine

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTALoR.32
	}
}

### Roman Borders Restored

# Roman Borders
narrative_event = {
	id = LoR.40
	title = EVTNAMELoR.40
	picture = GFX_evt_rome_restored_byzantine

	desc = {
		text = EVTDESCLoR.40
		trigger = { religion_group = christian }
	}
	desc = {
		text = EVTDESCLoR40_HELLENIC
		trigger = { religion_openly_hellenic_or_reformed_trigger = yes }
	}
	#desc = {
	#	text = EVTDESCLoR40_GENERIC
	#	trigger = {
	#		NOT = { religion_group = christian }
	#		religion_openly_hellenic_or_reformed_trigger = no
	#	}
	#}

	only_independent = yes
	has_dlc = "Legacy of Rome"

	trigger = {
		OR = {
			has_landed_title = e_byzantium
			has_landed_title = e_roman_empire
		}

		is_alternate_start = no
		NOT = { has_global_flag = roman_borders }

		OR = {
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}

		# Provincia Britannia
		completely_controls_region = custom_england
		completely_controls_region = custom_wales

		# Provincia Italia
		completely_controls_region = world_europe_south_italy

		# Provincia Syria Palaestina
		completely_controls_region = world_middle_east_jerusalem

		# Provincia Aegyptus
		completely_controls_region = custom_egypt

		# Provincia Africa
		completely_controls_region = custom_africa

		# Provincia Illyricum
		completely_controls_region = custom_bulgaria
		completely_controls_region = custom_serbia
		completely_controls_region = custom_croatia

		# Provincia Viennensis
		completely_controls_region = custom_aquitaine

		# Provincia Gallia
		completely_controls_region = custom_france

		# Provincia Hispania
		completely_controls_region = world_europe_west_iberia

		# Provincia Mauretania
		completely_controls_region = custom_morocco

		# Provincia Macedonia
		completely_controls_region = custom_byzantium

		# Provincia Asia
		completely_controls_region = custom_nikaea

		# Provincia Pontus
		completely_controls_region = custom_trebizond
		completely_controls = d_coloneia
		completely_controls = d_mesopotamia
		completely_controls = d_cilicia

		# Provincia Pannonia-Dacia
		completely_controls_region = custom_carpathia
		completely_controls_region = custom_wallachia

		# Provincia Armenia
		completely_controls = d_armenia
		completely_controls = d_kartli
	}

	mean_time_to_happen = {
		days = 1
	}

	immediate = {
		set_global_flag = roman_borders

		if = {
			limit = {
				ai = no
				is_ironman = yes
			}

			set_character_flag = achievement_spqr
		}
	}

	option = {
		name = EVTOPTALoR.40

		prestige = 1000
	}
}

### The Augustus Trait

# Augustus Trait Gained
character_event = {
	id = LoR.45
	picture = GFX_evt_rome_restored_byzantine

	desc = {
		text = EVTDESCLoR.45
		trigger = { is_alternate_start = no }
	}
	desc = {
		text = EVTDESCLoR45_HF
		trigger = { is_alternate_start = yes }
	}

	is_triggered_only = yes # on_five_year_pulse and on_new_holder

	only_independent = yes
	has_global_flag = rome_restored
	has_dlc = "Legacy of Rome"

	trigger = {
		has_landed_title = e_roman_empire
		NOT = { trait = augustus }
	}

	option = {
		name = EVTOPTALoR.45

		add_trait = augustus
	}
}

# Augustus Trait Lost
character_event = {
	id = LoR.46
	desc = EVTDESCLoR.46
	picture = GFX_evt_rome_restored_byzantine

	is_triggered_only = yes # on_yearly_pulse

	has_dlc = "Legacy of Rome"
	has_global_flag = rome_restored

	trigger = {
		trait = augustus
		NOT = { has_landed_title = e_roman_empire }
	}

	option = {
		name = EVTOPTALoR.46

		remove_trait = augustus
	}
}

# Augustus Trait inheritance
character_event = {
	id = LoR.47

	is_triggered_only = yes # on_death
	hide_window = yes

	only_independent = yes
	has_global_flag = rome_restored
	has_dlc = "Legacy of Rome"

	trigger = {
		has_landed_title = e_roman_empire
	}

	immediate = {
		e_roman_empire = {
			current_heir = {
				character_event = {
					id = LoR.45
					days = 2
				}
			}
		}
	}
}

# Augustus Trait inheritance
character_event = {
	id = LoR.48

	is_triggered_only = yes # on_new_holder_usurpation
	hide_window = yes

	only_playable = yes
	has_global_flag = rome_restored
	has_dlc = "Legacy of Rome"

	trigger = {
		FROM = { title = e_roman_empire }
		NOT = { trait = augustus }
	}

	immediate = {
		character_event = {
			id = LoR.45
			days = 2
		}
	}
}