namespace = ancrel

##############################################
#
# Ancient Religions Reborn
# - Lets. Get. PAGAN! Events
#
# Event Ids: ancrel.9001 - 9100 reserved
##############################################

# the pope pagans up the world
character_event = {
	id = ancrel.9001
	desc = ancrel.9001.desc
	picture = GFX_evt_Pagan_dolmen
	is_triggered_only = yes

	trigger = {
		NOT = { has_global_flag = acr_paganify }
	}

	immediate = {
		set_global_flag = acr_paganify
		character_event = { id = ancrel.9014 days = 1 }
	}

	option = {
		name = ancrel.9001.a
		any_independent_ruler = {
			any_realm_character = {
				if = { # Celtic
					limit = {
						NOT = { religion_group = pagan_group }
						OR = {
							culture_group = celtic
							culture_group = iberian
							culture_group = west_germanic
							culture = occitan
							culture = frankish
							culture = norman
						}
					}
					character_event = { id = ancrel.9002 }
				}
				if = { # Hellenic
					limit = {
						NOT = { religion_group = pagan_group }					
						OR = {
							culture_group = byzantine
							culture = italian
						}

					}
					character_event = { id = ancrel.9003 }
				}
				if = { # Titan
					limit = {
						culture = alan
					}
					character_event = { id = ancrel.9012 }
				}
				if = { # Kemetic
					limit = {
						NOT = { religion_group = pagan_group }					
						OR = {
							culture = bedouin_arabic
							culture = levantine_arabic
							culture = egyptian_arabic
							culture_group = east_african
						}
					}
					character_event = { id = ancrel.9004 }
				}
				if = { # West African
					limit = {
						NOT = { religion_group = pagan_group }					
						OR = {
							culture = maghreb_arabic
							culture = andalusian_arabic
							culture_group = west_african
						}
					}
					character_event = { id = ancrel.9005 }
				}
				if = { # Slavic
					limit = {
						NOT = { religion_group = pagan_group }					
						OR = {
							culture_group = west_slavic
							culture_group = east_slavic
							culture_group = south_slavic
						}
					}
					character_event = { id = ancrel.9006 }
				}
				if = { # Norse
					limit = {
						NOT = { religion_group = pagan_group }					
						OR = {
							culture_group = north_germanic
							culture_group = central_germanic
						}
					}
					character_event = { id = ancrel.9007 }					
				}
				if = { # Zoroastrian
					limit = {
						NOT = { religion_group = pagan_group }					
						culture_group = iranian
					}
					character_event = { id = ancrel.9008 }
				}
				if = { # Tengri
					limit = {
						NOT = { religion_group = pagan_group }
						OR = {
							culture_group = altaic
							culture_group = magyar
						}
					}
					character_event = { id = ancrel.9009 }
				}
				if = { # Religious heads (not the pope)
					limit = {
						controls_religion = yes
					}
					character_event = { id = ancrel.9014 }
				}
			}
		}
	}
}

# Celtic
character_event = {
	id = ancrel.9002
	desc = ancrel.9002.desc
	picture = GFX_evt_Pagan_dolmen
	is_triggered_only = yes
	hide_from = yes
	
	option = {
		name = OK
		religion = celtic_pagan
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = celtic_pagan }
		}
	}
}

# Hellenic
character_event = {
	id = ancrel.9003
	desc = ancrel.9003.desc
	picture = GFX_evt_roman_temple
	is_triggered_only = yes
	hide_from = yes

	option = {
		name = OK
		religion = hellenic_pagan
		if = {
			limit = {
				d_galilee = {
					holder_scope = {
						character = ROOT
					}
				}
			}
			remove_trait = eunuch
		}
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = hellenic_pagan }
		}
	}
}

# Kemetic
character_event = {
	id = ancrel.9004
	desc = ancrel.9004.desc
	picture = GFX_evt_temple_egyptian_pagan
	is_triggered_only = yes
	hide_from = yes

	option = {
		name = OK
		religion = egyptian_pagan
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = egyptian_pagan }
		}
	}
}

# West African
character_event = {
	id = ancrel.9005
	desc = ancrel.9005.desc
	picture = GFX_evt_desert
	is_triggered_only = yes
	hide_from = yes

	option = {
		name = OK
		religion = west_african_pagan
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = west_african_pagan }
		}
	}
}

# Slavic
character_event = {
	id = ancrel.9006
	desc = ancrel.9006.desc
	picture = GFX_evt_cathedral_norse_pagan
	is_triggered_only = yes
	hide_from = yes

	option = {
		name = OK
		religion = slavic_pagan
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = slavic_pagan }
		}
	}
}

# Norse
character_event = {
	id = ancrel.9007
	desc = ancrel.9007.desc
	picture = GFX_evt_cathedral_norse_pagan
	is_triggered_only = yes
	hide_from = yes

	option = {
		name = OK
		religion = norse_pagan
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = norse_pagan }
		}
	}
}

# Zoroastrian
character_event = {
	id = ancrel.9008
	desc = ancrel.9008.desc
	picture = GFX_evt_marriage_zoroastrian_group
	is_triggered_only = yes
	hide_from = yes

	option = {
		name = OK
		religion = zoroastrian
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = zoroastrian }
		}
	}
}

# Tengri
character_event = {
	id = ancrel.9009
	desc = ancrel.9009.desc
	picture = "GFX_evt_mongols"
	border = "GFX_event_normal_frame_war"

	is_triggered_only = yes
	hide_from = yes

	option = {
		name = OK
		religion = tengri_pagan
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = tengri_pagan }
		}
	}
}

