﻿namespace = ep3_story_cycle_harrying

#⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀
#⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣀⣀⣤⣴⡞⠀⠀⣀⣴⣿⠀⠀
#⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⠿⣿⣿⢿⣿⣷⣶⣿⣿⣿⡟⠀⠀
#⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡏⠀⠈⠁⠘⠿⠟⠛⢉⣽⣿⠃⠀⠀
#⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡘⠃⠀⠀⠀⠀⠀⠀⢰⣿⣿⣋⣀⡄⠀
#⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣦⠀⠀⠀⠀⠀⣀⣬⣿⣿⡿⠋⠀⠀
#⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣷⣄⠀⣀⣀⣻⣿⣏⣉⠀⠀⠀⠀
#⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣦⡙⢿⣿⣿⣿⣿⣿⡷⠈⠙⠛⠛⠋⠁⠀⠀⠀⠀
#⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣄⠙⢿⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#⠀⠀⠀⠀⠀⠀⣠⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#⠀⠀⢀⣴⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#⠀⠠⣿⣿⠟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
#⠀⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

### Maintenance events
## 0001-0999
# by Nick Meredith

# Harrying ends - the Aethelings are no more
ep3_story_cycle_harrying.0001 = {
	type = character_event
	title = ep3_story_cycle_harrying.0001.t
	desc = {
		desc = ep3_story_cycle_harrying.0001.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					this = scope:ruler_england
				}
				desc = ep3_story_cycle_harrying.0001.desc.william
			}
			triggered_desc = {
				trigger = {
					this = character:90028
				}
				desc = ep3_story_cycle_harrying.0001.desc.hereward
			}
			desc = ep3_story_cycle_harrying.0001.desc.therest
		}
	}

	theme = harrying
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = { root != this }
		character = scope:ruler_england
		animation = personality_honorable
	}

	immediate = {
		title:k_england.holder = {
			save_scope_as = ruler_england
		}
		title:k_england = {
			save_scope_as = england
		}
		custom_tooltip = harrying_end
	}

	option = { # Hereward
		name = ep3_story_cycle_harrying.0001.a

		trigger = {
			this = character:90028
		}

		stress_impact = {
			base = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #William
		name = ep3_story_cycle_harrying.0001.b

		trigger = {
			this = scope:ruler_england
		}

		stress_impact = {
			base = major_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #All others
		name = ep3_story_cycle_harrying.0001.b

		trigger = {
			NOR = {
				this = scope:ruler_england
				this = character:90028
			}
		}

		ai_chance = {
			base = 100
		}
	}
}

# Harrying ends - an Aetheling rules
ep3_story_cycle_harrying.0002 = {
	type = character_event
	title = ep3_story_cycle_harrying.0002.t
	desc = {
		desc = ep3_story_cycle_harrying.0002.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					this = scope:ruler_england
				}
				desc = ep3_story_cycle_harrying.0002.desc.ruler
			}
			triggered_desc = {
				trigger = {
					this = character:90028
				}
				desc = ep3_story_cycle_harrying.0002.desc.hereward
			}
			desc = ep3_story_cycle_harrying.0002.desc.therest
		}
	}
	theme = harrying
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = { root != this }
		character = scope:ruler_england
		animation = personality_honorable
	}

	immediate = {
		title:k_england.holder = {
			save_scope_as = ruler_england
		}
		title:k_england = {
			save_scope_as = england
		}
		custom_tooltip = harrying_end
	}

	option = { # Hereward
		name = ep3_story_cycle_harrying.0002.a

		trigger = {
			this = character:90028
		}

		stress_impact = {
			base = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { # Ruler
		name = ep3_story_cycle_harrying.0002.b

		trigger = {
			this = scope:ruler_england
		}

		stress_impact = {
			base = major_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #All others
		name = ep3_story_cycle_harrying.0002.b

		trigger = {
			NOR = {
				this = scope:ruler_england
				this = character:90028
			}
		}

		ai_chance = {
			base = 100
		}
	}
}

# Harrying ends - neither Normans nor Aethelings rule
ep3_story_cycle_harrying.0003 = {
	type = character_event
	title = ep3_story_cycle_harrying.0003.t
	desc = ep3_story_cycle_harrying.0003.desc
	theme = harrying
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = { root != this }
		character = scope:ruler_england
		animation = personality_honorable
	}

	immediate = {
		title:k_england.holder = {
			save_scope_as = ruler_england
		}
		title:k_england = {
			save_scope_as = england
		}
		custom_tooltip = harrying_end
	}

	option = { # Hereward
		name = ep3_story_cycle_harrying.0003.a

		trigger = {
			this = character:90028
		}

		stress_impact = {
			base = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { # Ruler
		name = ep3_story_cycle_harrying.0003.b

		trigger = {
			this = scope:ruler_england
		}

		stress_impact = {
			base = major_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #All others
		name = ep3_story_cycle_harrying.0003.b

		trigger = {
			NOR = {
				this = scope:ruler_england
				this = character:90028
			}
		}

		ai_chance = {
			base = 100
		}
	}
}

# Harrying ends - 100 years have passed
ep3_story_cycle_harrying.0004 = {
	type = character_event
	title = ep3_story_cycle_harrying.0004.t
	desc = {
		desc = ep3_story_cycle_harrying.0004.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					this = scope:ruler_england
				}
				desc = ep3_story_cycle_harrying.0004.desc.ruler
			}
			triggered_desc = {
				trigger = {
					this.culture = culture:anglo_saxon
				}
				desc = ep3_story_cycle_harrying.0004.desc.anglo_saxon
			}
			desc = ep3_story_cycle_harrying.0004.desc.therest
		}
	}
	theme = harrying
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = { root != this }
		character = scope:ruler_england
		animation = personality_honorable
	}

	immediate = {
		title:k_england.holder = {
			save_scope_as = ruler_england
		}
		title:k_england = {
			save_scope_as = england
		}
		custom_tooltip = harrying_end
	}

	option = { # Anglo-Saxons
		name = ep3_story_cycle_harrying.0004.a

		trigger = {
			this.culture = culture:anglo_saxon
		}

		stress_impact = {
			base = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { # Ruler
		name = ep3_story_cycle_harrying.0004.b

		trigger = {
			this = scope:ruler_england
		}

		stress_impact = {
			base = major_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #All others
		name = ep3_story_cycle_harrying.0004.b

		trigger = {
			NOR = {
				this = scope:ruler_england
				this.culture = culture:anglo_saxon
			}
		}

		ai_chance = {
			base = 100
		}
	}
}

##################################################
# William Events
# by Nick Meredith
# 1000-1999
##################################################

#Burn crops
#Burn down villages
#Construct castles
#Improve infrastructure North/South
#Revoke titles
#Slaughter supposed conspirators
#Build spy network
#Rebuild villages in grids
#Decide the fate of a captive Aetheling
#Receive a desperate northerner
#Mutilate a captive

# Burn crops
ep3_story_cycle_harrying.1000 = {
	type = character_event
	title = ep3_story_cycle_harrying.1000.t
	desc = ep3_story_cycle_harrying.1000.desc
	theme = harrying
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:aetheling
		animation = anger
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		any_vassal = {
			culture = culture:anglo_saxon
			highest_held_title_tier > tier_county
		}
	}

	immediate = {
		random_vassal = {
			limit = {
				culture = culture:anglo_saxon
				highest_held_title_tier > tier_county
			}
			save_scope_as = aetheling
		}
		scope:aetheling.primary_title = {
			save_scope_as = crop_duchy
		}
		ep3_harrying_widget_setup_effect = yes

		save_scope_as = root_scope
	}

	option = { #Burn all the crops
		name = ep3_story_cycle_harrying.1000.a

		add_dread = medium_dread_gain

		add_tyranny = minor_tyranny_gain

		ep3_increase_pacification_effect = { AMOUNT = harrying_medium_increase_value }

		scope:crop_duchy = {
			change_county_control = 15
			every_direct_de_jure_vassal_title = {
				custom = every_county_in_duchy_aetheling
				add_county_modifier = {
					modifier = all_crops_burned
					years = 5
				}
			}
		}

		culture = {
			change_cultural_acceptance = {
				target = scope:aetheling.culture
				value = minor_cultural_acceptance_loss
				desc = harrying_of_the_north_tt
			}
		}

		stress_impact = {
			wrathful = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			vengeful = minor_stress_impact_loss
			compassionate = major_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = -1
			}
		}
	}

	option = { #Burn most of them, leaving enough for subsistence
		name = ep3_story_cycle_harrying.1000.b

		add_dread = minor_dread_gain

		scope:crop_duchy = {
			change_county_control = 5
			every_direct_de_jure_vassal_title = {
				custom = every_county_in_duchy_aetheling
				add_county_modifier = {
					modifier = crops_burned
					years = 5
				}
			}
		}

		culture = {
			change_cultural_acceptance = {
				target = scope:aetheling.culture
				value = miniscule_cultural_acceptance_loss
				desc = harrying_of_the_north_tt
			}
		}

		stress_impact = {
			calm = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			wrathful = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.5
			}
		}
	}

	option = { #Exact a levy of crops
		name = ep3_story_cycle_harrying.1000.c

		add_treasury_or_gold = medium_treasury_or_gold_value

		scope:crop_duchy = {
			change_county_control = -10
			every_direct_de_jure_vassal_title = {
				custom = every_county_in_duchy_aetheling
				add_county_modifier = {
					modifier = crop_levy
					years = 5
				}
			}
		}

		every_vassal = {
			custom = every_minority_vassal
			vassal_stance = minority
			add_opinion = {
				target = root 
				modifier = annoyed_opinion
				opinion = -15
			}
		}	

		stress_impact = {
			sadistic = medium_stress_impact_gain
			vengeful = major_stress_impact_gain
			compassionate = miniscule_stress_impact_loss
			forgiving = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_compassion = 1
			}
		}
	}
	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

