###################################
#
# THE OLD GODS
# - Blot Events
#
###################################

# Written by Henrik Eklund

namespace = TOG

# You summon your vassals to a Blot
character_event = {
	id = TOG.600
	desc = EVTDESC_TOG_600
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes # hold_blot, minor_decisions.txt
	hide_from = yes

	option = {
		name = EVTOPTA_TOG_600

		any_vassal = {
			limit = {
				block_general_event_trigger = no
				war = no
			}

			if = {
				limit = {
					OR = {
						religion_openly_norse_or_reformed_trigger = yes
						religion_openly_german_or_reformed_trigger = yes
					}
				}

				character_event = {
					id = TOG.601
					tooltip = EVTTOOLTIP_TOG_601
				}

				character_event = {
					id = TOG.605 # Blot begins
					days = 10
				}
			}
			else = {
				character_event = {
					id = TOG.602
					tooltip = EVTTOOLTIP_TOG_602
				}
			}
		}

		character_event = {
			id = TOG.604 # Blot begins
			days = 10
		}
	}
}

# Summoned to Blot (Vassal)
character_event = {
	id = TOG.601
	desc = EVTDESC_TOG_601
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_TOG_601

		set_character_flag = attending_blot
		set_character_flag = do_not_disturb

		character_event = {
			id = TOG.699 # Safety catch flag clearing
			days = 50 # Increase this by 5 for each additional sacrifice, and also for each additional feast event
		}
	}
}

# Non-Norse Pagans pay to skip Blot
character_event = {
	id = TOG.602
	desc = EVTDESC_TOG_602
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	option = { # Pay
		name = EVTOPTA_TOG_602

		trigger = {
			wealth >= 5
			real_tier = BARON
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = TOG.603
				tooltip = EVTTOOLTIP_TOG_603
			}
		}

		wealth = -5
	}

	option = { # Pay
		name = EVTOPTA_TOG_602

		trigger = {
			wealth >= 10
			real_tier = COUNT
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = TOG.603
				tooltip = EVTTOOLTIP_TOG_603
			}
		}

		wealth = -10
	}

	option = { # Pay
		name = EVTOPTA_TOG_602

		trigger = {
			wealth >= 20
			real_tier = DUKE
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = TOG.603
				tooltip = EVTTOOLTIP_TOG_603
			}
		}

		wealth = -20
	}

	option = { # Pay
		name = EVTOPTA_TOG_602

		trigger = {
			wealth >= 50
			higher_real_tier_than = DUKE
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = TOG.603
				tooltip = EVTTOOLTIP_TOG_603
			}
		}

		wealth = -50
	}

	option = { # Don't pay
		name = EVTOPTB_TOG_602

		FROM = {
			show_scope_change = no

			character_event = {
				id = TOG.636
				tooltip = EVTTOOLTIP_TOG_636
			}
		}

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_refused_blot
				who = ROOT
			}

			any_vassal = {
				show_scope_change = no

				limit = { has_character_flag = attending_blot }

				opinion = {
					name = opinion_refused_blot
					who = ROOT
				}
			}
		}
	}
}

# Non-Norse Pagans pay to skip Blot (Liege)
character_event = {
	id = TOG.603
	desc = EVTDESC_TOG_603
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_TOG_603

		if = {
			limit = { FROM = { real_tier = BARON } }
			wealth = 5
		}
		else_if = {
			limit = { FROM = { real_tier = COUNT } }
			wealth = 10
		}
		else_if = {
			limit = { FROM = { real_tier = DUKE } }
			wealth = 20
		}
		else = {
			wealth = 50
		}
	}
}

# Non-Norse Pagans refuse to pay to skip Blot (Liege)
character_event = {
	id = TOG.636
	desc = EVTDESC_TOG_636
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_636
	}
}

# Blot Begins! (Liege)
character_event = {
	id = TOG.604
	desc = EVTDESC_TOG_604
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	option = {
		name = EVTOPTA_TOG_604

		character_event = {
			id = TOG.611
			days = 5
			tooltip = blot_begins
		}

		if = {
			limit = { ai = no }

			chronicle = {
				entry = CHRONICLE_HELD_BLOT
				picture = GFX_evt_viking_throneroom_oldgods
			}
		}
	}
}

# Blot Begins! (Vassal)
character_event = {
	id = TOG.605
	desc = EVTDESC_TOG_605
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_604
	}
}

