﻿namespace = regula_exhaurire_vitale_event

#############################
# Regula Interaction Events #
######################################################
# 0001: Exhaurire Vitale
		# 0011-0013: Piety drain
		# 0021-0025: Absorb Vitality
		# 0031-0035: Absorb Essence
######################################################

# Drain life (Exhaurire Vitale)
regula_exhaurire_vitale_event.0001 = {
	type = character_event
	title = regula_exhaurire_vitale_event.0001.t

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 0 }}
				desc = regula_exhaurire_vitale_event.0001.desc_0
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 1 }}
				desc = regula_exhaurire_vitale_event.0001.desc_1
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 2 }}
				desc = regula_exhaurire_vitale_event.0001.desc_2
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 3 }}
				desc = regula_exhaurire_vitale_event.0001.desc_3
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 4 }}
				desc = regula_exhaurire_vitale_event.0001.desc_4
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 5 }}
				desc = regula_exhaurire_vitale_event.0001.desc_5
			}
		}
	}

	theme = regula_theme
	override_background = {
		reference = godless_shrine  # Background: https://www.artstation.com/julesmartinvos
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { regula_blindfold }
		animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			carn_undress_character_effect = yes
		}
	}

	option = {
		name = regula_exhaurire_vitale_event.0001.piety
		custom_description_no_bullet = { text = regula_exhaurire_vitale_drain_piety }
		regula_exhaurire_vitale_drain_piety_effect = yes
	}

	option = { # Absorb Essence
		name = regula_exhaurire_vitale_event.0001.absorb_essence

		trigger = {
			exhaurire_vitale_can_drain_any_trait = {
				ACTOR = scope:actor
				TARGET = scope:recipient
			}
			piety >= regula_exhaurire_vitale_absorb_essence_piety_cost
		}

		show_as_unavailable = {
			# We always show this option.
			# Even if we can't afford or there are no traits to drain.
			always = yes
		}

		custom_description_no_bullet = { text = regula_exhaurire_vitale_absorb_essence }
		regula_exhaurire_vitale_absorb_essence_effect = yes
		add_piety = { subtract = regula_exhaurire_vitale_absorb_essence_piety_cost }
		add_piety_experience = { subtract = regula_exhaurire_vitale_absorb_essence_piety_experience_cost }
	}

	option = { # Absorb Vitality
		name = regula_exhaurire_vitale_event.0001.absorb_vitality

		trigger = {
			piety >= regula_exhaurire_vitale_absorb_vitality_piety_cost
		}

		show_as_unavailable = {
			# We always show this option.
			# Even if we can't afford.
			always = yes
		}

		custom_description_no_bullet = { text = regula_exhaurire_vitale_absorb_vitality }
		regula_exhaurire_vitale_absorb_vitality_effect = yes
		add_piety = { subtract = regula_exhaurire_vitale_absorb_vitality_piety_cost }

		if = {
			limit = {
				piety_level >= regula_exhaurire_vitale_absorb_vitality_piety_level_cost
			}
			add_piety_level = { subtract = regula_exhaurire_vitale_absorb_vitality_piety_level_cost }
		}
		else = {
			add_piety_level = { subtract = piety_level }
		}

		exhaurire_vitale_drain_vitality_cost_update = yes
	}

	option = {
		name = regula_exhaurire_vitale_event.0001.cancel
		custom_description_no_bullet = { text = regula_exhaurire_vitale_cancel }
		hidden_effect = {
			remove_interaction_cooldown = regula_exhaurire_vitale_interaction
		}
	}

	after = {
		scope:recipient = {
			if = {
				limit = {
					is_alive = yes
				}
				carn_dress_character_effect = yes
			}
		}
	}
}

# Exhaurire Vitale Piety Drain ############################################################################################################
# All tier DRAINS piety for the target. If the target does not have enough, her piety goes into negative AND she gets a health debuff
# In order of
# Bad			- Drains piety from the target - 50 if a standard devoted, 75 if a paelex / domina
# Good			- Drains piety from the target - 300 if a standard devoted, 400 if a paelex / domina
# Great			- Drains piety from the target - 500 if a standard devoted, 650 if a paelex / domina