# Build on the Great North Road
ep3_story_cycle_harrying.1005 = {
	type = character_event
	title = ep3_story_cycle_harrying.1005.t
	desc = ep3_story_cycle_harrying.1005.desc
	theme = harrying
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:marshal
		animation = chancellor
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		any_vassal = {
			culture = culture:anglo_saxon
		}
		OR = { #Ensure owns at least one county on the route
			has_title = title:c_middlesex
			has_title = title:c_hertfordshire
			has_title = title:c_bedford
			has_title = title:c_northamptonshire
			has_title = title:c_leicestershire
			has_title = title:c_nottinghamshire
			has_title = title:c_west_riding
		}
		exists = cp:councillor_marshal
	}

	immediate = {
		every_county_in_region = {
			region = world_europe_west_britannia
			limit = { # All counties along the Great North Road...ish
				OR = {
					this = title:c_middlesex
					this = title:c_hertfordshire
					this = title:c_bedford
					this = title:c_northamptonshire
					this = title:c_leicestershire
					this = title:c_nottinghamshire
					this = title:c_west_riding
				}
				OR = {
					holder = root
					holder.top_liege = root
				}
			}
			add_to_list = great_north_road
		}
		cp:councillor_marshal = {
			save_scope_as = marshal
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Rebuild and stock the road with armed guards
		name = ep3_story_cycle_harrying.1005.a

		remove_treasury_or_gold = major_treasury_or_gold_value

		every_in_list = {
			list = great_north_road
			custom = ep3_story_cycle_harrying.1005.a.tt
			add_county_modifier = {
				modifier = ep3_gnr_guards_modifier
				years = 15
			}
		}

		stress_impact = {
			craven = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			lazy = minor_stress_impact_gain
			greedy = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
				ai_greed = -1
			}
		}
	}

	option = { #Rebuild the road
		name = ep3_story_cycle_harrying.1005.b

		remove_treasury_or_gold = major_treasury_or_gold_value

		every_in_list = {
			list = great_north_road
			custom = ep3_story_cycle_harrying.1005.a.tt
			add_county_modifier = {
				modifier = ep3_gnr_modifier
				years = 10
			}
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_gain
			greedy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.5
			}
		}
	}

	option = { #Destroy the northern parts of the road; deny them the passage
		name = ep3_story_cycle_harrying.1005.c

		ep3_increase_pacification_effect = { AMOUNT = harrying_medium_increase_value }

		every_in_list = {
			list = great_north_road
			custom = ep3_story_cycle_harrying.1005.c.tt1
			limit = {
				holder.culture = culture:anglo_saxon
			}
			add_county_modifier = {
				modifier = ep3_gnr_negative_modifier
				years = 10
			}
		}

		stress_impact = {
			callous = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			vengeful = minor_stress_impact_loss
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = -1
			}
		}
	}
	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

# Decide the fate of a captive Aetheling
ep3_story_cycle_harrying.1010 = {
	type = character_event
	title = ep3_story_cycle_harrying.1010.t
	desc = ep3_story_cycle_harrying.1010.desc
	theme = harrying
	override_background = { reference = dungeon }
	left_portrait = {
		character = root
		animation = spymaster
	}
	right_portrait = {
		character = scope:captured
		animation = prisondungeon
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		any_prisoner = {
			is_ai = yes
			is_adult = yes
			culture = culture:anglo_saxon
			is_lowborn = no
		}
	}

	immediate = {
		save_scope_as = actor
		random_prisoner = {
			limit = {
				is_ai = yes
				is_adult = yes
				culture = culture:anglo_saxon
				is_lowborn = no
			}
			save_scope_as = captured
			save_scope_as = recipient
		}
		save_scope_as = root_scope #for tooltip
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Kill him
		name = ep3_story_cycle_harrying.1010.a

		execute_prisoner_effect = {
			VICTIM = scope:captured
			EXECUTIONER = root
		}

		ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }
		ep3_increase_pacification_effect = { AMOUNT = harrying_medium_increase_value }

		stress_impact = {
			callous = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			compassionate = major_stress_impact_gain
			just = major_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_honor = -1
			}
		}
	}

	option = { #Mutilate and release him
		name = ep3_story_cycle_harrying.1010.b

		add_dread = miniscule_dread_gain

		disfigure_recipient_effect = yes
		torture_blind_castrate_disfigure_opinion_effect = { VERB = disfigured }

		stress_impact = {
			sadistic = minor_stress_impact_loss
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_honor = -0.5
			}
		}
	}

	option = { #You will be a Norman, now
		name = ep3_story_cycle_harrying.1010.c

		duel = {
			skills = { diplomacy intrigue }
			target = scope:captured
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.1010.c.success

				show_as_tooltip = { #To resolve in follow-up, due to learn language scheme
					scope:captured = {
						set_culture = culture:norman
					}
				}

				trigger_event = {
					id = ep3_story_cycle_harrying.1011
					days = { 1 2 }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.1010.c.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.1010.c.failure
	
					add_prestige = medium_prestige_loss
					every_vassal = { 
						vassal_stance = glory_hound
						custom = every_glory_hound_vassal
						add_opinion = {
							modifier = tournament_mocked_opinion #Re-using
							target = root
							opinion = -15
						}
					}
				}
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_compassion = 1
			}
		}
	}

	option = { #Let them rot
		name = ep3_story_cycle_harrying.1010.d

		add_character_modifier = {
			modifier = ep3_honourable_jailor_modifier
			years = 15
		}

		stress_impact = {
			base = miniscule_stress_impact_loss
			sadistic = major_stress_impact_gain
			compassionate = miniscule_stress_impact_loss
			just = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_compassion = 1
			}
		}
	}
	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

#Follow-up on acceptance
ep3_story_cycle_harrying.1011 = {
	type = character_event
	title = ep3_story_cycle_harrying.1011.t
	desc = {
		desc = ep3_story_cycle_harrying.1011.desc
		triggered_desc = {
			trigger = {
				scope:spouse_courtier = {
					exists = this 
				}			
			}
			desc = ep3_story_cycle_harrying.1011.desc.spouse
		}
	}
	theme = harrying
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:captured
		animation = happiness
	}
	lower_center_portrait = {
		trigger = {
			scope:spouse_courtier = {
				exists = this
			}
		}
		character = scope:spouse_courtier
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	immediate = {
		if = { #Ugly if/else block starts here!
			limit = {
				scope:captured = {
					is_married = no
					is_betrothed = no
				}
			}
			if = { #Grab a courtier
				limit = {
					AND = {
						scope:captured = { is_female = yes }
						any_courtier = {
							is_female = no
							is_married = no
							is_betrothed = no
							is_adult = yes
							culture = culture:norman
							age > scope:captured.age_plus_10
							age < scope:captured.age_minus_10
						}
					}
				}
				random_courtier = {
					limit = {
						is_female = no
						is_married = no
						is_betrothed = no
						is_adult = yes
						culture = culture:norman
						age > scope:captured.age_plus_10
						age < scope:captured.age_minus_10
					}
					weight = {
						base = 1
						modifier = {
							factor = 10
							is_lowborn = no #Always good to do noble marriages where possible
						}
						modifier = {
							factor = 5
							is_close_or_extended_family_of = root #And what nobler than the king?
						}
					}
					save_scope_as = spouse_courtier
				}
			}
			else_if = { #Gender reverse
				limit = {
					AND = {
						scope:captured = { is_female = no }
						any_courtier = {
							is_female = yes
							is_married = no
							is_betrothed = no
							is_adult = yes
							culture = culture:norman
							age > scope:captured.age_plus_10
							age < scope:captured.age_minus_10
						}
					}
				}
				random_courtier = {
					limit = {
						is_female = yes
						is_married = no
						is_betrothed = no
						is_adult = yes
						culture = culture:norman
						age > scope:captured.age_plus_10
						age < scope:captured.age_minus_10
					}
					weight = {
						base = 1
						modifier = {
							factor = 10
							is_lowborn = no
						}
						modifier = {
							factor = 5
							is_close_or_extended_family_of = root
						}
					}
					save_scope_as = spouse_courtier
				}
			}
			else = { #Just in case
				hidden_effect = {
					create_character = {
						location = root.location
						random_traits = yes
						faith = root.faith
						culture = culture:norman
						age = scope:captured.age
						gender_female_chance = {
							if = {
								limit = { scope:captured = { is_female = yes } }
								add = 0
							}
							else = { add = 100 }
						}
						save_scope_as = spouse_courtier
					}
				}
			}
		}

		if = { #Just to ensure she's actually part of your court, if generated
			limit = {
				scope:spouse_courtier = {
					exists = this
					NOT = {
						is_courtier_of = root
					}
				}
			}
			hidden_effect = {
				add_courtier = scope:spouse_courtier
			}
		}

		ep3_harrying_widget_setup_effect = yes

		ep3_increase_pacification_effect = { AMOUNT = harrying_medium_increase_value }
	}

	option = { #You'll get married to a nice Norman lad/lass! Also learn the language
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { 
							scope:spouse_courtier = {
								exists = this 
							}
						}
						desc = ep3_story_cycle_harrying.1011.a.spouselanguage
					}
					desc = ep3_story_cycle_harrying.1011.a.language
				}
			}
		}

		scope:captured = {
			if = {
				limit = {
					scope:spouse_courtier = {
						exists = this
					}
				}
				marry = scope:spouse_courtier
			}
			if = {
				limit = {
					can_start_scheme = {
						type = learn_language
						target_character = root
					}
				}
				start_scheme = {
					type = learn_language
					target_character = root
				}
			}
			release_from_prison = yes
			if = {
				limit = {
					highest_held_title_tier = tier_unlanded
				}
				change_liege = {
					liege = root
					change = scope:change
				}
				add_courtier = scope:captured
			}
		}

		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:captured
			opinion = 35
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			patient = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_gain
			impatient = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_compassion = 1
			}
		}
	}

	option = { #Go now, and be free
		name = ep3_story_cycle_harrying.1011.b

		scope:captured = {
			release_from_prison = yes
			if = {
				limit = {
					highest_held_title_tier = tier_unlanded
				}
				change_liege = {
					liege = root
					change = scope:change
				}
			}
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			patient = miniscule_stress_impact_loss
			lazy = miniscule_stress_impact_gain
			impatient = miniscule_stress_impact_gain
		}

		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:captured
			opinion = 50
		}

		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 1
			}
		}
	}

	after = {
		hidden_effect = {
			scope:captured = {
				set_culture = culture:norman
			}
		}
		ep3_harrying_widget_clear_effect = yes
	}
}

