﻿namespace = bell_special_yearly

#The Bell of Huesca special yearly events, by Isabella Welch

# bell_special_yearly 1000 - You get the first chance to string up a faction leader
# bell_special_yearly 1500 - Stringing up the victim (using a piece of the old bell), deciding on the second one
# bell_special_yearly 2000 - Strangle the second victim with their own lute strings
# bell_special_yearly 3000 - Another musical death
# bell_special_yearly 4000 - Keep the completed bell a secret (sitting in your garden pulling up the heads of roses)
# bell_special_yearly 5000 - Bell gets discovered if kept a secret
# bell_special_yearly 6000 - Putting on a concert with the bell, the horror

# ones that need to go into the on_action are 1000, 2000, 3000, 4000, 5000 and 6000. 1500 is triggered directly from 1000

#scripted_trigger valid_faction_member_trigger = {
#	OR = {
#		is_leading_faction_type = independence_faction
#		is_leading_faction_type = liberty_faction
#		is_leading_faction_type = claimant_faction
#		is_leading_faction_type = populist_faction
#	}
#	primary_heir != this
#	is_available_ai_adult = yes
#}

scripted_trigger valid_faction_member_trigger = { #changed from faction leaders to make event easier to trigger /Ola 
	NOT = { is_primary_heir_of = root }
	is_a_faction_member = yes		
	is_available_ai_adult = yes
}

scripted_trigger eligible_to_create_bell_trigger = {
	is_available = yes
	OR = {
		has_trait = torturer
		has_trait = paranoid #added to make it easier to trigger - Ola
		has_trait = schemer #added to make it easier to trigger - Ola
		has_trait = vengeful #added to make it easier to trigger - Ola
		has_trait = callous #added to make it easier to trigger - Ola
		has_trait = sadistic
		dread >= high_dread
		tyranny >= high_tyranny
	}
	NOR = { 
		has_trait = infirm
		has_trait = blind
	}
}

scripted_trigger family_or_close_to_dead_faction_member_1_trigger = {
	OR = {
		is_close_family_of = scope:faction_member_1
		has_relation_friend = scope:faction_member_1
	}
	NOR = {
		has_trait = craven
	}
	is_available_ai_adult = yes
}
scripted_trigger family_or_close_to_dead_faction_member_2_trigger = {
	OR = {
		is_close_family_of = scope:faction_member_2
		has_relation_friend = scope:faction_member_2
	}
	NOR = {
		has_trait = craven
	}
	is_available_ai_adult = yes
}
scripted_trigger family_or_close_to_dead_faction_member_3_trigger = {
	OR = {
		is_close_family_of = scope:faction_member_3
		has_relation_friend = scope:faction_member_3
	}
	NOR = {
		has_trait = craven
	}
	is_available_ai_adult = yes
}

#visiting the visigothic church and encountering a dangerous faction member there

