﻿namespace = holy_stuff_relic_procession_event

##################################################
# Relic Procession
##################################################

holy_stuff_relic_procession_event.0001 = { #Hallelujah! The procession passes without incident.
	type = character_event
	title = holy_stuff_relic_procession_event.0001.t
	desc = holy_stuff_relic_procession_event.0001.desc
	theme = faith
	override_background = {
		reference = terrain_scope
	}
	left_portrait = {
		character = root
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:realm_priest
		animation = personality_zealous
	}

	immediate = {
		#End the activity
		if = {
			limit = {
				exists = scope:activity
			}
			scope:activity = {
				complete_activity = yes
			}
		}
		cp:councillor_court_chaplain = {
			save_scope_as = realm_priest
		}
		capital_county = {
			save_scope_as = procession_location
		}
		capital_province = {
                  save_scope_as = background_terrain_scope
		}
		play_music_cue = "mx_cue_epic_sacral_moment"

		holy_stuff_relic_procession_scripted_effect = yes
	}

	option = {
		name = holy_stuff_relic_procession_event.0001.a

	}
}

holy_stuff_relic_procession_event.0002 = { #A storm spoils the procession
	type = character_event
	title = holy_stuff_relic_procession_event.0002.t
	desc = holy_stuff_relic_procession_event.0002.desc
	theme = faith
	override_background = {
		reference = terrain_scope
	}
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:realm_priest
		animation = worry
	}

	immediate = {
		#End the activity
		if = {
			limit = {
				exists = scope:activity
			}
			scope:activity = {
				complete_activity = yes
			}
		}
		cp:councillor_court_chaplain = {
			save_scope_as = realm_priest
		}
		capital_county = {
			save_scope_as = procession_location
		}
		capital_province = {
                  save_scope_as = background_terrain_scope
		}
		play_music_cue = "mx_cue_negative"
	}

	option = {
		name = holy_stuff_relic_procession_event.0002.a

		random = {
			chance = {
				value = 35
				add = {
					value = health
					multiply = -2.5
				}
			}
			show_as_tooltip = { add_trait = ill }
		}

		holy_stuff_relic_procession_scripted_effect = yes
	}

	option = {
		name = holy_stuff_relic_procession_event.0002.b

		add_piety = miniscule_piety_loss

		stress_impact = {
			cynical = minor_stress_impact_loss
			zealous = minor_stress_impact_gain
		}

	}
}

holy_stuff_relic_procession_event.0003 = { #Your court chaplain is a clumsy idiot.
	type = character_event
	title = holy_stuff_relic_procession_event.0003.t
	desc = holy_stuff_relic_procession_event.0003.desc
	theme = faith
	override_background = {
		reference = terrain_scope
	}
	left_portrait = {
		character = root
		animation = rage
	}
	right_portrait = {
		character = scope:realm_priest
		animation = worry
	}
	artifact = { # To display the artifact in the event-window
	    target = scope:procession_relic
	    position = lower_center_portrait
	}

	immediate = {
		#End the activity
		if = {
			limit = {
				exists = scope:activity
			}
			scope:activity = {
				complete_activity = yes
			}
		}
		cp:councillor_court_chaplain = {
			save_scope_as = realm_priest
		}
		capital_county = {
			save_scope_as = procession_location
		}
		capital_province = {
                  save_scope_as = background_terrain_scope
		}
		root = {
			save_scope_as = executioner
		}
		play_music_cue = "mx_cue_negative"

		holy_stuff_relic_procession_scripted_effect = yes

		stress_impact = {
			relic_collector = medium_stress_impact_gain
		}

		random_character_artifact = {
			limit = {
				artifact_is_christian_relic_trigger = yes
			}
			save_scope_as = procession_relic
		} 

		if = {
			random_list = {
				50 = {
					# Remove 25% of remaining durability
					scope:procession_relic = {
						add_durability = {
							value = artifact_durability
							multiply = -0.25
						}
					}
				}
				30 = {
					# Remove 50% of remaining durability
					scope:procession_relic = {
						add_durability = {
							value = artifact_durability
							multiply = -0.50
						}
					}
				}
				20 = {
					# Remove 75% of remaining durability
					scope:procession_relic = {
						add_durability = {
							value = artifact_durability
							multiply = -0.75
						}
					}
				}
			}
		}
	}

	option = {
		name = holy_stuff_relic_procession_event.0003.a
	}
	option = {
		name = holy_stuff_relic_procession_event.0003.b

		trigger = {
			OR = {
				has_trait = compassionate
				has_trait = forgiving
			}
		}

		random_list = {
			90 = {
				if = {
					limit = { 
						scope:realm_priest = {
								NOT = {
									has_relation_rival = root
									has_relation_potential_rival = root
									has_relation_nemesis = root
								}
						}
                  		}
					scope:realm_priest = {
						add_opinion = {
							target = root
							modifier = kindness_opinion
							opinion = 30
						}
					}
				}
			}
			10 = {
				if = {
					limit = { #Has no nickname or a bad nickname
			      		OR = { 
				      		has_any_nickname = no
				      		has_bad_nickname = yes
                        		} 
			      		NOT = { 
				      		has_character_flag = had_nickname_event
                        		}
                  		}
					give_nickname = nick_the_kind
				}
			}
		}
	}

	option = {
		name = holy_stuff_relic_procession_event.0003.c

		trigger = {
			OR = {
				has_trait = callous
				has_trait = sadistic
			}
		}

		stress_impact = {
			forgiving = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		root = {
			add_dread = medium_dread_gain
                  add_tyranny = medium_tyranny_gain
		}
		scope:realm_priest = {
				death = {
					death_reason = death_execution
					killer = scope:executioner
				}
		}
	}

}