# Punish a village
ep3_story_cycle_harrying.1015 = {
	type = character_event
	title = ep3_story_cycle_harrying.1015.t
	desc = ep3_story_cycle_harrying.1015.desc
	theme = harrying
	override_background = { reference = burning_building }
	override_effect_2d = smoke
	left_portrait = {
		character = root
		animation = rage
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		any_vassal = {
			culture = culture:anglo_saxon
			highest_held_title_tier > tier_county	
			any_county = {
				any_province = {
					has_holding = yes
					num_buildings > 0
				}
			}		
		}
	}

	immediate = {
		random_vassal = {
			limit = { culture = culture:anglo_saxon }
			save_scope_as = vassal
			random_realm_province = {
				limit = {
					has_holding = yes
					num_buildings >= 1
				}
				save_scope_as = offending_village	
				every_neighboring_province = { add_to_list = resettlement_villages }
				hidden_effect = { destroy_random_building_variable_effect = yes }
			}
		}
		save_scope_as = root_scope #for tooltip
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Burn it to cinders
		name = ep3_story_cycle_harrying.1015.a

		ep3_increase_pacification_effect = { AMOUNT = harrying_medium_increase_value }

		scope:offending_village = {
			destroy_random_building_effect = yes
			add_province_modifier = {
				modifier = ep3_smouldering_village
				years = 15
			}
		}

		stress_impact = {
			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			compassionate = major_stress_impact_gain
			just = major_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_honor = -1
			}
		}
	}

	option = { #Resettle the residents
		name = ep3_story_cycle_harrying.1015.b

		scope:offending_village = {
			add_province_modifier = {
				modifier = ep3_resettled_village
				years = 15
			}
		}

		every_in_list = {
			list = resettlement_villages
			custom = all_neighbouring_villages
			add_province_modifier = {
				modifier = ep3_population_boost
				years = 15
			}
		}

		stress_impact = {
			sadistic = minor_stress_impact_loss
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_honor = -0.5
			}
		}
	}

	option = { #Leave it be
		name = ep3_story_cycle_harrying.1015.c

		ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }

		add_tyranny = minor_tyranny_loss

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_compassion = 1
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

##################################################
# Aetheling Events
# by Nick Meredith
# 2000-2999
##################################################

#Appeal for Scottish help
#Bleddyn allies with Anglo-Saxons
#Welsh raids into Herefordshire
#Send messages to Europe for knights
#Stoke flames across the country