# Prisoner selection
character_event = {
	id = TOG.611

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		clear_flags_with_prefix = blot_sacrifice_

		if = {
			limit = {
				check_variable = {
					which = local_sacrifice_count
					value < 4
				}

				any_courtier = {
					prisoner = yes
					is_adult = yes
					host = { character = ROOT }
				}
			}

			change_variable = {
				which = local_sacrifice_count
				value = 1
			}

			random_courtier = {
				limit = {
					prisoner = yes
					is_adult = yes
					host = { character = ROOT }
				}

				# Setup for sacrifice event flavour, to avoid duplicating logic in triggered descriptions
				if = {
					limit = { sibling = ROOT }

					if = {
						limit = { is_female = no }
						ROOT = { set_character_flag = blot_sacrifice_brother }
					}
					else = {
						ROOT = { set_character_flag = blot_sacrifice_sister }
					}
				}
				else_if = {
					limit = { is_parent_of = ROOT }

					if = {
						limit = { is_female = no }
						ROOT = { set_character_flag = blot_sacrifice_father }
					}
					else = {
						ROOT = { set_character_flag = blot_sacrifice_mother }
					}
				}
				else_if = {
					limit = { is_child_of = ROOT }

					if = {
						limit = { is_female = no }
						ROOT = { set_character_flag = blot_sacrifice_son }
					}
					else = {
						ROOT = { set_character_flag = blot_sacrifice_daughter }
					}
				}
				else_if = {
					limit = { is_married = ROOT }
					ROOT = { set_character_flag = blot_sacrifice_spouse }
				}
				else_if = {
					limit = { dynasty = ROOT }
					ROOT = { set_character_flag = blot_sacrifice_kin }
				}
				else_if = {
					limit = { religion_group = christian }
					ROOT = { set_character_flag = blot_sacrifice_christian }
				}
				else_if = {
					limit = { religion_group = muslim }
					ROOT = { set_character_flag = blot_sacrifice_muslim }
				}
				else_if = {
					limit = {
						religion_openly_aztec_or_reformed_trigger = yes
						culture = nahua
					}

					ROOT = { set_character_flag = blot_sacrifice_aztec }
				}
				else = {
					ROOT = { set_character_flag = blot_sacrifice_generic }
				}

				character_event = { id = TOG.606 }
			}
		}

		# Only sacrifice slaves once, then get on with the feast
		else_if = {
			limit = {
				check_variable = {
					which = local_sacrifice_count
					value == 0
				}
			}

			character_event = {
				id = TOG.634 # Sacrifice slaves
				days = 5
			}
		}
		else = {
			character_event = {
				id = TOG.640 # Feast starts
				days = 5
			}
		}
	}
}

# Sacrifice Prisoner (Prisoner)
character_event = {
	id = TOG.606
	desc = EVTDESC_TOG_606
	picture = GFX_evt_midwinter_blot_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_TOG_606

		FROM = {
			character_event = { id = TOG.610 } # Sacrifice
		}
	}
}