# Piety Drain - Bad
regula_exhaurire_vitale_event.0011 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_bad
				title = regula_exhaurire_vitale_outcome_bad.t
				desc = regula_exhaurire_vitale_piety_bad.desc
				right_icon = scope:recipient

				scope:recipient = {
					# Takes piety from your target
					if = {
						limit = {
							is_regula_leader_devoted_trigger = yes
						}
						add_piety_no_experience = -75
					}
					else = {
						add_piety_no_experience = -50
					}

					# Gives a health debuff if not enough piety
					if = {
						limit = {
							piety < 0
						}
						add_character_modifier = {
							modifier = regula_exhaurire_vitale_small_health_penalty
							years = 3
						}
					}
				}

				scope:actor = {
					if = {
						limit = {
							scope:recipient = {
								is_regula_leader_devoted_trigger = yes
							}
						}
						add_piety_no_experience = 75
					}
					else = {
						add_piety_no_experience = 50
					}
				}
			}
		}
	}
}

# Piety Drain - Good
regula_exhaurire_vitale_event.0012 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_good.t
				desc = regula_exhaurire_vitale_piety_good.desc
				right_icon = scope:recipient

				scope:recipient = {
					# Takes piety from your target
					if = {
						limit = {
							is_regula_leader_devoted_trigger = yes
						}
						add_piety_no_experience = -400
					}
					else = {
						add_piety_no_experience = -300
					}

					# Gives a health debuff if not enough piety
					if = {
						limit = {
							piety < 0
						}
						add_character_modifier = {
							modifier = regula_exhaurire_vitale_small_health_penalty
							years = 3
						}
					}
				}

				scope:actor = {
					if = {
						limit = {
							scope:recipient = {
								is_regula_leader_devoted_trigger = yes
							}
						}
						add_piety_no_experience = 400
					}
					else = {
						add_piety_no_experience = 300
					}
				}
			}
		}
	}
}