# Recruit levies from starving men
ep3_story_cycle_harrying.2000 = {
	type = character_event
	title = ep3_story_cycle_harrying.2000.t
	desc = {
		desc = ep3_story_cycle_harrying.2000.desc
		triggered_desc = {
			trigger = {
				NOR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			desc = ep3_story_cycle_harrying.2000.notcallous
		}
	}
	theme = harrying
	override_background = { reference = alley_day }
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:starving_man
		animation = beg
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		location = root.capital_province
		exists = root.cp:councillor_marshal
	}

	immediate = {
		location = {
			save_scope_as = location
		}
		top_liege = {
			save_scope_as = william
		}
		hidden_effect = {
			random_dummy_gender_effect = yes
			create_character = {
				template = new_warrior_character
				location = root.location
				culture = culture:anglo_saxon
				faith = root.location.faith
				gender_female_chance = root_soldier_female_chance
				save_scope_as = starving_man
			}
			scope:starving_man = {
				change_current_weight = -50
			}
		}
		root.cp:councillor_marshal = {
			save_scope_as = marshal
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #All of you; you're all hired.
		name = ep3_story_cycle_harrying.2000.a

		remove_short_term_gold = major_gold_value

		ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }

		add_prestige = medium_prestige_gain

		scope:location.county = {
			add_county_modifier = {
				modifier = ep3_paid_grains
				years = 10
			}
		}

		trigger_event = {
			id = ep3_story_cycle_harrying.2001
			days = { 3 6 }
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			generous = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_compassion = 1
			}
		}
	}

	option = { #I'll hire you, fine gentleman
		name = ep3_story_cycle_harrying.2000.b

		remove_short_term_gold = minor_gold_value

		add_courtier = scope:starving_man

		stress_impact = {
			greedy = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			generous = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.5
				ai_compassion = 1
			}
		}
	}

	option = { #Maybe I can try intervening myself?
		name = ep3_story_cycle_harrying.2000.c

		duel = {
			skill = stewardship
			value = decent_skill_rating
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2000.c.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.2000.c.success
	
					ep3_decrease_pacification_effect = yes

					scope:location.county = {
						add_county_modifier = {
							modifier = ep3_innovative_farming_techniques
							years = 10
						}
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2000.c.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.2000.c.failure
	
					add_prestige = minor_prestige_loss
					ep3_decrease_resistance_effect = yes
				}
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_loss
			generous = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			diligent = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_compassion = -0.5
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

#You gain event troops!
ep3_story_cycle_harrying.2001 = {
	type = letter_event
	opening = ep3_story_cycle_harrying.2001.opening
	desc = ep3_story_cycle_harrying.2001.desc
	sender = scope:marshal

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		add_stress = minor_stress_loss
	}

	option = { # Wooo!
		name = ep3_story_cycle_harrying.2001.a

		spawn_army = {
			name = event_troop_default_name
			levies = 1000
			location = scope:location
			origin = scope:location
		}

		ai_chance = {
			base = 100
		}		
	}

	option = { # Reject them for now
		name = ep3_story_cycle_harrying.2001.b

		flavor = ep3_story_cycle_harrying.2001.b.tt

		scope:location.county = {
			add_county_modifier = {
				modifier = ep3_surplus_manpower
				years = 10
			}
		}

		ai_chance = {
			base = 100
		}		
	}
}

# Recruit murderers to kill Normans
ep3_story_cycle_harrying.2005 = {
	type = character_event
	title = ep3_story_cycle_harrying.2005.t
	desc = ep3_story_cycle_harrying.2005.desc
	theme = harrying
	override_background = { reference = armory }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:murderer
		animation = spymaster
	}
	lower_center_portrait = {
		character = scope:spymaster
	}
	cooldown = { years = 20 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		exists = root.cp:councillor_spymaster
		title:k_england.holder = {
			culture = culture:norman
			any_vassal = {
				culture = culture:norman
				capital_province = {
					geographical_region = world_europe_west_britannia
				}
			}
		}
	}

	immediate = {
		location = {
			save_scope_as = location
		}
		top_liege = {
			save_scope_as = william
		}
		scope:william = {
			random_vassal = {
				limit = {
					culture = culture:norman
					capital_province = {
						geographical_region = world_europe_west_britannia
					}
				}
				capital_province.county = {
					save_scope_as = willy_vassal
				}
			}
		}
		hidden_effect = {
			create_character = {
				template = ep3_murderer_template
				location = root.location
				culture = culture:anglo_saxon
				faith = root.location.faith
				gender_female_chance = root_soldier_female_chance
				save_scope_as = murderer
			}
		}
		root.cp:councillor_spymaster = {
			save_scope_as = spymaster
		}
		scope:william = {
			random_close_family_member = {
				limit = {
					location = { geographical_region = world_europe_west_britannia } 
				}
				save_scope_as = willy_family
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Perhaps we need to aim higher...
		name = ep3_story_cycle_harrying.2005.a

		trigger = {
			scope:william = {
				any_close_family_member = {
					location = { geographical_region = world_europe_west_britannia } 
				}
			}
		}

		add_internal_flag = special

		pay_short_term_gold = {
			target = scope:murderer
			gold = medium_gold_value
		}

		start_scheme = { type = murder target_character = scope:willy_family }

		custom_tooltip = diplomacy_family.2250.b.tt
		hidden_effect = {
			random_scheme = {
				type = murder
				limit = {
					scheme_target_character = scope:willy_family
				}
				add_scheme_modifier = {
					type = extra_success_chance_modifier
				}
			}
		}

		hidden_effect = {
			scope:murderer = {
				silent_disappearance_effect = yes
			}
		}

		stress_impact = {
			vengeful = medium_stress_impact_loss
			sadistic = minor_stress_impact_loss
			forgiving = medium_stress_impact_gain
			greedy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -1
			}
		}
	}

	option = { #Go off and murder some Normans, wouldja?
		name = ep3_story_cycle_harrying.2005.b

		flavor = ep3_story_cycle_harrying.2005.b.tt

		pay_short_term_gold = {
			target = scope:murderer
			gold = medium_gold_value
		}

		ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }

		scope:willy_vassal = {
			add_county_modifier = {
				modifier = ep3_murderers_loose
				years = 20
			}
		}

		hidden_effect = {
			scope:murderer = {
				silent_disappearance_effect = yes
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			callous = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			generous = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -0.5
			}
		}
	}

	option = { #Well, you might be handy to have around...
		name = ep3_story_cycle_harrying.2005.c

		add_courtier = scope:murderer

		stress_impact = {
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

# Gather support amongst the minor nobles
ep3_story_cycle_harrying.2010 = {
	type = character_event
	title = ep3_story_cycle_harrying.2010.t
	desc = ep3_story_cycle_harrying.2010.desc
	theme = harrying
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = chancellor
	}
	cooldown = { years = 15 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		title:k_england.holder = {
			culture = culture:norman
			any_duchy = {
				count > 1
			}
		}		
	}

	immediate = {
		top_liege = {
			save_scope_as = william
		}
		scope:william = {
			every_sub_realm_county = { #Choose first one of two random counties
				limit = {
					holder = {
						culture = culture:norman
					}
				}
				add_to_list = county_list
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Rally general support
		name = ep3_story_cycle_harrying.2010.a

		duel = {
			skill = diplomacy
			value = decent_skill_rating

			10 = { #It really works
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2010.a.critsuccess
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_story_cycle_harrying.2010.a.critsuccess
					left_icon = root

					ep3_increase_resistance_large_effect = yes
				}
			}

			50 = { #It works
				compare_modifier = {
					 value = scope:duel_value
					 multiplier = 3.5
					 min = -49
				}

				desc = ep3_story_cycle_harrying.2010.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_story_cycle_harrying.2010.a.success
					left_icon = root  
				
					ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }
				}
			}

			50 = { #It doesn't work
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}

				desc = ep3_story_cycle_harrying.2010.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ep3_story_cycle_harrying.2010.a.failure
					left_icon = root  
				
					add_prestige = medium_prestige_loss
				}
			}

			10 = { #Message is intercepted and more troops sent
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2010.a.critfailure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ep3_story_cycle_harrying.2010.a.critfailure
					left_icon = root  
				
					ep3_increase_pacification_effect = { AMOUNT = harrying_medium_increase_value }
					add_prestige = medium_prestige_loss
				}
			}
		}

		stress_impact = {
			ambitious = minor_stress_impact_loss
			content = medium_stress_impact_gain
			greedy = miniscule_stress_impact_gain
			brave = miniscule_stress_impact_loss
			craven = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}

	option = { #Appeal for extra tax revenue
		name = ep3_story_cycle_harrying.2010.b

		duel = {
			skills = { stewardship diplomacy }
			value = decent_skill_rating
			
			50 = { #Yes!
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2010.b.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.2010.b.success
					left_icon = root
	
					add_gold = medium_gold_value
				}
			}
			50 = { #...no
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2010.b.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.2010.b.failure
					left_icon = root
	
					add_prestige = minor_prestige_loss
					ep3_decrease_resistance_effect = yes
				}
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_loss
			generous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}

	option = { #Tell them to save their strength
		name = ep3_story_cycle_harrying.2010.c


		scope:william = {
			every_sub_realm_county = {
				limit = {
					is_in_list = county_list
				}
				custom = county_list_tt
				random = {
					chance = 5
					add_county_modifier = {
						modifier = ep3_counties_restless_modifier
						years = 15
					}
				}
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

#Forge documents strengthening Aetheling positions
ep3_story_cycle_harrying.2015 = {
	type = character_event
	title = ep3_story_cycle_harrying.2015.t
	desc = ep3_story_cycle_harrying.2015.desc
	theme = harrying
	override_background = { reference = study }
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:chancellor
		animation = chancellor
	}
	lower_center_portrait = {
		trigger = {
			scope:other_vassal = {
				is_alive = yes
			}
		}
		character = scope:other_vassal
	}
	cooldown = { years = 15 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		primary_title.tier >= tier_duchy
	}

	immediate = {
		top_liege = {
			save_scope_as = william
		}
		primary_title = {
			save_scope_as = primary_title
		}
		if = {
			limit = {
				scope:william = {
					any_vassal = {
						this != root
						culture = culture:anglo_saxon
					}
				}
			}
			scope:william = {
				random_vassal = {
					limit = {
						this != root
						culture = culture:anglo_saxon
					}
					save_scope_as = other_vassal
					primary_title = {
						save_scope_as = other_vassal_primary_title
					}
				}
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Ensure your titles cannot be revoked
		name = ep3_story_cycle_harrying.2015.a

		duel = {
			skills = { diplomacy intrigue }
			target = scope:william
			
			60 = { #Yes!
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2015.a.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.2015.a.success
					left_icon = root
					right_icon = scope:william
	
					if = {
						limit = {
							vassal_contract_obligation_level_can_be_decreased = title_revocation_rights
						}
						vassal_contract_set_obligation_level = {
							type = title_revocation_rights
							level = 1
						}
					}
					else = {
						if = {
							limit = {
								can_add_hook = {
									target = scope:william
									type = fabrication_hook
								}
							}
							add_hook = {
								target = scope:william
								type = fabrication_hook
							}
						}						
					}

					if = {
						limit = {
							scope:other_vassal = {
								is_alive = yes
								vassal_contract_obligation_level_can_be_decreased = title_revocation_rights
							}
						}
						scope:other_vassal = {
							vassal_contract_set_obligation_level = {
								type = title_revocation_rights
								level = 1
							}
						}
					}
				}
			}
			40 = { #...no
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.2015.a.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.2015.a.failure
					left_icon = root
					right_icon = scope:william
	
					if = {
						limit = {
							can_add_hook = {
								target = scope:william
								type = favor_hook
							}
						}
						add_hook = {
							target = scope:william
							type = favor_hook
						}
					}
					if = {
						limit = {
							scope:other_vassal = {
								is_alive = yes
							}
						}
						scope:other_vassal = {
							add_hook = {
								target = scope:william
								type = favor_hook
							}
						}
					}
				}
			}
		}

		stress_impact = {
			ambitious = minor_stress_impact_loss
			content = medium_stress_impact_gain
			deceitful = miniscule_stress_impact_loss
			brave = miniscule_stress_impact_loss
			craven = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}

	option = { #Reduce Feudal Levies/Taxes
		name = ep3_story_cycle_harrying.2015.b

		if = {
			limit = {
				vassal_contract_obligation_level_can_be_decreased = feudal_government_taxes
			}
			vassal_contract_decrease_obligation_level = feudal_government_taxes
		}
		if = {
			limit = {
				vassal_contract_obligation_level_can_be_decreased = feudal_government_levies
			}
			vassal_contract_decrease_obligation_level = feudal_government_levies
		}
		if = {
			limit = {
				scope:other_vassal = {
					is_alive = yes
				}
			}
			scope:other_vassal = {
				if = {
					limit = {
						vassal_contract_obligation_level_can_be_decreased = feudal_government_taxes
					}
					vassal_contract_decrease_obligation_level = feudal_government_taxes
				}
				if = {
					limit = {
						vassal_contract_obligation_level_can_be_decreased = feudal_government_levies
					}
					vassal_contract_decrease_obligation_level = feudal_government_levies
				}
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_loss
			generous = medium_stress_impact_gain
			just = miniscule_stress_impact_gain
			arbitrary = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
			}
		}
	}

	option = { #Gain Marcher Lord status
		name = ep3_story_cycle_harrying.2015.c

		vassal_contract_set_obligation_level = {
			type = special_contract
			level = 2
		}

		scope:other_vassal = {
			vassal_contract_set_obligation_level = {
				type = special_contract
				level = 2
			}
		}

		stress_impact = {
			lazy = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

##################################################
# Hereward Events
# by Nick Meredith
# 3000-3999
##################################################

#Rob local church
#William offers to parcel out Cambridgeshire to you
#Call in Danish help
#Heist an artifact from a local noble
#Downgrade local building
#Travel to other areas of the country to gather support

# Rob local church
ep3_story_cycle_harrying.3000 = {
	type = character_event
	title = ep3_story_cycle_harrying.3000.t
	desc = ep3_story_cycle_harrying.3000.desc
	theme = harrying
	override_background = { reference = temple }
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:bishop
		animation = beg
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_center_portrait		
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		location = { save_temporary_scope_as = current_temp }
		scope:current_temp = {
			any_neighboring_province = {
				has_holding_type = church_holding
			}
		}
	}

	immediate = {
		location = {
			random_neighboring_province = {
				limit = {
					has_holding_type = church_holding
				}
				save_scope_as = neighboring_church
			}
		}
		hidden_effect = {
			create_character = {
				template = priest_character_template
				location = scope:neighboring_church
				save_scope_as = bishop
			}
			random_dummy_gender_effect = yes
			scope:bishop = {
				create_artifact_brooch_effect = { 
					OWNER = scope:bishop 
					SMITH = scope:dummy_gender
				}
			}
			scope:newly_created_artifact = {
				set_artifact_name = artifact_church_saint_brooch_name
				set_artifact_description = artifact_church_saint_brooch_description
				add_artifact_modifier = artifact_monthly_piety_4_modifier
				add_artifact_modifier = artifact_same_faith_opinion_4_modifier
				add_artifact_modifier = artifact_clergy_opinion_penalty_5_modifier
				set_artifact_rarity = famed
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Relics, you say?
		name = ep3_story_cycle_harrying.3000.a

		add_piety = medium_piety_loss

		add_prestige = minor_prestige_loss

		scope:newly_created_artifact = {
			set_owner = root
		}

		scope:neighboring_church = {
			add_province_modifier = {
				modifier = ep3_church_bereft
				years = 15
			}			
		}

		stress_impact = {
			greedy = medium_stress_impact_loss
			callous = miniscule_stress_impact_loss
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_compassion = -1
			}
		}
	}

	option = { #This gold is needed for the war effort, but we'll leave any relics
		name = ep3_story_cycle_harrying.3000.b

		flavor = ep3_story_cycle_harrying.3000.b.tt

		ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }

		add_gold = medium_gold_value

		stress_impact = {
			calm = miniscule_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			generous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 0.5
				ai_compassion = -0.5
			}
		}
	}

	option = { #I am a man of god, I would never.
		name = ep3_story_cycle_harrying.3000.c

		add_piety = medium_piety_gain

		add_character_modifier = {
			modifier = ep3_man_of_god
			years = 10
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			generous = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_compassion = 1
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

# Interdict supply lines
ep3_story_cycle_harrying.3005 = {
	type = character_event
	title = ep3_story_cycle_harrying.3005.t
	desc = ep3_story_cycle_harrying.3005.desc
	theme = harrying
	override_background = { reference = ep2_hunt_foggy_forest }
	override_effect_2d = fog
	left_portrait = {
		character = root
		animation = inspect_weapon
	}
	right_portrait = {
		character = scope:norman_soldier
		animation = survey
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}

	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
	}

	immediate = {
		location = {
			save_scope_as = location
		}
		random_dummy_gender_effect = yes
		create_character = {
			template = new_warrior_character
			location = root.location
			culture = culture:norman
			faith = root.location.faith
			gender_female_chance = root_soldier_female_chance
			save_scope_as = norman_soldier
		}
		hidden_effect = {
			scope:norman_soldier = {
				create_artifact = { #Scripted effect didn't like this, so custom weapon it is
					name = norman_sword_name
					description = stolen_norman_sword_description
					type = sword
					visuals = sword
					modifier = artifact_prowess_4_modifier
					modifier = artifact_knight_effectiveness_3_modifier
					modifier = artifact_hard_casualty_modifier_4_modifier
					rarity = masterwork
					save_scope_as = newly_created_artifact
				}
			}
		}
		global_var:harrying_of_the_north.story_owner = {
			save_scope_as = william
			random_vassal = {
				limit = {
					location = { geographical_region = world_europe_west_britannia } #To ensure they're not getting sent to Normandy
				}
				primary_title = {
					save_scope_as = vassal_county
				}
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Grab the equipment for yourself
		name = ep3_story_cycle_harrying.3005.a

		duel = {
			skills = { martial prowess }
			target = scope:norman_soldier
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3005.a.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3005.a.success
	
					ep3_decrease_pacification_effect = yes

					add_character_modifier = {
						modifier = ep3_stolen_equipment
						years = 5
					}
					
					scope:newly_created_artifact = {
						set_owner = root
						set_artifact_name = stolen_norman_sword_name
					}
					
					scope:vassal_county = {
						add_county_modifier = {
							modifier = ep3_missing_supplies
							years = 15
						}
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3005.a.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3005.a.failure
	
					add_prestige = medium_prestige_loss
					increase_wounds_no_death_effect = { REASON = battle }
					every_knight = { 
						custom = every_knight
						add_opinion = {
							modifier = botched_ambush_opinion
							target = root
							opinion = -15
						}
					}
				}
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_loss
			callous = miniscule_stress_impact_loss
			compassionate = miniscule_stress_impact_gain
			generous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_energy = 0.5
			}
		}
	}

	option = { #Take the equipment for allies
		name = ep3_story_cycle_harrying.3005.b

		flavor = ep3_story_cycle_harrying.3005.b.tt

		duel = {
			skills = { martial prowess }
			target = scope:norman_soldier
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3005.a.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3005.a.success
	
					ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }
					ep3_decrease_pacification_effect = yes

					scope:vassal_county = {
						add_county_modifier = {
							modifier = ep3_missing_supplies
							years = 15
						}
					}
					global_var:harrying_of_the_north.story_owner = {
						every_vassal = {
							limit = {
								culture = culture:anglo_saxon
							}
							custom = every_anglo_vassal
							add_character_modifier = {
								modifier = ep3_redistributed_equipment
								years = 5
							}
						}
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3005.a.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3005.a.failure
	
					add_prestige = medium_prestige_loss
					increase_wounds_no_death_effect = { REASON = battle }
					every_knight = { 
						custom = every_knight
						add_opinion = {
							modifier = botched_ambush_opinion
							target = root
							opinion = -15
						}
					}
				}
			}
		}

		stress_impact = {
			arrogant = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			generous = medium_stress_impact_loss
			humble = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_energy = 0.5
			}
		}
	}

	option = { #Sabotage the road ahead
		name = ep3_story_cycle_harrying.3005.c

		flavor = ep3_story_cycle_harrying.3005.c.tt

		scope:location = {
			add_province_modifier = {
				modifier = ep3_sabotaged_roads
				years = 10
			}		
		}

		scope:vassal_county = {
			add_county_modifier = {
				modifier = ep3_delayed_supplies
				years = 10
			}
		}

		stress_impact = {
			craven = medium_stress_impact_loss
			brave = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -0.5
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
		scope:norman_soldier = {
			silent_disappearance_effect = yes
		}
	}
}

scripted_trigger ep3_story_cycle_harrying_3010_ambushable_noble_trigger = {
	location = {
		geographical_region = world_europe_west_britannia
		duchy = root.location.duchy #Same duchy as Hereward
	}
	culture = culture:norman
	is_theocratic_lessee = no #No dueling priests!
	is_adult = yes
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = $WILLIAM$ }
	NOT = { has_character_flag = hereward_ambushed }
}

#Ambush Norman noble
ep3_story_cycle_harrying.3010 = {
	type = character_event
	title = ep3_story_cycle_harrying.3010.t
	desc = ep3_story_cycle_harrying.3010.desc
	theme = harrying
	override_background = { reference = ep2_travel_bridge }
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:norman_noble
		animation = aggressive_sword
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}

	cooldown = { years = 5 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		is_healthy = yes
		global_var:harrying_of_the_north.story_owner = {
			save_temporary_scope_as = william_temp
			any_vassal_or_below = {
				ep3_story_cycle_harrying_3010_ambushable_noble_trigger = { WILLIAM = scope:william_temp }
			}
		}
	}

	immediate = {
		location = { save_scope_as = location }
		global_var:harrying_of_the_north.story_owner = {
			save_scope_as = william
			random_vassal_or_below = {
				limit = {
					ep3_story_cycle_harrying_3010_ambushable_noble_trigger = { WILLIAM = scope:william }
				}
				primary_title = { save_scope_as = noble_county }
				save_scope_as = norman_noble
				add_character_flag = hereward_ambushed
			}
		}
		hidden_effect = { 
			random_dummy_gender_effect = yes
			scope:norman_noble = {
				create_artifact_ring_effect = {
					OWNER = scope:norman_noble
					SMITH = scope:dummy_gender
				}
			}
		}
		root = { save_scope_as = root_for_loc }
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Fight them
		name = ep3_story_cycle_harrying.3010.a

		custom_tooltip = ep3_story_cycle_harrying.3010.a.tt

		configure_start_single_combat_effect = {
			SC_INITIATOR = root
			SC_ATTACKER = root
			SC_DEFENDER = scope:norman_noble
			FIXED = no
			FATALITY = always
			LOCALE = ep2_travel_bridge
			OUTPUT_EVENT = ep3_story_cycle_harrying.3011
			INVALIDATION_EVENT = fp1_yearly.2002 #Re-use this
		}

		stress_impact = {
			brave = medium_stress_impact_loss
			wrathful = miniscule_stress_impact_loss
			calm = miniscule_stress_impact_gain
			craven = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
			}
		}
	}

	option = { #Simply rob them
		name = ep3_story_cycle_harrying.3010.b

		add_short_term_gold = medium_gold_value

		scope:newly_created_artifact = {
			set_owner = root
		}

		ep3_decrease_pacification_effect = yes

		stress_impact = {
			brave = medium_stress_impact_gain
			wrathful = miniscule_stress_impact_gain
			calm = miniscule_stress_impact_loss
			craven = medium_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_energy = -0.5
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

#Followup, post-duel
ep3_story_cycle_harrying.3011 = {
	type = character_event
	title = ep3_story_cycle_harrying.3011.t
	desc = ep3_story_cycle_harrying.3011.desc
	theme = harrying
	override_background = { reference = ep2_travel_bridge }
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:saxon_soldier_1
		animation = thinking
	}
	lower_center_portrait = {
		character = scope:saxon_soldier_2
	}

	cooldown = { years = 5 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		is_healthy = yes
	}

	immediate = {
		ep3_harrying_widget_setup_effect = yes
		ep3_decrease_pacification_effect = yes
		ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }
		scope:newly_created_artifact = {
			set_owner = root
		}
		hidden_effect = {
			random_dummy_gender_effect = yes
			create_character = {
				template = new_warrior_character
				location = root.location
				culture = culture:anglo_saxon
				faith = root.faith
				gender_female_chance = root_soldier_female_chance
				save_scope_as = saxon_soldier_1
			}
			create_character = {
				template = new_warrior_character
				location = root.location
				culture = culture:anglo_saxon
				faith = root.faith
				gender_female_chance = root_soldier_female_chance
				save_scope_as = saxon_soldier_2
			}
		}
	}

	option = { #Would you boys like a job?
		name = ep3_story_cycle_harrying.3011.a

		add_courtier = scope:saxon_soldier_1
		add_courtier = scope:saxon_soldier_2

		stress_impact = {
			forgiving = medium_stress_impact_loss
			vengeful = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
				ai_vengefulness = -1
			}
		}
	}

	option = { #Let them return to their families
		name = ep3_story_cycle_harrying.3011.b

		hidden_effect = {
			scope:saxon_soldier_1 = {
				silent_disappearance_effect = yes
			}
			scope:saxon_soldier_2 = {
				silent_disappearance_effect = yes
			}
		}

		add_character_modifier = {
			modifier = ep3_defender_of_families
			years = 10
		}

		stress_impact = {
			generous = miniscule_stress_impact_loss
			greedy = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

#Call in Danish help
ep3_story_cycle_harrying.3015 = {
	type = character_event
	title = ep3_story_cycle_harrying.3015.t
	desc = ep3_story_cycle_harrying.3015.desc
	theme = harrying
	left_portrait = {
		character = root
		animation = writing
	}
	right_portrait = {
		character = scope:danish_king
		animation = thinking
	}
	cooldown = { years = 50 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		is_healthy = yes
		title:k_denmark.holder = {
			is_at_war = no
			is_available_healthy_ai_adult = yes
		}
		title:k_england.holder = {
			is_ai = yes #Just to ensure we don't screw players over
		}
	}

	immediate = {
		location = {
			save_scope_as = location
		}
		title:k_denmark.holder = {
			save_scope_as = danish_king
		}
		hidden_effect = {
			create_character = {
				location = scope:danish_king.location
				template = new_warrior_character
				faith = scope:danish_king.faith
				culture = scope:danish_king.culture
				gender_female_chance = root_soldier_female_chance
				save_scope_as = knight_1
			}
			create_character = {
				location = scope:danish_king.location
				template = new_berserker_character
				faith = scope:danish_king.faith
				culture = scope:danish_king.culture
				gender_female_chance = root_soldier_female_chance
				save_scope_as = knight_2
			}
			create_character = {
				location = scope:danish_king.location
				template = new_commander_character
				faith = scope:danish_king.faith
				culture = scope:danish_king.culture
				gender_female_chance = root_soldier_female_chance
				save_scope_as = knight_3
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Send them a letter begging for them to be your new liege
		name = ep3_story_cycle_harrying.3015.a

		duel = {
			skill = diplomacy
			value = decent_skill_rating
			
			50 = { #He agrees
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3015.a.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3015.a.success
					left_icon = root
					right_icon = scope:danish_king

					scope:danish_king = {
						add_unpressed_claim = title:k_england
					}
					create_alliance = {
						target = scope:danish_king
						allied_through_owner = root
						allied_through_target = scope:danish_king
					}
					ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }
					ep3_decrease_pacification_effect = yes
					add_stress = medium_stress_loss
				}
			}

			50 = { #He disagrees
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3015.a.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3015.a.failure
	
					add_prestige = miniscule_prestige_loss
					ep3_increase_pacification_effect = { AMOUNT = harrying_medium_increase_value }
				}
			}
		}

		stress_impact = {
			ambitious = minor_stress_impact_loss
			brave = miniscule_stress_impact_loss
			content = medium_stress_impact_gain
			craven = minor_stress_impact_gain
		}

		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_energy = 1
			}
		}
	}

	option = { #Send them a letter begging for soldiers
		name = ep3_story_cycle_harrying.3015.b

		duel = {
			skills = { diplomacy martial }
			value = decent_skill_rating
			
			75 = { #He agrees
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3015.b.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3015.b.success
					left_icon = root
					right_icon = scope:danish_king

					add_character_flag = soldiers_accepted_flag

					add_courtier = scope:knight_1
					add_courtier = scope:knight_2
					add_courtier = scope:knight_3

					ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }
				}
			}

			25 = { #He disagrees
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3015.b.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3015.b.failure
	
					add_prestige = miniscule_prestige_loss
					add_stress = minor_stress_gain
				}
			}
		}

		stress_impact = {
			patient = miniscule_stress_impact_loss
			impatient = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
			}
		}
	}

	option = { #We fight this battle alone
		name = ep3_story_cycle_harrying.3015.c

		add_character_modifier = {
			modifier = ep3_standing_alone_modifier
			years = 10
		}

		every_courtier_or_guest = {
			custom = every_follower_custom
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 25
			}
		}

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			humble = medium_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -1
				ai_energy = -0.5
			}
		}
	}

	after = {
		if = {
			limit = {
				NOT = {
					has_character_flag = soldiers_accepted_flag
				}
			}
			scope:knight_1 = { silent_disappearance_effect = yes }
			scope:knight_2 = { silent_disappearance_effect = yes }
			scope:knight_3 = { silent_disappearance_effect = yes }
		}
		ep3_harrying_widget_clear_effect = yes
	}
}

