namespace = regula_holy_site_event

# Decision point for demigod.
regula_holy_site_event.1001 = {
	type = character_event
	title = regula_holy_site_event.1001.t
	
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = {
						controls_holy_site = reg_gotland
					}
				}
				desc = regula_holy_site_event.1001.european
			}
			triggered_desc = {
				trigger = {
					faith = {
						controls_holy_site = reg_carthage
					}
				}
				desc = regula_holy_site_event.1001.mediterranean
			}
			triggered_desc = {
				trigger = {
					faith = {
						controls_holy_site = reg_yazd
					}
				}
				desc = regula_holy_site_event.1001.alexandrian
			}
			triggered_desc = {
				trigger = {
					faith = {
						controls_holy_site = reg_jara
					}
				}
				desc = regula_holy_site_event.1001.west_africa
			}
		}
	}
	
	theme = regula_theme
	override_background = {
		event_background = throne_room  
	}
	right_portrait = { 
		character = scope:recipient
		animation = personality_content
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	option = { # Go ahead with it
		name = regula_holy_site_event.1001.a 
		trigger_event = {
			id = regula_holy_site_event.1002
			days = { 15 45 }
		}
	}

	option = { # Abort
		name = regula_holy_site_event.1001.b 

		remove_variable = regula_sanctifica_serva_in_progress
	}
}

# Preparations complete
regula_holy_site_event.1002 = {
	type = character_event
	title = regula_holy_site_event.1002.t
	desc = regula_holy_site_event.1002.desc
	theme = regula_theme
	override_background = {
		event_background = regula_ritual_site  ### UPDATE - Ritual site. Thomas chapel or Max procession?
	}
	right_portrait = { ### UPDATE - Need new poses
		character = scope:recipient
		animation = none
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	option = { # Go ahead with it
		name = regula_holy_site_event.1002.a 

		add_piety = -750

		remove_variable = regula_sanctifica_serva_in_progress

		add_character_modifier = {
			modifier = regula_sanctifica_serva_penalty
		}
		scope:recipient = {
			add_diplomacy_skill =5 
			add_martial_skill = 5
			add_stewardship_skill = 5
			add_intrigue_skill = 5
			add_learning_skill = 5
			add_prowess_skill = 10
			add_trait = regula_undying
			hidden_effect = {
				set_immortal_age = 25
			}
		}
		
		trigger_event = {
			id = regula_holy_site_event.1003
		}
	}

	option = { # Abort
		name = regula_holy_site_event.1002.b
		remove_variable = regula_sanctifica_serva_in_progress
		add_prestige = -250 
	}
}

regula_holy_site_event.1003 = {  ### UPDATE - Sound: Verdi Requiem, Dies irae  https://youtu.be/ZDFFHaz9GsY?t=30
	type = character_event
	title = regula_holy_site_event.1003.t
	desc = {
		desc = regula_holy_site_event.1003.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = {
						highest_skill = diplomacy
					}
				}
				desc = regula_holy_site_event.1003.desc.diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:recipient = {
						highest_skill = martial
					}
				}
				desc = regula_holy_site_event.1003.desc.martial
			}
			triggered_desc = {
				trigger = {
					scope:recipient = {
						highest_skill = stewardship
					}
				}
				desc = regula_holy_site_event.1003.desc.stewardship
			}
			triggered_desc = {
				trigger = {
					scope:recipient = {
						highest_skill = intrigue
					}
				}
				desc = regula_holy_site_event.1003.desc.intrigue
			}
			triggered_desc = {
				trigger = {
					scope:recipient = {
						highest_skill = learning
					}
				}
				desc = regula_holy_site_event.1003.desc.learning
			}
		}
	}

	theme = regula_theme

	override_background = { ### UPDATE - Depending on how the triggered desc work these may have to be arranged back to front.
		trigger = {	
			scope:recipient = {
				highest_skill = diplomacy
			}
		}
		event_background = regula_goddess_diplomacy # bastien-grivet-thenaiade-sd - pallet switch to red?
	}

	override_background = {
		trigger = {	
			scope:recipient = {
				highest_skill = martial
			}
		}
		event_background = regula_goddess_martial # SamWhiteArt - Black angel
	}

	override_background = {
		trigger = {	
			scope:recipient = {
				highest_skill = stewardship
			}
		}
		event_background = regula_goddess_stewardship # eduardo-pena-2-bird-goddess - forehead has Isis symbol.  OR ilya-vatutin-shailen-keeper-of-the-way
	}

	override_background = {
		trigger = {	
			scope:recipient = {
				highest_skill = intrigue
			}
		}
		event_background = regula_goddess_intrigue # nina-is-curse-us
	}

	override_background = {
		trigger = {	
			scope:recipient = {
				highest_skill = learning
			}
		}
		event_background = regula_goddess_learning # adrian-virlan-daily-sketch-30-process1
	}


	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate ={
		play_music_cue = "regula_dies_irae"
		scope:recipient = {
			add_to_global_variable_list = {
				name = regula_undying_character_list
				target = scope:recipient
			}
			if = {
				limit = {
					highest_skill = diplomacy
				}
				give_nickname = regula_nickname_avatar_diplomacy
				add_character_flag = {
					flag = regula_goddess_diplomacy_trait
				}
			}
			else_if = {
				limit = {
					highest_skill = martial
				}
				give_nickname = regula_nickname_avatar_martial
				add_character_flag = {
					flag = regula_goddess_martial_trait
				}
			}
			else_if = {
				limit = {
					highest_skill = stewardship
				}
				give_nickname = regula_nickname_avatar_stewardship
				add_character_flag = {
					flag = regula_goddess_stewardship_trait
				}
			}
			else_if = {
				limit = {
					highest_skill = intrigue
				}
				give_nickname = regula_nickname_avatar_intrigue
				add_character_flag = {
					flag = regula_goddess_intrigue_trait
				}
			}
			else_if = {
				limit = {
					highest_skill = learning
				}
				give_nickname = regula_nickname_avatar_learning
				add_character_flag = {
					flag = regula_goddess_learning_trait
				}
			}
			carn_remove_all_wounds_effect = yes
			carn_remove_all_major_disfigurements_effect = yes
			carn_recover_from_all_diseases_effect = yes
			carn_remove_all_minor_disfigurements_effect = yes
		}
	}

	option = { # It is done.
		name = regula_holy_site_event.1003.a 
	}
}