# Sacrifice (Liege)
character_event = {
	id = TOG.610
	picture = GFX_evt_midwinter_blot_oldgods
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESC_TOG_610 # Generic 1
		trigger = { has_character_flag = blot_sacrifice_generic }
	}
	desc = {
		text = EVTDESC_TOG_680 # Generic 2
		trigger = { has_character_flag = blot_sacrifice_generic }
	}
	desc = {
		text = EVTDESC_TOG_681 # Generic 3
		trigger = { has_character_flag = blot_sacrifice_generic }
	}
	desc = {
		text = EVTDESC_TOG_682 # Generic 4
		trigger = { has_character_flag = blot_sacrifice_generic }
	}
	desc = {
		text = EVTDESC_TOG_611
		trigger = { has_character_flag = blot_sacrifice_christian }
	}
	desc = {
		text = EVTDESC_TOG_612
		trigger = { has_character_flag = blot_sacrifice_muslim }
	}
	desc = {
		text = EVTDESC_TOG_621
		trigger = { has_character_flag = blot_sacrifice_aztec }
	}
	desc = {
		text = EVTDESC_TOG_613
		trigger = { has_character_flag = blot_sacrifice_brother }
	}
	desc = {
		text = EVTDESC_TOG_614
		trigger = { has_character_flag = blot_sacrifice_sister }
	}
	desc = {
		text = EVTDESC_TOG_615
		trigger = { has_character_flag = blot_sacrifice_father }
	}
	desc = {
		text = EVTDESC_TOG_616
		trigger = { has_character_flag = blot_sacrifice_mother }
	}
	desc = {
		text = EVTDESC_TOG_617
		trigger = { has_character_flag = blot_sacrifice_son }
	}
	desc = {
		text = EVTDESC_TOG_618
		trigger = { has_character_flag = blot_sacrifice_daughter }
	}
	desc = {
		text = EVTDESC_TOG_619
		trigger = { has_character_flag = blot_sacrifice_kin }
	}
	desc = {
		text = EVTDESC_TOG_620
		trigger = { has_character_flag = blot_sacrifice_spouse }
	}

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA_TOG_610
			trigger = { has_character_flag = blot_sacrifice_generic }
		}
		name = {
			text = EVTOPTA_TOG_611
			trigger = { has_character_flag = blot_sacrifice_christian }
		}
		name = {
			text = EVTOPTA_TOG_612
			trigger = { has_character_flag = blot_sacrifice_muslim }
		}
		name = {
			text = EVTOPTA_TOG_621
			trigger = { has_character_flag = blot_sacrifice_aztec }
		}
		name = {
			text = EVTOPTA_TOG_613
			trigger = { has_character_flag = blot_sacrifice_brother }
		}
		name = {
			text = EVTOPTA_TOG_614
			trigger = { has_character_flag = blot_sacrifice_sister }
		}
		name = {
			text = EVTOPTA_TOG_615
			trigger = { has_character_flag = blot_sacrifice_father }
		}
		name = {
			text = EVTOPTA_TOG_616
			trigger = { has_character_flag = blot_sacrifice_mother }
		}
		name = {
			text = EVTOPTA_TOG_617
			trigger = { has_character_flag = blot_sacrifice_son }
		}
		name = {
			text = EVTOPTA_TOG_618
			trigger = { has_character_flag = blot_sacrifice_daughter }
		}
		name = {
			text = EVTOPTA_TOG_619
			trigger = { has_character_flag = blot_sacrifice_kin }
		}
		name = {
			text = EVTOPTA_TOG_620
			trigger = { has_character_flag = blot_sacrifice_spouse }
		}

		trigger = {
			FROM = { controls_religion = no }
		}

		FROM = {
			show_scope_change = no

			death = {
				death_reason = death_sacrificed_norse
				killer = ROOT
			}

			save_event_target_as = kinslayer_target
		}

		if = {
			limit = { is_close_relative = FROM }
			add_kinslayer_trait_effect = yes
		}

		any_vassal = {
			limit = { has_character_flag = attending_blot }
			character_event = { id = TOG.622 }
		}

		if = {
			limit = {
				OR = {
					has_character_flag = blot_sacrifice_christian
					has_character_flag = blot_sacrifice_muslim
					has_character_flag = blot_sacrifice_aztec
				}
			}

			prestige = 50
			piety = 25
		}
		else = {
			prestige = 25
			piety = 15
		}
	}

	option = {
		name = {
			text = EVTOPTA_TOG_610
			trigger = { has_character_flag = blot_sacrifice_generic }
		}
		name = {
			text = EVTOPTA_TOG_611_Pope
			trigger = { has_character_flag = blot_sacrifice_christian }
		}
		name = {
			text = EVTOPTA_TOG_612_Caliph
			trigger = { has_character_flag = blot_sacrifice_muslim }
		}
		name = {
			text = EVTOPTA_TOG_621_Aztec_Religious_Head
			trigger = { has_character_flag = blot_sacrifice_aztec }
		}
		name = {
			text = EVTOPTA_TOG_613
			trigger = { has_character_flag = blot_sacrifice_brother }
		}
		name = {
			text = EVTOPTA_TOG_614
			trigger = { has_character_flag = blot_sacrifice_sister }
		}
		name = {
			text = EVTOPTA_TOG_615
			trigger = { has_character_flag = blot_sacrifice_father }
		}
		name = {
			text = EVTOPTA_TOG_616
			trigger = { has_character_flag = blot_sacrifice_mother }
		}
		name = {
			text = EVTOPTA_TOG_617
			trigger = { has_character_flag = blot_sacrifice_son }
		}
		name = {
			text = EVTOPTA_TOG_618
			trigger = { has_character_flag = blot_sacrifice_daughter }
		}
		name = {
			text = EVTOPTA_TOG_619
			trigger = { has_character_flag = blot_sacrifice_kin }
		}
		name = {
			text = EVTOPTA_TOG_620
			trigger = { has_character_flag = blot_sacrifice_spouse }
		}

		trigger = {
			FROM = { controls_religion = yes }
		}

		FROM = {
			show_scope_change = no

			death = {
				death_reason = death_sacrificed_norse
				killer = ROOT
			}

			save_event_target_as = kinslayer_target
		}

		if = {
			limit = { is_close_relative = FROM }
			add_kinslayer_trait_effect = yes
		}

		any_vassal = {
			limit = { has_character_flag = attending_blot }
			character_event = { id = TOG.622 }
		}

		if = {
			limit = {
				FROM = {
					NOT = { religion = norse_pagan_reformed }
				}
			}

			if = {
				limit = {
					ai = no
					is_ironman = yes
					NOT = { has_character_flag = achievement_holy_smoke }
				}

				set_character_flag = achievement_holy_smoke
			}

			prestige = 250
			piety = 100

			religion_authority = {
				name = sacrificed_head_good
				years = 20
			}

			FROM = {
				show_scope_change = no

				religion_authority = {
					name = sacrificed_head_bad
					years = 20
				}
			}
		}
		else = {
			prestige = 25
			piety = 15
		}
	}

	option = {
		name = {
			text = EVTOPTB_TOG_610
			trigger = { has_character_flag = blot_sacrifice_generic }
		}
		name = {
			text = EVTOPTB_TOG_611
			trigger = { has_character_flag = blot_sacrifice_christian }
		}
		name = {
			text = EVTOPTB_TOG_612
			trigger = { has_character_flag = blot_sacrifice_muslim }
		}
		name = {
			text = EVTOPTB_TOG_621
			trigger = { has_character_flag = blot_sacrifice_aztec }
		}
		name = {
			text = EVTOPTB_TOG_613
			trigger = { has_character_flag = blot_sacrifice_brother }
		}
		name = {
			text = EVTOPTB_TOG_614
			trigger = { has_character_flag = blot_sacrifice_sister }
		}
		name = {
			text = EVTOPTB_TOG_615
			trigger = { has_character_flag = blot_sacrifice_father }
		}
		name = {
			text = EVTOPTB_TOG_616
			trigger = { has_character_flag = blot_sacrifice_mother }
		}
		name = {
			text = EVTOPTB_TOG_617
			trigger = { has_character_flag = blot_sacrifice_son }
		}
		name = {
			text = EVTOPTB_TOG_618
			trigger = { has_character_flag = blot_sacrifice_daughter }
		}
		name = {
			text = EVTOPTB_TOG_619
			trigger = { has_character_flag = blot_sacrifice_kin }
		}
		name = {
			text = EVTOPTB_TOG_620
			trigger = { has_character_flag = blot_sacrifice_spouse }
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = TOG.637
				tooltip = EVTTOOLTIP_TOG_637
			}
		}

		if = {
			limit = {
				OR = {
					has_character_flag = blot_sacrifice_christian
					has_character_flag = blot_sacrifice_muslim
					has_character_flag = blot_sacrifice_aztec
				}
			}

			piety = -50
		}
		else = {
			piety = -25
		}
	}

	after = {
		character_event = {
			id = TOG.611
			days = 5
		}
	}
}