#Travel to another area of the country to intimidate a Norman sympathiser
ep3_story_cycle_harrying.3020 = {
	type = character_event
	title = ep3_story_cycle_harrying.3020.t
	desc = ep3_story_cycle_harrying.3020.desc
	theme = harrying
	left_portrait = {
		character = root
		animation = inspect_weapon
	}
	right_portrait = {
		character = scope:willy_vassal
		animation = dismissal
	}
	cooldown = { years = 10 }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		is_healthy = yes
		title:k_england.holder = {
			save_temporary_scope_as = willy_temp
			any_vassal = {
				culture = culture:anglo_saxon
				capital_province = { geographical_region = world_europe_west_britannia }
				highest_held_title_tier > tier_barony
				opinion = {
					target = scope:willy_temp
					value >= neutral_opinion
				}
				any_courtier = {
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					culture = culture:anglo_saxon
				}
			}
		}
	}

	immediate = {
		location = {
			save_scope_as = location
		}
		title:k_england.holder = {
			save_scope_as = willy
			random_vassal = {
				limit = {
					culture = culture:anglo_saxon
					capital_province = { geographical_region = world_europe_west_britannia }
					highest_held_title_tier > tier_barony
					opinion = {
						target = scope:willy
						value >= neutral_opinion
					}
					any_courtier = {
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
						culture = culture:anglo_saxon
					}
				}
				save_scope_as = willy_vassal
				location = {
					save_scope_as = willy_vassal_capital
				}
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Travel there, raise hell
		name = ep3_story_cycle_harrying.3020.a

		custom_tooltip = ep3_story_cycle_harrying.3020.a.tt

		start_travel_plan = {
			destination = scope:willy_vassal_capital
			players_use_planner = no
			on_arrival_destinations = last
			on_arrival_event = ep3_story_cycle_harrying.3021
			return_trip = no
		}

		stress_impact = {
			ambitious = minor_stress_impact_loss
			brave = miniscule_stress_impact_loss
			content = medium_stress_impact_gain
			craven = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
			}
		}
	}

	option = { #Leave it
		name = ep3_story_cycle_harrying.3020.b

		ep3_decrease_resistance_effect = yes

		stress_impact = {
			patient = miniscule_stress_impact_loss
			impatient = minor_stress_impact_gain
		}

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

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

#You arrive and ambush him
ep3_story_cycle_harrying.3021 = {
	type = character_event
	title = ep3_story_cycle_harrying.3021.t
	desc = ep3_story_cycle_harrying.3021.desc
	theme = harrying
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:willy_vassal
		animation = beg
	}
	cooldown = { years = 5 }
	override_background = { reference = alley_night }
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_available = yes
		is_healthy = yes
		title:k_england.holder = {
			save_temporary_scope_as = willy_temp
			any_vassal = {
				culture = culture:anglo_saxon
				capital_province = { geographical_region = world_europe_west_britannia }
				highest_held_title_tier > tier_barony
				opinion = {
					target = scope:willy_temp
					value >= neutral_opinion
				}
				location = root.location
				any_courtier = {
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					culture = culture:anglo_saxon
				}
			}
		}
	}

	immediate = {
		save_scope_as = root_for_loc
		title:k_england.holder = {
			save_scope_as = willy
			random_vassal = {
				limit = {
					culture = culture:anglo_saxon
					capital_province = { geographical_region = world_europe_west_britannia }
					highest_held_title_tier > tier_barony
					opinion = {
						target = scope:willy
						value >= neutral_opinion
					}
					location = root.location
					any_courtier = {
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
						culture = culture:anglo_saxon
					}
				}
				save_scope_as = willy_vassal
			}
		}
		scope:willy_vassal = {
			random_courtier = {
				limit = {
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					culture = culture:anglo_saxon
				}
				save_scope_as = knight_1
			}
		}
		hidden_effect = {
			create_character = {
				template = new_warrior_character
				location = scope:willy_vassal.location
				culture = scope:willy_vassal.culture
				faith = scope:willy_vassal.faith
				gender_female_chance = root_soldier_female_chance
				save_scope_as = knight_2
			}
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Kill him and steal his stuff
		name = ep3_story_cycle_harrying.3021.a

		custom_tooltip = ep3_story_cycle_harrying.3021.a.tt

		configure_start_single_combat_effect = {
			SC_INITIATOR = root
			SC_ATTACKER = root
			SC_DEFENDER = scope:willy_vassal
			FIXED = no
			FATALITY = always
			LOCALE = ep2_travel_bridge
			OUTPUT_EVENT = ep3_story_cycle_harrying.3022
			INVALIDATION_EVENT = fp1_yearly.2002 #Re-use this
		}

		stress_impact = {
			calm = medium_stress_impact_gain
			just = minor_stress_impact_gain
			wrathful = minor_stress_impact_loss
			arbitrary = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_compassion = -1
			}
		}
	}

	option = { #Reason with him
		name = ep3_story_cycle_harrying.3021.b

		duel = {
			skill = diplomacy
			target = scope:willy_vassal
			
			50 = { #You reason successfully
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3021.b.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3021.b.success
					left_icon = root
					right_icon = scope:willy_vassal

					scope:willy_vassal = {
						add_opinion = {
							target = scope:willy
							modifier = revanchist_opinion
							opinion = -120
						}
					}
					scope:willy = {
						add_character_modifier = {
							modifier = ep3_disgruntled_vassals_modifier
							years = 10
						}
					}
					ep3_decrease_pacification_effect = yes
				}
			}

			50 = { #You are unable to reason with him
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3021.b.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3021.b.failure
	
					add_stress = miniscule_stress_gain
					ep3_decrease_resistance_effect = yes
				}
			}
		}

		stress_impact = {
			calm = minor_stress_impact_loss
			just = miniscule_stress_impact_loss
			wrathful = medium_stress_impact_gain
			arbitrary = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
			}
		}
	}

	option = { #Threaten him
		name = ep3_story_cycle_harrying.3021.c

		duel = {
			skill = prowess
			target = scope:willy_vassal

			60 = { #Your threats work
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3021.c.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3021.c.success
					left_icon = root
					right_icon = scope:willy_vassal

					scope:willy_vassal = {
						add_opinion = {
							target = scope:willy
							modifier = revanchist_opinion
							opinion = -120
						}
					}
					scope:willy = {
						add_dread = major_dread_loss
						add_character_modifier = {
							modifier = ep3_disgruntled_vassals_modifier
							years = 10
						}
					}
					ep3_decrease_pacification_effect = yes
				}
			}

			40 = { #Your threats don't work
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3021.c.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3021.c.failure
	
					add_dread = minor_dread_loss
					add_prestige = minor_prestige_loss
					ep3_decrease_resistance_effect = yes
				}
			}
		}

		stress_impact = {
			ambitious = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			content = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -0.5
			}
		}
	}

	option = { #Take some loyalists and leave him to it
		name = ep3_story_cycle_harrying.3021.d

		flavor = ep3_story_cycle_harrying.3021.d.flavour

		add_courtier = scope:knight_1
		add_courtier = scope:knight_2

		ep3_decrease_resistance_effect = yes

		stress_impact = {
			patient = miniscule_stress_impact_loss
			impatient = minor_stress_impact_gain
			just = miniscule_stress_impact_loss
			arbitrary = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -0.5
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

#Duel resolution
ep3_story_cycle_harrying.3022 = {
	type = character_event
	title = ep3_story_cycle_harrying.3022.t
	desc = ep3_story_cycle_harrying.3022.desc
	theme = harrying
	left_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:willy_vassal
		animation = dead
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_left_portrait
	}
	artifact = {
		target = scope:traitors_head_artifact
		position = lower_right_portrait
	}
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		ep3_harrying_widget_setup_effect = yes
		capital_province = { save_scope_as = domicile }

		random_dummy_gender_effect = yes

		add_gold = { 50 100 }

		hidden_effect = {
			scope:willy_vassal = {
				create_artifact_brooch_effect = { 
					OWNER = scope:willy_vassal 
					SMITH = scope:dummy_gender
				}
			}
			create_artifact = {
				name = traitors_head
				description = traitors_head_description
				type = miscellaneous
				visuals = small_box
				durability = 10
				max_durability = 10
				decaying = yes
				modifier = artifact_health_penalty_1_modifier
				modifier = artifact_stress_gain_1_penalty_modifier
				modifier = artifact_attraction_opinion_negative_2_modifier
				creator = root
				rarity = famed
				save_scope_as = traitors_head_artifact
			}
		}

		scope:newly_created_artifact = {
			set_owner = root
		}
	}

	option = { #Send his head to William
		name = ep3_story_cycle_harrying.3022.a

		scope:traitors_head_artifact = {
			set_owner = scope:willy
		}

		scope:willy = {
			add_character_modifier = {
				modifier = ep3_life_threatened_modifier
				years = 10
			}
		}

		stress_impact = {
			calm = minor_stress_impact_gain
			just = minor_stress_impact_gain
			wrathful = miniscule_stress_impact_loss
			arbitrary = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 1
				ai_compassion = -1
			}
		}
	}

	option = { #Let everyone know what happens to turncoats
		name = ep3_story_cycle_harrying.3022.b

		ep3_increase_resistance_large_effect = yes

		if = {
			limit = {
				scope:willy = {
					any_sub_realm_duchy = {
						count > 1
						holder.culture = culture:norman
					}
				}
			}
			scope:willy = {
				random_sub_realm_duchy = {
					limit = {
						holder.culture = culture:norman
					}
					show_as_tooltip = {
						add_county_modifier = {
							modifier = ep3_impassioned_populace_modifier
							years = 10
						}
					}
					hidden_effect = {
						every_de_jure_county = {
							add_county_modifier = {
								modifier = ep3_impassioned_populace_modifier
								years = 10
							}
						}
					}
					save_scope_as = saved_duchy
				}
				random_sub_realm_duchy = {
					limit = {
						holder.culture = culture:norman
						this != scope:saved_duchy
					}
					show_as_tooltip = {
						add_county_modifier = {
							modifier = ep3_impassioned_populace_modifier
							years = 10
						}
					}
					hidden_effect = {
						every_de_jure_county = {
							add_county_modifier = {
								modifier = ep3_impassioned_populace_modifier
								years = 10
							}
						}
					}
				}
			}
		}

		hidden_effect = {
			destroy_artifact = scope:traitors_head_artifact
		}

		stress_impact = {
			calm = minor_stress_impact_loss
			just = miniscule_stress_impact_loss
			wrathful = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
		start_travel_plan = {
			destination = scope:domicile
			players_use_planner = no
			on_arrival_destinations = last
			return_trip = no
		}
	}
}