#[on_startup] maintenance event
character_event = {
	id = ancrel.9010
	hide_window = yes

	is_triggered_only = yes

	ai = no
	
	trigger = {
		NOT = { has_global_flag = ancrel }
	}

	immediate = {
		set_global_flag = ancrel
	}
}

# Titan
character_event = {
	id = ancrel.9012
	desc = ancrel.9012.desc
	picture = GFX_evt_cathedral_norse_pagan
	hide_from = yes

	is_triggered_only = yes

	option = {
		name = OK
		religion = titan_pagan
		any_demesne_title = {
			limit = { tier = count }
			location = { religion = promethean_pagan }
		}
	}
}

# free a religious head's vassals count and above
character_event = {
	id = ancrel.9014
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		any_vassal = {
			limit = {
				primary_title = {
					higher_tier_than = BARON
				}
			}
			set_defacto_liege = THIS
		}
	}
}

##############################################
#
# Ancient Religions Reborn
# - Debugging Events
#
# Event Ids: ancrel.9001 - 9100 reserved
##############################################

# set the ancrel_debug global flag for testing
# some events and decisions may check this flag
# and alter their behavior to make testing easier
character_event = {
	id = ancrel.9015
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		set_global_flag = ancrel_debug
	}
}

# debugging event to end all wars
character_event = {
	id = ancrel.9016
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		any_war = {
			end_war = whitepeace
		}
	}
}

# Arriving for the great holy war - Non-Hellenic Ancient Religions
character_event = {
	id = ancrel.9017
	desc = EVTDESC8300
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war
	
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_crusade_trait_trigger = no
		in_command = yes
		is_ancient_religion_trigger = yes
		religion_openly_hellenic_or_reformed_trigger = no # vanilla event covers hellenic
		OR = {
			AND = {
				any_war = {
					using_cb = crusade
				}
				crusade_target = {
					is_located_in = ROOT
				}
			}
			any_liege = {
				religion = ROOT
				any_war = {
					using_cb = crusade
				}
				crusade_target = {
					is_located_in = ROOT
				}
			}
		}
	}

	mean_time_to_happen = {
		days = 1
	}
	
	option = {
		name = 8469.a
		trigger = {
			religion_openly_in_celtic_subgroup_trigger = yes
		}
		add_trait = lughs_own
	}

	option = {
		name = 8469.a
		trigger = {
			religion = egyptian_pagan
		}
		add_trait = montu
	}

	option = {
		name = 8469.a
		trigger = {
			religion = aten_pagan
		}
		add_trait = atens_chosen
	}

	option = {
		name = 8469.a
		trigger = {
			NOR = {
				religion_openly_in_celtic_subgroup_trigger = yes
				religion = aten_pagan
				religion = egyptian_pagan
			}
		}
	}
}

# debug to grant all provinces in your dejure kingdom to you, including the king title
character_event = {
	id = ancrel.9020
	hide_window = yes
	
	is_triggered_only = yes
	
	has_global_flag = ancrel_debug

	immediate = {
		capital_scope = {
			kingdom = {
				save_event_target_as = ancrel_title_grant
				ROOT = { 
					grant_title_no_opinion = PREV
				}
			}
		}
	}
	
	after = {
		any_independent_ruler = {
			limit = {
				de_jure_liege_or_above = event_target:ancrel_title_grant
			}
			any_realm_province = {
				county = {
					ROOT = { 
						usurp_title = PREV
					}
				}
			}
		}
	}
}

# debug to grant you the de jure empire of your capital and vassalize de jure vassals
character_event = {
	id = ancrel.9021
	hide_window = yes

	is_triggered_only = yes
	
	has_global_flag = ancrel_debug

	immediate = {
		capital_scope = {
			empire = {
				save_event_target_as = ancrel_title_grant
				ROOT = { 
					grant_title_no_opinion = PREV
				}
			}
		}
	}
	
	after = {
		any_independent_ruler = {
			limit = {
				de_jure_liege_or_above = event_target:ancrel_title_grant
			}
			set_defacto_liege = ROOT
		}
	}
}

# debug to convert all characters and provinces in your realm to your religion and culture
character_event = {
	id = ancrel.9022
	hide_window = yes

	is_triggered_only = yes

	
	has_global_flag = ancrel_debug

	immediate = {
		any_realm_character = {
			religion = ROOT
			culture = ROOT
		}

		any_realm_province = {
			religion = ROOT
			culture = ROOT
		}
	}
}

# migration event, fired [on_start], smooths over issues with save files between versions
character_event = {
	id = ancrel.9023
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		NOT = { has_global_flag = ancrel_sequana }
	}

	immediate = {
		set_global_flag = ancrel_sequana
		if = {
			limit = {
				has_global_flag = celtic_reformation
			}

			any_mercenary_band = {
				limit = {
					holy_order = yes
					holder_scope = { religion = celtic_pagan }
				}

				religion = celtic_pagan_reformed
			}
		}
		if = {
			limit = {
				has_global_flag = egyptian_reformation
			}

			any_mercenary_band = {
				limit = {
					holy_order = yes
					holder_scope = { religion = egyptian_pagan }
				}

				religion = egyptian_pagan_reformed
			}
		}
		if = {
			limit = {
				has_global_flag = hellenic_reformation
			}

			any_mercenary_band = {
				limit = {
					holy_order = yes
					holder_scope = { religion = hellenic_pagan }
				}

				religion = hellenic_pagan_reformed
			}
		}
	}
}