# Sacrifice (Vassal)
character_event = {
	id = TOG.622
	picture = GFX_evt_midwinter_blot_oldgods
	border = GFX_event_normal_frame_religion

	desc = {
		text = EVTDESC_TOG_622
		trigger = { FROM = { has_character_flag = blot_sacrifice_generic } }
	}
	desc = {
		text = EVTDESC_TOG_623
		trigger = { FROM = { has_character_flag = blot_sacrifice_christian } }
	}
	desc = {
		text = EVTDESC_TOG_624
		trigger = { FROM = { has_character_flag = blot_sacrifice_muslim } }
	}
	desc = {
		text = EVTDESC_TOG_625
		trigger = { FROM = { has_character_flag = blot_sacrifice_brother } }
	}
	desc = {
		text = EVTDESC_TOG_626
		trigger = { FROM = { has_character_flag = blot_sacrifice_sister } }
	}
	desc = {
		text = EVTDESC_TOG_627
		trigger = { FROM = { has_character_flag = blot_sacrifice_father } }
	}
	desc = {
		text = EVTDESC_TOG_628
		trigger = { FROM = { has_character_flag = blot_sacrifice_mother } }
	}
	desc = {
		text = EVTDESC_TOG_629
		trigger = { FROM = { has_character_flag = blot_sacrifice_son } }
	}
	desc = {
		text = EVTDESC_TOG_630
		trigger = { FROM = { has_character_flag = blot_sacrifice_daughter } }
	}
	desc = {
		text = EVTDESC_TOG_631
		trigger = { FROM = { has_character_flag = blot_sacrifice_kin } }
	}
	desc = {
		text = EVTDESC_TOG_632
		trigger = { FROM = { has_character_flag = blot_sacrifice_spouse } }
	}
	desc = {
		text = EVTDESC_TOG_633
		trigger = { FROM = { has_character_flag = blot_sacrifice_aztec } }
	}

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTDESC_TOG_622

		tooltip = {
			FROMFROM = {
				show_scope_change = no

				death = {
					death_reason = death_sacrificed_norse
					killer = FROM
				}
			}
		}
	}
}

# No Prisoners, Slaves sacrificed instead (Liege)
character_event = {
	id = TOG.634
	desc = EVTDESC_TOG_634
	picture = GFX_evt_midwinter_blot_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	option = {
		name = EVTOPTA_TOG_634

		any_vassal = {
			limit = { has_character_flag = attending_blot }
			character_event = { id = TOG.635 }
		}

		character_event = {
			id = TOG.640 # Feast starts
			days = 5
		}

		wealth = -50
		prestige = 50
		piety = 50
	}
}

# No Prisoners, Slaves sacrificed instead (Vassal)
character_event = {
	id = TOG.635
	desc = EVTDESC_TOG_635
	picture = GFX_evt_midwinter_blot_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_635
	}
}