### EVENT CHAIN:
## Dealing with the Devil

#William sends you a letter
ep3_story_cycle_harrying.3050 = {
	type = letter_event
	opening = ep3_story_cycle_harrying.3050.opening
	desc = ep3_story_cycle_harrying.3050.desc
	sender = scope:william
	cooldown = { years = 100 }

	trigger = {
		has_ep3_dlc_trigger = yes
		is_ai = no #Don't even trigger this for AI
		is_imprisoned = no
		is_incapable = no
		global_var:harrying_of_the_north.story_owner = { #King of England
			is_ai = yes
			OR = { #But needs to either have Cambridgeshire or be able to take it off a Norman vassal
				has_title = title:c_cambridgeshire
				any_vassal = {
					culture = culture:norman
					has_title = title:c_cambridgeshire
				}
			}
		}
	}

	immediate = {
		global_var:harrying_of_the_north.story_owner = {
			save_scope_as = william
			capital_province.barony = { save_scope_as = london }
		}
	}

	option = { # Grimly accept
		name = ep3_story_cycle_harrying.3050.a

		custom_tooltip = ep3_story_cycle_harrying.3050.a.tt

		every_character_active_contract = { invalidate_contract = yes }

		start_travel_plan = {
			destination = scope:william.capital_province
			players_use_planner = no
			on_arrival_event = ep3_story_cycle_harrying.3051
			on_arrival_destinations = last
			return_trip = no
		}

		ai_chance = { #Just in case
			base = 0
		}		
	}

	option = { # Refuse
		name = ep3_story_cycle_harrying.3050.b

		reverse_add_opinion = {
			target = scope:william
			modifier = disrespect_opinion
			opinion = -40
		}

		ai_chance = {
			base = 100
		}
	}
}