# Pregnancy gender adjustment
regula_holy_site_event.2000 = {
    hidden = yes

    trigger = {
		# faith = { religion_tag = regula_religion }
        faith = {
			controls_holy_site_with_flag = holy_site_reg_offspring_flag
        }
	}
	
	immediate = {
		random = {
			chance = 60
			set_pregnancy_gender = female
		}
	}
}

regula_holy_site_event.2001 = {
    hidden = yes

    trigger = {
		# faith = { religion_tag = regula_religion }
		exists = global_var:regula_child_max
		global_var:regula_child_max = {
			compare_value >= regula_num_magister_children
		}
	}
	# trigger = {
	# 	# faith = { religion_tag = regula_religion }
	# 	exists = global_var:regula_child_max
	# 	if = {
	# 		limit = {
	# 			global_var:regula_child_max = 0
	# 		}
	# 	}
	# 	else_if = {
	# 		limit = {
	# 			global_var:regula_child_max = Two
	# 			regula_num_magister_children > 2
	# 		}
	# 	}
	# 	else_if = {
	# 		limit = {
	# 			global_var:regula_child_max = Four
	# 			regula_num_magister_children > 4
	# 		}
	# 	}
	# }
	
	immediate = {
		add_character_flag = carn_suppress_next_on_pregnancy_maintenance
		add_character_flag = carn_suppress_next_on_pregnancy_notification
		add_character_flag = carn_suppress_next_on_birth_notification
		end_pregnancy = yes
	}
}

# Christianity and Islam fervor adjustment
# regula_holy_site_event.2003 = {
# 	type = character_event
# 	hidden = yes
# 	trigger = {
# 		has_trait = magister_trait_group
# 		faith = {
# 			controls_holy_site_with_flag = 	holy_site_reg_jerusalem_flag
# 		}
# 	}
	
# 	immediate = {
# 		religion:christianity_religion = {
# 			every_faith = {
# 				change_fervor = -2.5
# 			}
# 		}
# 		religion:islam_religion = {
# 			every_faith = {
# 				change_fervor = -2.5
# 			}
# 		}
# 	}
# }