# Liege changed his mind about sacrifice (prisoner)
character_event = {
	id = TOG.637
	desc = EVTDESC_TOG_637
	picture = GFX_evt_midwinter_blot_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_TOG_637

		opinion = {
			name = opinion_spared_at_blot
			who = FROM
			years = 2
		}
	}
}

# Feast Begins (Liege)
character_event = {
	id = TOG.640
	desc = EVTDESC_TOG_640
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	option = {
		name = EVTOPTA_TOG_640

		custom_tooltip = {
			text = feast_begins

			set_character_flag = blot_feast

			set_variable = {
				which = local_blot_feast_events
				value = 0
			}

			character_event = {
				id = TOG.644 # Blot events tombola
				days = 3
			}

			hidden_effect = {
				any_vassal = {
					limit = { has_character_flag = attending_blot }

					set_character_flag = blot_feast_vassal
					character_event = { id = TOG.641 }

					opinion = {
						name = opinion_held_blot
						who = ROOT
					}
				}
			}
		}
	}
}

character_event = {
	id = TOG.644

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		check_variable = {
			which = local_blot_feast_events
			value < 4
		}
	}

	immediate = {
		change_variable = {
			which = local_blot_feast_events
			value = 1
		}

		random_list = {
			10 = {
				trigger = {
					any_vassal = {
						trait = drunkard
						has_character_flag = blot_feast_vassal
					}

					NOT = { has_character_flag = feast_drunkard }
				}

				random_vassal = {
					limit = {
						trait = drunkard
						has_character_flag = blot_feast_vassal
					}

					character_event = { id = TOG.650 }
				}
			}

			10 = {
				trigger = {
					any_vassal = {
						trait = gluttonous
						has_character_flag = blot_feast_vassal
					}

					num_of_vassals >= 2
					NOT = { has_character_flag = feast_gluttonous }
				}

				random_vassal = {
					limit = {
						trait = gluttonous
						has_character_flag = blot_feast_vassal
					}

					character_event = { id = TOG.653 }
				}
			}

			10 = {
				trigger = {
					any_vassal = {
						trait = lunatic
						has_character_flag = blot_feast_vassal
					}

					NOT = { has_character_flag = feast_lunatic }
				}

				random_vassal = {
					limit = {
						trait = lunatic
						has_character_flag = blot_feast_vassal
					}

					character_event = { id = TOG.656 }
				}
			}

			10 = {
				trigger = {
					any_vassal = {
						trait = lustful
						is_female = no
						has_character_flag = blot_feast_vassal
					}

					NOT = { has_character_flag = feast_lustful }
				}

				random_vassal = {
					limit = {
						trait = lustful
						is_female = no
						has_character_flag = blot_feast_vassal
					}

					character_event = { id = TOG.658 }
				}
			}

			10 = {
				trigger = {
					any_vassal = {
						has_character_flag = blot_feast_vassal

						liege = {
							any_vassal = {
								has_character_flag = blot_feast_vassal

								opinion = {
									who = PREVPREV
									value >= 20
								}

								NOT = { character = PREVPREV }
							}
						}
					}

					NOT = { has_character_flag = feast_friendship }
				}

				random_vassal = {
					limit = {
						liege = {
							any_vassal = {
								opinion = {
									who = PREVPREV
									value >= 20
								}

								NOT = { character = PREVPREV }
							}
						}
					}

					character_event = { id = TOG.661 }
				}
			}

			10 = {
				trigger = {
					NOT = { has_character_flag = feast_homosexual }

					any_vassal = {
						trait = homosexual
						has_lover = no
						has_character_flag = blot_feast_vassal

						liege = {
							any_vassal = {
								trait = homosexual
								same_sex = PREVPREV
								has_lover = no
								has_character_flag = blot_feast_vassal

								opinion = {
									who = PREVPREV
									value >= 0
								}

								NOT = { character = PREVPREV }
							}
						}
					}
				}

				random_vassal = {
					limit = {
						trait = homosexual
						has_lover = no
						has_character_flag = blot_feast_vassal

						liege = {
							any_vassal = {
								trait = homosexual
								same_sex = PREVPREV
								has_lover = no
								has_character_flag = blot_feast_vassal

								opinion = {
									who = PREVPREV
									value >= 0
								}

								NOT = { character = PREVPREV }
							}
						}
					}

					character_event = { id = TOG.664 }
				}
			}
		}

		repeat_event = {
			id = TOG.644
			days = 5
		}
	}

	fail_trigger_effect = {
		character_event = {
			id = TOG.642 # Feast ends
			days = 7
		}
	}
}

# Feast Begins (Vassal)
character_event = {
	id = TOG.641
	desc = EVTDESC_TOG_640
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_641

		custom_tooltip = { text = feast_begins }
	}
}