#You meet William
ep3_story_cycle_harrying.3051 = {
	type = character_event
	title = ep3_story_cycle_harrying.3051.t
	desc = ep3_story_cycle_harrying.3051.desc
	theme = harrying
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:william
		animation = thinking
	}

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		location = {
			save_scope_as = location
		}
	}

	option = { #Greet him cheekily
		name = ep3_story_cycle_harrying.3051.a

		duel = {
			skill = diplomacy
			value = decent_skill_rating
			
			70 = { #He's lets it slide
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3051.a.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3051.a.success
					left_icon = root
					right_icon = scope:william

					if = {
						limit = {
							scope:william = {
								this = character:140
							}
						}
						scope:william = {
							add_legitimacy = miniscule_legitimacy_loss
							every_vassal = {
								limit = {
									culture = culture:anglo_saxon
								}
								custom = every_anglo_vassal
								add_opinion = {
									modifier = bantered_with_the_bastard_opinion
									target = root
									opinion = 10
								}
							}
						}
					}
					else = {
						scope:william = {
							add_legitimacy = miniscule_legitimacy_loss
							every_vassal = {
								limit = {
									culture = culture:anglo_saxon
								}
								custom = every_anglo_vassal
								add_opinion = {
									modifier = bantered_with_the_devil_opinion
									target = root
									opinion = 10
								}
							}
						}
					}
				}
			}

			30 = { #He's annoyed by your levity
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3051.a.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3051.a.failure
	
					add_prestige = miniscule_prestige_loss
				}
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_loss
			callous = miniscule_stress_impact_loss
			compassionate = miniscule_stress_impact_gain
			generous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_energy = 0.5
			}
		}
	}

	option = { #Stay silent
		name = ep3_story_cycle_harrying.3051.b

		flavor = ep3_story_cycle_harrying.3051.b.tt

		stress_impact = {
			arrogant = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			generous = medium_stress_impact_loss
			humble = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_energy = 0.5
			}
		}
	}


	after = {
		trigger_event = {
			id = ep3_story_cycle_harrying.3052
			days = 1
		}
	}
}

#William offers to give you Cambridgeshire
ep3_story_cycle_harrying.3052 = {
	type = character_event
	title = ep3_story_cycle_harrying.3052.t
	desc = ep3_story_cycle_harrying.3052.desc
	theme = harrying
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:william
		animation = disapproval
	}
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}
	cooldown = { years = 10 }

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		location = {
			save_scope_as = location
		}
		title:c_cambridgeshire = { save_scope_as = cambridgeshire }
		father = {
			save_scope_as = father
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Take his offer
		name = ep3_story_cycle_harrying.3052.a

		flavor = ep3_story_cycle_harrying.3052.a.flavor
		custom_tooltip = ep3_story_cycle_harrying.3052.a.tt

		add_prestige = medium_prestige_loss

		if = {
			limit = {
				scope:cambridgeshire.holder = {
					this != scope:william
				}
			}
			scope:cambridgeshire.holder = {
				add_opinion = {
					target = scope:william
					modifier = angry_opinion
					opinion = -40
				}
			}
		}

		trigger_event = {
			id = ep3_story_cycle_harrying.3053
			days = 1
		}

		stress_impact = {
			greedy = medium_stress_impact_loss
			callous = miniscule_stress_impact_loss
			compassionate = miniscule_stress_impact_gain
			generous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_energy = 0.5
			}
		}
	}

	option = { #Turn down his offer
		name = ep3_story_cycle_harrying.3052.b

		ep3_increase_resistance_effect = { AMOUNT = harrying_medium_increase_value }

		reverse_add_opinion = {
			target = scope:william 
			modifier = angry_opinion
			opinion = -65
		}

		trigger_event = {
			id = ep3_story_cycle_harrying.3054
			days = 1
		}

		stress_impact = {
			arrogant = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			generous = medium_stress_impact_loss
			humble = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_energy = 0.5
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
	}
}