bell_special_yearly.1000 = {
	type = character_event
	title = bell_special_yearly.1000.t
	desc = bell_special_yearly.1000.desc
	theme = murder_scheme
	override_background = { reference = temple_church }
	left_portrait = { 
		character = root
		animation = scheme
	}

	lower_right_portrait = { #to emphasize that he isn't physically present in the church yet /Ola
		character = scope:faction_member_1
	}

	trigger = {
		any_vassal = {
			valid_faction_member_trigger = yes
			count >= 3
		}
		eligible_to_create_bell_trigger = yes
		
		exists = cp:councillor_steward

		cp:councillor_steward = {
			valid_faction_member_trigger = no #added to stop weirdness with him being murdered in the church he sent you to /Ola 
		}
	}

	weight_multiplier = {
		base = 0.25
		modifier = {
			add = 0.5
			has_trait = vengeful
		}
		modifier = {
			add = 0.5
			has_trait = arbitrary
		}	
		modifier = {
			add = 1
			has_trait = murderer #seemed a reasonable addition /Ola 
		}	
		modifier = {
			add = 1
			has_trait = kinslayer #seemed a reasonable addition /Ola 
		}	
	}

	immediate = {
		random_vassal = {
			limit = {
				valid_faction_member_trigger = yes
			}
			save_scope_as = faction_member_1
			joined_faction = {
				save_scope_as = faction_member_1_faction
			}
		}
		cp:councillor_steward = { save_scope_as = steward }
	}

	option = { 
		name = bell_special_yearly.1000.a
		custom_tooltip = bell_special_yearly.1000.a.tt
		trigger_event = {
			id = bell_special_yearly.1500
			days = 4
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = -0.5
				ai_boldness = 0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = bell_special_yearly.1000.b

		if = {
			limit = { has_lifestyle = intrigue_lifestyle }
			add_intrigue_lifestyle_xp = medium_lifestyle_xp
		}

		else = {
			add_stress = minor_stress_loss #Just to get something if you don't have Intrigue lifestyle /Ola
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}
}

#killing the faction member and deciding, maybe you will do it again

bell_special_yearly.1500 = {
	type = character_event
	title = bell_special_yearly.1000.t
	desc = bell_special_yearly.1500.desc
	theme = murder_scheme
	override_background = { reference = temple_church }

	left_portrait = { 
		character = root
		animation = scheme
	}

	right_portrait = { 
		character = scope:faction_member_1
		animation = fear
	}

	trigger = {

	}

	immediate = {
		#with all of these, a possible person to discover the murders is added to the list
		every_courtier_or_guest = {
			limit = {
				family_or_close_to_dead_faction_member_1_trigger = yes
			}
			add_to_list = possible_bell_discoverers
		}
		every_vassal_or_below = {
			limit = {
				family_or_close_to_dead_faction_member_1_trigger = yes
			}
			add_to_list = possible_bell_discoverers
		}
		unknown_bell_murder_effect = {
			VICTIM = scope:faction_member_1
			MURDERER = root
		}
	}


	option = { # Let's do it again! 
		name = bell_special_yearly.1500.a
		custom_tooltip = bell_special_yearly.1500.a.tt
		custom_tooltip = bell_special_yearly.1500.discovery.tt

		if = {
			limit = { is_developer_testing_trigger = yes } # Removed the two month wait time when debugging event
			custom_tooltip = debug_generic_option_shortened_trigger_can_disable
			trigger_event = {
				id = bell_special_yearly.2000
				days = 4
			}
		}
		else = {
			trigger_event = {
				id = bell_special_yearly.2000
				days = { 40 60 }
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = -0.5
				ai_boldness = 0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = { # Let's never speak of this...
		name = bell_special_yearly.1500.b
		stress_impact = {
			craven = minor_stress_loss
			arrogant = minor_stress_gain
			ambitious = medium_stress_gain
			torturer = medium_stress_gain
			sadistic = medium_stress_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_boldness = -0.5
				ai_vengefulness = -0.5
				ai_compassion = 0.8
			}
		}
	}
}

#Second faction leader murder

bell_special_yearly.2000 = {
	type = character_event
	title = bell_special_yearly.1000.t
	desc = bell_special_yearly.2000.desc
	theme = murder_scheme

	left_portrait = { 
		character = root
		animation = spymaster 
		outfit_tags = {
			western_commoner_outfit 
			iberian_christian_shrimp_wrap
		}
	}

	right_portrait = { 
		character = scope:faction_member_2
		animation = fear
	}

	trigger = {
		any_vassal = {
			valid_faction_member_trigger = yes
			count >= 1
		}
		eligible_to_create_bell_trigger = yes
	}

	immediate = {
		random_vassal = {
			limit = {
				valid_faction_member_trigger = yes
			}
			save_scope_as = faction_member_2
			joined_faction = {
				save_scope_as = faction_member_2_faction
			}
		}
		every_courtier_or_guest = {
			limit = {
				family_or_close_to_dead_faction_member_2_trigger = yes
			}
			add_to_list = possible_bell_discoverers
		}
		every_vassal_or_below = {
			limit = {
				family_or_close_to_dead_faction_member_2_trigger = yes
			}
			add_to_list = possible_bell_discoverers
		}
		unknown_bell_murder_effect = {
			VICTIM = scope:faction_member_2
			MURDERER = root
		}
	}


	option = { # Let's do it again
		name = bell_special_yearly.2000.a
		custom_tooltip = bell_special_yearly.1500.a.tt
		custom_tooltip = bell_special_yearly.1500.discovery.tt
		add_character_flag = can_have_bell_special_yearly_3000

		if = {
			limit = { is_developer_testing_trigger = yes }
			custom_tooltip = debug_generic_option_shortened_trigger_can_disable
			trigger_event = {
				id = bell_special_yearly.3000
				days = 4
			}
		}
		else = {
			trigger_event = {
				id = bell_special_yearly.3000
				days = { 40 60 }
			}
		}
		set_variable = {
			name = bell_discovery
			value = 0
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = -0.75
				ai_boldness = 0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = { # Let's leave it be
		name = bell_special_yearly.2000.b
		custom_tooltip = bell_special_yearly.1500.b.tt
		stress_impact = {
			craven = minor_stress_loss
			arrogant = minor_stress_gain
			ambitious = medium_stress_gain
			torturer = medium_stress_gain
			sadistic = medium_stress_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_boldness = -0.5
				ai_vengefulness = -0.5
			}
		}
	}
}

#Final faction leader murder

bell_special_yearly.3000 = {
	type = character_event
	title = bell_special_yearly.1000.t
	desc = bell_special_yearly.3000.desc
	theme = murder_scheme

	left_portrait = { 
		character = root
		animation = spymaster 
	}

	right_portrait = { 
		character = scope:faction_member_3
		animation = fear
	}

	trigger = {
		has_character_flag = can_have_bell_special_yearly_3000
		any_vassal = {
			valid_faction_member_trigger = yes
			count >= 1
		}
		eligible_to_create_bell_trigger = yes
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		random_vassal = {
			limit = {
				valid_faction_member_trigger = yes
			}
			save_scope_as = faction_member_3
			joined_faction = {
				save_scope_as = faction_member_3_faction
			}
		}
		every_courtier_or_guest = {
			limit = {
				family_or_close_to_dead_faction_member_3_trigger = yes
			}
			add_to_list = possible_bell_discoverers
		}
		every_vassal_or_below = {
			limit = {
				family_or_close_to_dead_faction_member_3_trigger = yes
			}
			add_to_list = possible_bell_discoverers
		}
		unknown_bell_murder_effect = {
			VICTIM = scope:faction_member_3
			MURDERER = root
		}
	}

	after = {
		remove_character_flag = can_have_bell_special_yearly_3000
		if = {
			limit = { is_developer_testing_trigger = yes }
			custom_tooltip = debug_generic_option_shortened_trigger_can_disable
			trigger_event = {
				id = bell_special_yearly.4000
				days = 4
			}
		}
		else = {
			trigger_event = {
				id = bell_special_yearly.4000
				days = { 40 60 }
			}
		}
	}

	option = { # Act excited about it
		name = bell_special_yearly.3000.a
		add_prestige = medium_prestige_gain
		change_variable = {
			name = bell_discovery
			add = 1
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = -0.80
			}
		}
	}

	option = { # Act nonchalant about it
		name = bell_special_yearly.3000.b
		
		if = {
			limit = { has_lifestyle = intrigue_lifestyle }
			add_intrigue_lifestyle_xp = medium_lifestyle_xp
		}

		else = {
			add_stress = minor_stress_loss #Just to get something if you don't have Intrigue lifestyle /Ola
		}

		change_variable = {
			name = bell_discovery
			add = -1
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.1
			}
		}
	}
}

#Picking up rose heads in the garden, possibly getting caught


bell_special_yearly.4000 = {
	type = character_event
	title = bell_special_yearly.1000.t
	desc = {
		desc = bell_special_yearly.4000.desc
		triggered_desc = {
			trigger = {
				scope:bell_discoverer = {
					exists = yes
				}
			}
			desc = bell_special_yearly.4000.desc_discoverer
		}
	}
	theme = murder_scheme
	override_background = { reference = garden }

	left_portrait = { 
		character = root
		animation = happiness # optional, can hit tab and delete
	}

	right_portrait = { 
		character = scope:bell_discoverer
		animation = schadenfreude
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		random_in_list = {
			limit = { is_available_ai_adult = yes }
			list = possible_bell_discoverers
			weight = {
				base = 100
				modifier = {
					add = 50
					has_lifestyle = intrigue_lifestyle
				}
				modifier = {
					add = 50
					intrigue >= high_skill_rating
				}
				modifier = {
					add = 50
					is_powerful_vassal = yes
				}
				modifier = {
					add = 50
					has_relation_rival = root
				}
				modifier = {
					add = -50
					has_trait = trusting
				}
			}
			save_scope_as = bell_discoverer
		}
	}

	option = { # Get excited, put on a concert with the bell
		name = bell_special_yearly.4000.a
		custom_tooltip = bell_special_yearly.4000.a.tt
		if = {
			limit = { has_royal_court = yes has_dlc_feature = royal_court }
			change_current_court_grandeur = medium_court_grandeur_gain
		}
		if = {
			limit = { is_developer_testing_trigger = yes }
			custom_tooltip = debug_generic_option_shortened_trigger_can_disable
			trigger_event = {
				id = bell_special_yearly.6000
				days = 4
			}
		}
		else = {
			trigger_event = {
				id = bell_special_yearly.6000
				days = { 40 60 }
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = -0.8
				ai_boldness = 0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = { # Try to keep the secret
		name = bell_special_yearly.4000.b
		if = {
			limit = {
				scope:bell_discoverer = {
					exists = yes
				}
			}
			duel = {
				skill = intrigue
				target = scope:bell_discoverer
				30 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 2.5
					}
					desc = bell_discovery_success_effect
					send_interface_toast = {
						title = bell_discovery_success_effect
						left_icon = scope:bell_discoverer
					}
					modifier = {
						var:bell_discovery >= 0
						add = 5
					}
					if = {
						limit = { has_lifestyle = intrigue_lifestyle }
						add_intrigue_lifestyle_xp = medium_lifestyle_xp
					}
					else = { add_stress = minor_stress_loss } #Just to get something if you don't have Intrigue lifestyle /Ola
				}
				40 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -2.5
					}
					modifier = {
						scope:bell_discoverer = { has_trait = trusting }
						add = 5
					}
					modifier = {
						var:bell_discovery < 0
						add = 5
					}
					desc = bell_discovery_failure_effect
					trigger_event = {
						id = bell_special_yearly.5000
						days = { 10 20 }
					}
				}
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = -0.5
			}
		}
	}
}

#Bell getting discovered, you are deposed and killed

bell_special_yearly.5000 = {
	type = character_event
	title = bell_special_yearly.1000.t
	desc = bell_special_yearly.5000.desc
	theme = prison
	override_background = { reference = temple_church }

	left_portrait = { 
		character = root
		animation = fear # optional, can hit tab and delete
	}

	right_portrait = { 
		character = scope:bell_discoverer
		animation = schadenfreude
	}

	after = {
		death = {
			death_reason = death_bell_revenge
			killer = scope:bell_discoverer
		}
	}

	option = { # This is just informing you of the outcome
		name = bell_special_yearly.5000.a
	}
}

# Putting on the concert in the ruined church

bell_special_yearly.6000 = {
	type = character_event
	title = bell_special_yearly.1000.t
	desc = bell_special_yearly.6000.desc
	theme = murder_scheme
	override_background = { reference = temple_church }

	left_portrait = { 
		character = root
		animation = scheme # optional, can hit tab and delete
	}

	immediate = {
		add_tyranny = major_tyranny_gain
		add_dread = major_dread_gain

		show_as_tooltip = { scope:bell_secret = { expose_secret = root } }
	}

	option = { 
		name = bell_special_yearly.6000.a
		give_nickname = nick_the_requiem
		ai_chance = {
			base = 50
		}

		hidden_effect = { scope:bell_secret = { expose_secret = root } }
	}

	option = {
		name = bell_special_yearly.6000.b
		give_nickname = nick_the_bell_keeper
		ai_chance = {
			base = 50
		}

		hidden_effect = { scope:bell_secret = { expose_secret = root } }
	}
}