# Feast Ends (Liege)
character_event = {
	id = TOG.642
	desc = EVTDESC_TOG_642
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	option = {
		name = EVTOPTA_TOG_642

		any_vassal = {
			limit = { has_character_flag = attending_blot }
			character_event = { id = TOG.643 }
		}

		add_character_modifier = {
			name = held_blot_timer
			years = 5
			hidden = yes
		}

		add_character_modifier = {
			name = held_blot_modifier
			years = 1
		}

		clr_character_flag = holding_blot
		clr_character_flag = blot_feast
		clr_character_flag = feast_drunkard
		clr_character_flag = feast_gluttonous
		clr_character_flag = feast_lunatic
		clr_character_flag = feast_lustful
		clr_character_flag = feast_homosexual
		clr_character_flag = do_not_disturb
	}
}

# Feast Ends (Vassal)
character_event = {
	id = TOG.643
	desc = EVTDESC_TOG_643
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_TOG_642

		clr_character_flag = attending_blot
		clr_character_flag = blot_feast_vassal
		clr_character_flag = feast_drunkard
		clr_character_flag = feast_gluttonous
		clr_character_flag = feast_lunatic
		clr_character_flag = feast_lustful
		clr_character_flag = feast_friendship
		clr_character_flag = feast_homosexual
		clr_character_flag = do_not_disturb
	}
}

### Feast Events

# Drunkard (Guest)
character_event = {
	id = TOG.650
	desc = EVTDESC_TOG_650
	picture = GFX_evt_drunk
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	option = {
		name = EVTOPTA_TOG_650
		tooltip_info = drunkard

		liege = {
			show_scope_change = no

			if = {
				limit = { trait = drunkard }

				opinion = {
					name = opinion_drinking_buddy
					who = ROOT
				}
			}
			else = {
				opinion = {
					name = opinion_feast_scandal
					who = ROOT
				}
			}

			set_character_flag = feast_drunkard
			character_event = { id = TOG.651 }

			any_vassal = {
				show_scope_change = no

				limit = {
					has_character_flag = blot_feast_vassal
					NOT = { character = ROOT }
				}

				if = {
					limit = { trait = drunkard }

					opinion = {
						name = opinion_drinking_buddy
						who = ROOT
					}
				}
				else = {
					opinion = {
						name = opinion_feast_scandal
						who = ROOT
					}
				}

				character_event = { id = TOG.651 }
			}
		}
	}
}

# Drunkard (Host and Other Guests)
character_event = {
	id = TOG.651
	desc = EVTDESC_TOG_651
	picture = GFX_evt_drunk
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_651

		trigger = {
			NOT = { trait = drunkard }
		}

		tooltip = {
			opinion = {
				name = opinion_feast_scandal
				who = FROM
			}
		}
	}

	option = {
		name = EVTOPTB_TOG_651
		tooltip_info = drunkard

		trigger = { trait = drunkard }

		tooltip = {
			opinion = {
				name = opinion_drinking_buddy
				who = FROM
			}
		}
	}
}

# Gluttonous (Guest)
character_event = {
	id = TOG.653
	desc = EVTDESC_TOG_653
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = {
		liege = {
			set_character_flag = feast_gluttonous

			random_vassal = {
				limit = {
					NOT = { character = ROOT }
				}

				save_event_target_as = glutton_victim
			}
		}
	}

	option = {
		name = EVTOPTA_TOG_653
		tooltip_info = gluttonous

		event_target:glutton_victim = {
			character_event = {
				id = TOG.654
				tooltip = EVTTOOLTIP_TOG_654
			}

			opinion = {
				name = opinion_vomit
				who = ROOT
			}
		}

		liege = {
			show_scope_change = no

			opinion = {
				name = opinion_feast_scandal
				who = ROOT
			}

			character_event = { id = TOG.655 }

			any_vassal = {
				show_scope_change = no

				limit = {
					has_character_flag = blot_feast_vassal

					NOR = {
						character = ROOT
						character = event_target:glutton_victim
					}
				}

				opinion = {
					name = opinion_feast_scandal
					who = ROOT
				}

				character_event = { id = TOG.655 }
			}
		}
	}
}

# Gluttonous (Victim)
character_event = {
	id = TOG.654
	desc = EVTDESC_TOG_654
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_654

		tooltip = {
			opinion = {
				name = opinion_vomit
				who = FROM
			}
		}
	}
}

# Gluttonous (Host and Other Guests)
character_event = {
	id = TOG.655
	desc = EVTDESC_TOG_655
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_655

		tooltip = {
			opinion = {
				name = opinion_feast_scandal
				who = FROM
			}
		}
	}
}