scripted_effect ep3_story_cycle_harrying_3053_process_vassalisation_effect = {
	create_title_and_vassal_change = {
		type = granted
		save_scope_as = change
	}
	if = {
		limit = {
			scope:duke_norfolk ?= { is_vassal_of = scope:william }
		}
		change_liege = {
			liege = scope:duke_norfolk
			change = scope:change
		}
		add_truce_both_ways = {
			character = scope:william
			years = 100
			name = fp3_landed_zanj_reason #Re-using this
		}
		add_truce_both_ways = {
			character = scope:duke_norfolk
			years = 100
			name = fp3_landed_zanj_reason #Re-using this
		}
	}
	else = {
		change_liege = {
			liege = scope:william
			change = scope:change
		}
		add_truce_both_ways = {
			character = scope:william
			years = 100
			name = fp3_landed_zanj_reason #Re-using this
		}
	}
	resolve_title_and_vassal_change = scope:change
}

#You accept his offer
ep3_story_cycle_harrying.3053 = {
	type = character_event
	title = ep3_story_cycle_harrying.3053.t
	desc = ep3_story_cycle_harrying.3053.desc
	theme = harrying
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:william
		animation = disapproval
	}
	lower_right_portrait = scope:duke_norfolk
	cooldown = { years = 10 }

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		scope:cambridgeshire.duchy.holder ?= { save_scope_as = duke_norfolk }
	}

	option = { #Recant your decision
		name = ep3_story_cycle_harrying.3053.a

		add_prestige = medium_prestige_gain

		trigger_event = {
			id = ep3_story_cycle_harrying.3054
			days = 1
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #Accept
		name = ep3_story_cycle_harrying.3053.b

		custom_tooltip = ep3_story_cycle_harrying.3053.b.tt

		create_title_and_vassal_change = {
			type = granted
			save_scope_as = change
		}
		scope:cambridgeshire = {
			change_title_holder_include_vassals = {
				holder = root
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		# We need to do this here to account for you already being duke tier.
		show_as_tooltip = { ep3_story_cycle_harrying_3053_process_vassalisation_effect = yes }
		save_scope_value_as = {
			name = settled_option
			value = yes
		}
		add_character_flag = hereward_settled_flag

		ep3_decrease_resistance_effect = yes
		ep3_increase_pacification_large_effect = yes

		if = {
			limit = {
				has_nickname = nick_the_wake
			}
			remove_nickname = yes
		}

		give_nickname = nick_iscariot

		remove_trait = the_wake

		start_travel_plan = {
			destination = root.capital_province
			players_use_planner = no
			on_arrival_destinations = last
			return_trip = no
		}

		scope:william = {
			add_stress = major_stress_loss
		}

		ai_chance = {
			base = 0
		}
	}

	after = {
		# We need to do this here to account for you already being duke tier.
		hidden_effect = {
			if = {
				limit = { exists = scope:settled_option }
				ep3_story_cycle_harrying_3053_process_vassalisation_effect = yes
			}
		}
	}
}

#You decline his offer
ep3_story_cycle_harrying.3054 = {
	type = character_event
	title = ep3_story_cycle_harrying.3054.t
	desc = ep3_story_cycle_harrying.3054.desc
	theme = harrying
	override_background = { reference = throne_room }
	left_portrait = {
		character = root
		animation = dismissal
	}
	right_portrait = {
		character = scope:william
		animation = rage
	}
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		location = {
			save_scope_as = location
		}
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Try to fight your way out
		name = ep3_story_cycle_harrying.3054.a

		duel = {
			skill = prowess
			value = very_high_skill_rating
			
			25 = { #You escape!
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3054.a.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3054.a.success
					left_icon = root

					add_prestige = major_prestige_gain

					scope:william = {
						add_prestige = major_prestige_loss
					}
				}

				start_travel_plan = {
					destination = root.domicile.domicile_location
					players_use_planner = no
					on_arrival_destinations = last
					return_trip = no
				}
			}
			75 = { #You are caught, beaten, and carted down to the cells
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3054.a.failure

				trigger_event = {
					id = ep3_story_cycle_harrying.3055
					days = 1
				}

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3054.a.failure

					ep3_decrease_resistance_effect = yes

					add_prestige = medium_prestige_loss
					
					increase_wounds_no_death_effect = { REASON = fight }

					scope:william = {
						imprison = {
							target = root
							type = dungeon
						}
					}
				}
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_loss
			callous = miniscule_stress_impact_loss
			compassionate = miniscule_stress_impact_gain
			generous = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_energy = 0.5
			}
		}
	}

	option = { #Allow yourself to be taken to the dungeons
		name = ep3_story_cycle_harrying.3054.b

		flavor = ep3_story_cycle_harrying.3054.b.tt

		ep3_decrease_resistance_effect = yes

		add_prestige = minor_prestige_loss

		scope:william = {
			imprison = {
				target = root
				type = dungeon
			}
		}

		trigger_event = {
			id = ep3_story_cycle_harrying.3055
			days = 1
		}

		stress_impact = {
			arrogant = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			generous = medium_stress_impact_loss
			humble = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_energy = 0.5
			}
		}
	}

	after = {
		ep3_harrying_widget_clear_effect = yes
		# Since we sent custom imprisonment events, we want to block the default ones.
		hidden_effect = {
			add_character_flag = {
				flag = block_imprisonment_event
				days = 2
			}
		}
	}
}

#You are thrown in the dungeon
ep3_story_cycle_harrying.3055 = {
	type = character_event
	title = ep3_story_cycle_harrying.3055.t
	desc = ep3_story_cycle_harrying.3055.desc
	theme = harrying
	override_background = { reference = dungeon }
	left_portrait = {
		character = root
		animation = prisondungeon
		outfit_tags = { beggar_rags }
	}
	right_portrait = {
		character = scope:william
		animation = schadenfreude
	}
	lower_center_portrait = {
		character = scope:sympathetic_courtier
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_imprisoned = yes
		imprisoner = scope:william
	}

	immediate = {
		if = {
			limit = {
				scope:william = {
					any_courtier = {
						culture = culture:anglo_saxon
					}
				}
			}
			scope:william = {
				random_courtier = {
					limit = {
						culture = culture:anglo_saxon
					}
					save_scope_as = sympathetic_courtier
				}
			}
		}
		else = {
			hidden_effect = {
				create_character = {
					employer = scope:william
					template = servant_character
					gender_female_chance = 50
					culture = culture:anglo_saxon
					faith = root.faith
					save_scope_as = sympathetic_courtier
				}
				scope:william = {
					add_courtier = scope:sympathetic_courtier
				}
			}
		}
		add_character_flag = harrying_imprisoned_flag
	}

	option = { #You look around your cell
		name = ep3_story_cycle_harrying.3055.a

		stress_impact = {
			base = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}

	after = {
		trigger_event = {
			id = ep3_story_cycle_harrying.3056
			days = { 30 40 }
		}
	}
}

# A mysterious letter appears
ep3_story_cycle_harrying.3056 = {
	type = character_event
	window = anonymous_letter_event
	title = debug.0002.t
	desc = ep3_story_cycle_harrying.3056.desc
	theme = harrying

	trigger = {
		has_ep3_dlc_trigger = yes
		is_imprisoned = yes
		imprisoner = scope:william
	}

	option = { # A lifeline!
		name = ep3_story_cycle_harrying.3056.a

		stress_impact = {
			base = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}		
	}

	after = {
		trigger_event = {
			id = ep3_story_cycle_harrying.3057
			days = { 2 4 }
		}
	}
}

#You are sprung free!
ep3_story_cycle_harrying.3057 = {
	type = character_event
	title = ep3_story_cycle_harrying.3057.t
	desc = ep3_story_cycle_harrying.3057.desc
	theme = harrying
	override_background = { reference = alley_night }

	left_portrait = {
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:sympathetic_courtier
		animation = survey
		outfit_tags = { western_stealth_hood }
	}
	widget = {
		gui = "event_window_widget_harrying"
		container = "custom_widgets_container"
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		is_imprisoned = yes
		imprisoner = scope:william
	}

	immediate = {
		ep3_harrying_widget_setup_effect = yes
	}

	option = { #Come with me!
		name = ep3_story_cycle_harrying.3057.a

		duel = {
			skill = diplomacy
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3057.a.success

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3057.a.success
					left_icon = root
					right_icon = scope:sympathetic_courtier
	
					add_courtier = scope:sympathetic_courtier

					reverse_add_opinion = {
						target = scope:sympathetic_courtier
						modifier = pleased_opinion
						opinion = 15
					}

					hidden_effect = {
						start_travel_plan = {
							destination = root.domicile.domicile_location
							players_use_planner = no
							on_arrival_destinations = last
							return_trip = no
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = ep3_story_cycle_harrying.3057.a.failure

				send_interface_toast = {
					title = ep3_story_cycle_harrying.3057.a.failure
					left_icon = root
					right_icon = scope:sympathetic_courtier

					add_stress = miniscule_stress_gain
				}
			}
		}

		release_from_prison = yes #Used here for event order reasons

		ai_chance = {
			base = 100
		}
	}

	option = { #I will always remember you.
		name = ep3_story_cycle_harrying.3057.b

		#scope:sympathetic_courtier = { #In case we ever wanna use him for something
		#	add_character_flag = sympathetic_courtier_flag
		#}

		stress_impact = {
			base = minor_stress_impact_loss
		}

		release_from_prison = yes #Used here for event order reasons

		ai_chance = {
			base = 100
		}
	}

	after = {
		start_travel_plan = {
			destination = root.domicile.domicile_location
			players_use_planner = no
			on_arrival_destinations = last
			return_trip = no
		}
		scope:sympathetic_courtier = {
			add_stress = medium_stress_loss #Prevent errors
		}
		ep3_harrying_widget_clear_effect = yes
		remove_character_flag = harrying_imprisoned_flag
	}
}