# Piety Drain - Great
regula_exhaurire_vitale_event.0013 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_great.t
				desc = regula_exhaurire_vitale_piety_great.desc
				right_icon = scope:recipient

				scope:recipient = {
					# Takes piety from your target
					if = {
						limit = {
							is_regula_leader_devoted_trigger = yes
						}
						add_piety_no_experience = -650
					}
					else = {
						add_piety_no_experience = -500
					}

					# Gives a health debuff if not enough piety
					if = {
						limit = {
							piety < 0
						}
						add_character_modifier = {
							modifier = regula_exhaurire_vitale_small_health_penalty
							years = 3
						}
					}
				}

				scope:actor = {
					if = {
						limit = {
							scope:recipient = {
								is_regula_leader_devoted_trigger = yes
							}
						}
						add_piety_no_experience = 650
					}
					else = {
						add_piety_no_experience = 500
					}
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Vitality ###########################################################################################################
# Absorbs 'youth' (max age, and current age) from the target.
# In order of
# Backfire		- You die. Target is wounded (can kill).
# Bad			- You are wounded (can kill). Target is wounded (can kill).
# Good			- You drain 10 years of life expectancy from the target. Target is wounded (can kill).
# Great			- You drain 20 years of life expectancy from the target. Target is wounded twice (can kill).
# Fantastic		- You drain 30 years of life expectancy from the target. Target is wounded three times (can kill).

# Exhaurire Vitale - Absorb Vitality - Backfire
regula_exhaurire_vitale_event.0021 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_bad
				title = regula_exhaurire_vitale_outcome_backfire.t
				desc = regula_exhaurire_vitale_absorb_essence_backfire.desc
				right_icon = scope:recipient

				death = {
					death_reason = death_own_ritual_backfire
				}

				scope:recipient = {
					stress_impact = {
						base = medium_stress_impact_gain
					}
					increase_wounds_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Vitality - Bad
regula_exhaurire_vitale_event.0022 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_bad
				title = regula_exhaurire_vitale_outcome_bad.t
				desc = regula_exhaurire_vitale_absorb_vitality_bad.desc
				right_icon = scope:recipient

				stress_impact = {
					base = medium_stress_impact_gain
					ambitious = minor_stress_impact_gain
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
				}

				increase_wounds_effect = { REASON = treatment }

				scope:recipient = {
					stress_impact = {
						base = medium_stress_impact_gain
					}
					increase_wounds_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Vitality - Good
regula_exhaurire_vitale_event.0023 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_good.t
				desc = regula_exhaurire_vitale_absorb_vitality_good.desc
				right_icon = scope:recipient

				exhaurire_vitale_drain_vitality_effect = {
					ACTOR = scope:actor
					TARGET = scope:recipient
					STACKS = 1
				}

				stress_impact = {
					base = minor_stress_impact_gain
					ambitious = medium_stress_impact_loss
					callous = medium_stress_impact_loss
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
					sadistic = medium_stress_impact_loss
				}

				scope:recipient = {
					if = {
						limit = {
							age >= 65
						}

						# Kill outright.
						death = {
							death_reason = death_drained
							killer = scope:actor
						}
					}
					else = {
						stress_impact = {
							base = medium_stress_impact_gain
						}
						increase_wounds_effect = { REASON = treatment }
					}
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Vitality - Great
regula_exhaurire_vitale_event.0024 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_great.t
				desc = regula_exhaurire_vitale_absorb_vitality_great.desc
				right_icon = scope:recipient

				exhaurire_vitale_drain_vitality_effect = {
					ACTOR = scope:actor
					TARGET = scope:recipient
					STACKS = 2
				}

				stress_impact = {
					base = minor_stress_impact_gain
					ambitious = medium_stress_impact_loss
					callous = medium_stress_impact_loss
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
					sadistic = medium_stress_impact_loss
				}

				scope:recipient = {
					if = {
						limit = {
							age >= 55
						}

						# Kill outright.
						death = {
							death_reason = death_drained
							killer = scope:actor
						}
					}
					else = {
						stress_impact = {
							base = medium_stress_impact_gain
						}
						increase_wounds_effect = { REASON = treatment }
						increase_wounds_effect = { REASON = treatment }
					}
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Vitality - Fantastic
regula_exhaurire_vitale_event.0025 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_fantastic.t
				desc = regula_exhaurire_vitale_absorb_vitality_fantastic.desc
				right_icon = scope:recipient

				exhaurire_vitale_drain_vitality_effect = {
					ACTOR = scope:actor
					TARGET = scope:recipient
					STACKS = 3
				}

				stress_impact = {
					base = minor_stress_impact_gain
					ambitious = medium_stress_impact_loss
					callous = medium_stress_impact_loss
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
					sadistic = medium_stress_impact_loss
				}

				scope:recipient = {
					if = {
						limit = {
							age >= 45
						}

						# Kill outright.
						death = {
							death_reason = death_drained
							killer = scope:actor
						}
					}
					else = {
						stress_impact = {
							base = major_stress_impact_gain
						}
						increase_wounds_effect = { REASON = treatment }
						increase_wounds_effect = { REASON = treatment }
						increase_wounds_effect = { REASON = treatment }
					}
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Essence ############################################################################################################
# Absorbs positive congenital traits from the target.
# In order of
# Backfire		- Drain occurs opposite direction (if possible). Both you and target are wounded.
# Bad			- Drain has a chance to occur (25%). Target is wounded.
# Good			- Drain occurs once. Low chance (25%) target wounded.
# Great			- Drain occurs once (40%) or twice (60%).
# Fantastic		- Train occurs once (25%), twice (50%), or three times (25%).

# Exhaurire Vitale - Absorb Essence - Backfire
regula_exhaurire_vitale_event.0031 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_bad
				title = regula_exhaurire_vitale_outcome_backfire.t
				desc = regula_exhaurire_vitale_absorb_essence_backfire.desc
				right_icon = scope:recipient

				increase_wounds_no_death_effect = { REASON = treatment }

				stress_impact = {
					base = medium_stress_impact_gain
					ambitious = minor_stress_impact_gain
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
				}

				scope:recipient = {
					increase_wounds_no_death_effect = { REASON = treatment }
					stress_impact = {
						base = medium_stress_impact_gain
					}
				}

				if = { # If possible, do a reverse drain
					limit = {
						exhaurire_vitale_can_drain_any_trait = {
							ACTOR = scope:recipient
							TARGET = scope:actor
						}
					}

					exhaurire_vitale_drain_any_trait_effect = {
						ACTOR = scope:recipient
						TARGET = scope:actor
					}
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Essence - Bad
regula_exhaurire_vitale_event.0032 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_bad
				title = regula_exhaurire_vitale_outcome_bad.t
				desc = regula_exhaurire_vitale_absorb_essence_bad.desc
				right_icon = scope:recipient

				stress_impact = {
					base = minor_stress_impact_gain
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
				}

				scope:recipient = {
					increase_wounds_no_death_effect = { REASON = treatment }
					stress_impact = {
						base = minor_stress_impact_gain
					}
				}

				random = {
					chance = 25

					exhaurire_vitale_drain_any_trait_effect = {
						ACTOR = scope:actor
						TARGET = scope:recipient
					}
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Essence - Good
regula_exhaurire_vitale_event.0033 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_good.t
				desc = regula_exhaurire_vitale_absorb_essence_good.desc
				right_icon = scope:recipient

				stress_impact = {
					base = minor_stress_impact_gain
					ambitious = medium_stress_impact_loss
					callous = medium_stress_impact_loss
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
					sadistic = medium_stress_impact_loss
				}

				scope:recipient = {
					stress_impact = {
						base = minor_stress_impact_gain
						ambitious = minor_stress_impact_gain
					}

					random = {
						chance = 25
						increase_wounds_no_death_effect = { REASON = treatment }
					}
				}

				exhaurire_vitale_drain_any_trait_effect = {
					ACTOR = scope:actor
					TARGET = scope:recipient
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Essence - Great
regula_exhaurire_vitale_event.0034 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_great.t
				desc = regula_exhaurire_vitale_absorb_essence_great.desc
				right_icon = scope:recipient

				stress_impact = {
					base = minor_stress_impact_gain
					ambitious = medium_stress_impact_loss
					callous = medium_stress_impact_loss
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
					sadistic = medium_stress_impact_loss
				}

				scope:recipient = {
					stress_impact = {
						base = minor_stress_impact_gain
						ambitious = minor_stress_impact_gain
					}
				}

				random_list = {
					40 = {
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
					}
					60 = {
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
					}
				}
			}
		}
	}
}

# Exhaurire Vitale - Absorb Essence - Fantastic
regula_exhaurire_vitale_event.0035 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = regula_exhaurire_vitale_outcome_good
				title = regula_exhaurire_vitale_outcome_fantastic.t
				desc = regula_exhaurire_vitale_absorb_essence_fantastic.desc
				right_icon = scope:recipient

				stress_impact = {
					base = minor_stress_impact_gain
					ambitious = medium_stress_impact_loss
					callous = medium_stress_impact_loss
					compassionate = minor_stress_impact_gain
					content = minor_stress_impact_gain
					calm = minor_stress_impact_gain
					just = minor_stress_impact_gain
					sadistic = medium_stress_impact_loss
				}

				scope:recipient = {
					stress_impact = {
						base = minor_stress_impact_gain
						ambitious = minor_stress_impact_gain
					}
				}

				random_list = {
					25 = {
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
					}
					50 = {
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
					}
					25 = {
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
						exhaurire_vitale_drain_any_trait_effect = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
					}
				}
			}
		}
	}
}