# Lunatic (Guest)
character_event = {
	id = TOG.656
	desc = EVTDESC_TOG_656
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	hide_from = yes
	is_triggered_only = yes

	option = {
		name = EVTOPTA_TOG_656
		tooltip_info = lunatic

		liege = {
			show_scope_change = no

			if = {
				limit = { trait = lunatic }

				opinion = {
					name = opinion_feast_friend
					who = ROOT
				}
			}
			else = {
				opinion = {
					name = opinion_feast_scandal
					who = ROOT
				}
			}

			set_character_flag = feast_lunatic
			character_event = { id = TOG.657 }

			any_vassal = {
				show_scope_change = no

				limit = {
					has_character_flag = blot_feast_vassal
					NOT = { character = ROOT }
				}

				if = {
					limit = { trait = lunatic }

					opinion = {
						name = opinion_feast_friend
						who = ROOT
					}
				}
				else = {
					opinion = {
						name = opinion_feast_scandal
						who = ROOT
					}
				}

				character_event = { id = TOG.657 }
			}
		}
	}
}

# Lunatic (Host and Other Guests)
character_event = {
	id = TOG.657
	desc = EVTDESC_TOG_657
	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_657

		trigger = {
			NOT = { trait = lunatic }
		}

		tooltip = {
			opinion = {
				name = opinion_feast_scandal
				who = FROM
			}
		}
	}

	option = {
		name = EVTOPTB_TOG_657
		tooltip_info = lunatic

		trigger = { trait = lunatic }

		tooltip = {
			opinion = {
				name = opinion_feast_friend
				who = FROM
			}
		}
	}
}

# Lustful (Guest)
character_event = {
	id = TOG.658
	desc = EVTDESC_TOG_658
	picture = GFX_evt_brothel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	hide_from = yes

	immediate = {
		liege = {
			set_character_flag = feast_lustful
		}
	}

	option = {
		name = {
			text = EVTOPTA_TOG_658
			trigger = { is_married = no }
		}
		name = {
			text = EVTOPTB_TOG_658
			trigger = { is_married = yes }
		}

		tooltip_info = lustful

		liege = {
			show_scope_change = no

			if = {
				limit = { trait = lustful }

				opinion = {
					name = opinion_lustful_buddy
					who = ROOT
				}
			}
			else = {
				opinion = {
					name = opinion_feast_scandal
					who = ROOT
				}
			}

			character_event = { id = TOG.659 }

			any_vassal = {
				show_scope_change = no

				limit = {
					has_character_flag = blot_feast_vassal
					NOT = { character = ROOT }
				}

				if = {
					limit = { trait = lustful }

					opinion = {
						name = opinion_lustful_buddy
						who = ROOT
					}
				}
				else = {
					opinion = {
						name = opinion_feast_scandal
						who = ROOT
					}
				}

				character_event = { id = TOG.659 }
			}
		}

		any_spouse = {
			show_scope_change = no

			opinion = {
				name = opinion_mad_as_hell
				who = ROOT
				years = 1
			}

			character_event = { id = TOG.659 }
		}
	}
}

# Lustful (Host and Other Guests)
character_event = {
	id = TOG.659
	desc = EVTDESC_TOG_659
	picture = GFX_evt_brothel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_659

		trigger = {
			NOR = {
				trait = lustful
				is_married = FROM
			}
		}

		tooltip = {
			opinion = {
				name = opinion_feast_scandal
				who = FROM
			}
		}
	}

	option = {
		name = EVTOPTB_TOG_659
		tooltip_info = lustful

		trigger = {
			trait = lustful
			NOT = { is_married = FROM }
		}

		tooltip = {
			opinion = {
				name = opinion_lustful_buddy
				who = FROM
			}
		}
	}

	option = {
		name = EVTOPTC_TOG_659

		trigger = { is_married = FROM }

		tooltip = {
			opinion = {
				name = opinion_mad_as_hell
				who = FROM
				years = 1
			}
		}
	}
}

# Friendship Formed (Guest 1)
character_event = {
	id = TOG.661
	desc = EVTDESC_TOG_661
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = {
		hidden_effect = {
			liege = {
				set_character_flag = feast_friendship

				random_vassal = {
					limit = {
						has_character_flag = blot_feast_vassal

						opinion = {
							who = ROOT
							value >= 20
						}

						NOT = { character = ROOT }
					}

					save_event_target_as = other_vassal_guest
					character_event = { id = TOG.662 }
				}
			}
		}
	}

	option = {
		name = EVTOPTA_TOG_661

		reverse_opinion = {
			name = opinion_feast_friend
			who = event_target:other_vassal_guest
		}

		opinion = {
			name = opinion_feast_friend
			who = event_target:other_vassal_guest
		}
	}
}

# Friendship Formed (Guest 2)
character_event = {
	id = TOG.662
	desc = EVTDESC_TOG_661
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	immediate = {
		# For localisation in event description
		FROM = { save_event_target_as = other_vassal_guest }
	}

	option = {
		name = EVTOPTA_TOG_661

		tooltip = {
			reverse_opinion = {
				name = opinion_feast_friend
				who = FROM
			}

			opinion = {
				name = opinion_feast_friend
				who = FROM
			}
		}
	}
}

# Homosexual lovers (Guest 1)
character_event = {
	id = TOG.664
	desc = EVTDESC_TOG_664
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion
	portrait = event_target:second_homosexual_guest

	is_triggered_only = yes

	immediate = {
		save_event_target_as = first_homosexual_guest

		liege = {
			set_character_flag = feast_homosexual

			random_vassal = {
				limit = {
					trait = homosexual
					same_sex = ROOT
					has_character_flag = blot_feast_vassal

					opinion = {
						who = ROOT
						value >= 0
					}

					NOT = { character = ROOT }
				}

				save_event_target_as = second_homosexual_guest
				save_event_target_as = other_homosexual_guest # For loc
			}
		}
	}

	option = {
		name = EVTOPTA_TOG_664
		tooltip_info = homosexual

		event_target:second_homosexual_guest = {
			character_event = { id = TOG.665 }
		}

		add_lover = event_target:second_homosexual_guest

		random = {
			chance = 50

			custom_tooltip = { text = EVTTOOLTIP_TOG_669 }
		}
	}
}

# Homosexual lovers (Guest 2)
character_event = {
	id = TOG.665
	desc = EVTDESC_TOG_664
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion
	portrait = event_target:first_homosexual_guest

	is_triggered_only = yes

	immediate = {
		FROM = { save_event_target_as = other_homosexual_guest } # For loc
	}

	option = {
		name = EVTOPTA_TOG_664
		tooltip_info = homosexual

		random = {
			chance = 50

			custom_tooltip = {
				text = EVTTOOLTIP_TOG_669

				character_event = { id = TOG.669 }
				FROM = { character_event = { id = TOG.669 } }

				liege = {
					character_event = { id = TOG.670 }

					any_vassal = {
						limit = {
							has_character_flag = blot_feast_vassal

							NOR = {
								character = event_target:first_homosexual_guest
								character = event_target:second_homosexual_guest
							}
						}

						character_event = { id = TOG.670 }
					}
				}
			}
		}

		tooltip = {
			add_lover = FROM
		}
	}
}

# Homosexual Caught
character_event = {
	id = TOG.669
	desc = EVTDESC_TOG_669
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_TOG_669

		liege = {
			show_scope_change = no

			if = {
				limit = { trait = homosexual }

				opinion = {
					name = opinion_homosexual_sympathy
					who = ROOT
				}
			}

			else = {
				opinion = {
					name = opinion_feast_scandal
					who = ROOT
				}
			}

			any_vassal = {
				show_scope_change = no

				limit = {
					has_character_flag = blot_feast_vassal
					NOT = { character = ROOT }
				}

				if = {
					limit = { trait = homosexual }

					opinion = {
						name = opinion_homosexual_sympathy
						who = ROOT
					}
				}
				else = {
					opinion = {
						name = opinion_feast_scandal
						who = ROOT
					}
				}
			}
		}
	}
}

# Homosexuals Caught (Host and Other Guests)
character_event = {
	id = TOG.670
	desc = EVTDESC_TOG_670
	picture = GFX_evt_viking_throneroom_oldgods
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA_TOG_670

		trigger = {
			NOT = { trait = homosexual }
		}

		tooltip = {
			opinion = {
				name = opinion_feast_scandal
				who = event_target:first_homosexual_guest
			}

			opinion = {
				name = opinion_feast_scandal
				who = event_target:second_homosexual_guest
			}
		}
	}

	option = {
		name = EVTOPTB_TOG_670
		tooltip_info = homosexual

		trigger = { trait = homosexual }

		tooltip = {
			opinion = {
				name = opinion_homosexual_sympathy
				who = event_target:first_homosexual_guest
			}

			opinion = {
				name = opinion_homosexual_sympathy
				who = event_target:second_homosexual_guest
			}
		}
	}
}

###########################################
# Flag management                         #
###########################################

# Safety catch - clears character flags and modifiers
character_event = {
	id = TOG.699

	is_triggered_only = yes
	hide_window = yes

	immediate = {
		clr_character_flag = holding_blot
		clr_character_flag = blot_feast
		clr_character_flag = attending_blot
		clr_character_flag = blot_feast_vassal
		clr_character_flag = feast_drunkard
		clr_character_flag = feast_gluttonous
		clr_character_flag = feast_lunatic
		clr_character_flag = feast_lustful
		clr_character_flag = feast_homosexual
		clr_character_flag = feast_friendship
		clr_character_flag = do_not_disturb
		clear_flags_with_prefix = blot_sacrifice_
	}
}