﻿namespace = bp1_house_feud

##############################
##############################
######## START EVENTS ########
##############################
##############################

# bp1_house_feud.0001 - existing House Head rivalry
# bp1_house_feud.0002 - existing close family rivalry
# bp1_house_feud.0003 - close family killed by another house (yearly)
# bp1_house_feud.0004 - old House Head rivalry inherited
# bp1_house_feud.0005 - close family killed by another house (on reveal)
# bp1_house_feud.0006 - competing claims with another house
# bp1_house_feud.0007 - house head imprisoned for a while
# bp1_house_feud.0008 - close family imprisoned for a while
# bp1_house_feud.0009 - previous house head killed by another
# bp1_house_feud.0010 - house head tortured/blinded/castrated
# bp1_house_feud.0011 - close family tortured/blinded/castrated
# bp1_house_feud.0012 - house head cuckolded (yearly)
# bp1_house_feud.0013 - house head cuckolded (on reveal)
# bp1_house_feud.0014 - close family cuckolded (on reveal)

# House Head has rival of another house
bp1_house_feud.0001 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0001.t
	desc = {
		desc = bp1_house_feud.0001.desc
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = bedchamber }
	left_portrait = {
		character = root
		animation = boredom
		outfit_tags = { nightgown }
	}
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		# Someone to feud with
		any_relation = {
			type = rival
			save_temporary_scope_as = house_feud_victim_temp
			root = {
				valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_victim_temp }
			}
		}
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			any_relation = {
				type = nemesis
				save_temporary_scope_as = house_feud_victim_temp
				root = {
					valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_victim_temp }
				}
			}
		}
		modifier = {
			factor = 2
			any_relation = {
				type = rival
				primary_title.tier = root.primary_title.tier
				save_temporary_scope_as = house_feud_victim_temp
				root = {
					valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_victim_temp }
				}
			}
		}
		modifier = {
			factor = 1.25
			culture = { has_cultural_parameter = house_hostility_more_common }
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		random_relation = {
			type = rival
			limit = {
				save_temporary_scope_as = house_feud_victim_temp
				root = {
					valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_victim_temp }
				}
			}
			weight = {
				base = 1
				modifier = {
					factor = 1000
					has_relation_nemesis = root
				}
				modifier = {
					factor = 2
					primary_title.tier = root.primary_title.tier
				}
			}
			save_scope_as = house_feud_rival
		}
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = { # Start Feud
		name = bp1_house_feud.0001.a
		house_feud_start_effect = {
			# Feuding House Head
			ACTOR = root
			# Target House Head
			TARGET = scope:house_feud_rival
			# Feud Reason
			REASON = head_rivalry
			# House Member attacker if relevant
			ATTACKER = scope:house_feud_rival
			# House Member victim if relevant
			VICTIM = root
		}
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = { # Remain rivals
		name = bp1_house_feud.0001.b
		house_feud_forgiving_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}
}

# House Head's close family has a rival of another house
bp1_house_feud.0002 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0002.t
	desc = {
		desc = bp1_house_feud.0002.desc
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
	}
	right_portrait = {
		character = scope:house_feud_victim
		animation = worry
	}
	lower_center_portrait = scope:house_feud_attacker
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		# Someone to feud with
		any_close_family_member = {
			house_feud_member_trigger = yes
			any_relation = {
				type = rival
				save_temporary_scope_as = family_rival_temp
				root = {
					valid_for_feud_events_with_target_trigger = { TARGET = scope:family_rival_temp }
				}
			}
		}
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			any_close_family_member = {
				house_feud_member_trigger = yes
				any_relation = {
					type = nemesis
					save_temporary_scope_as = family_rival_temp
					root = {
						valid_for_feud_events_with_target_trigger = { TARGET = scope:family_rival_temp }
					}
				}
			}
		}
		modifier = {
			factor = 2
			any_close_family_member = {
				house_feud_member_trigger = yes
				any_relation = {
					type = rival
					house.house_head.primary_title.tier ?= root.primary_title.tier
					save_temporary_scope_as = family_rival_temp
					root = {
						valid_for_feud_events_with_target_trigger = { TARGET = scope:family_rival_temp }
					}
				}
			}
		}
		modifier = {
			factor = 1.25
			culture = { has_cultural_parameter = house_hostility_more_common }
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		set_local_venomous_creature_effect = yes
		random_close_family_member = {
			limit = {
				house_feud_member_trigger = yes
				any_relation = {
					type = rival
					save_temporary_scope_as = family_rival_temp
					root = {
						valid_for_feud_events_with_target_trigger = { TARGET = scope:family_rival_temp }
					}
				}
			}
			save_scope_as = house_feud_victim
			random_relation = {
				type = rival
				limit = {
					save_temporary_scope_as = family_rival_temp
					root = {
						valid_for_feud_events_with_target_trigger = { TARGET = scope:family_rival_temp }
					}
				}
				weight = {
					base = 1
					modifier = {
						factor = 10
						has_relation_nemesis = scope:house_feud_victim
					}
					modifier = {
						factor = 2
						primary_title.tier = root.primary_title.tier
					}
				}
				house_feud_save_head_and_attacker_effect = yes
			}
		}
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0002.a
        house_feud_start_effect = {
			# Feuding House Head
			ACTOR = root
			# Target House Head
			TARGET = scope:house_feud_attacker
			# Feud Reason
			REASON = family_rivalry
			# House Member attacker if relevant
			ATTACKER = scope:house_feud_attacker
			# House Member victim if relevant
			VICTIM = scope:house_feud_victim
		}
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_feud_opinion
		}
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0002.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			involved_character = scope:house_feud_victim
			reason = rival_house_feud_close_relative
		}
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_rival_opinion
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0002.b
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0002.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_ignored_opinion
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# House Head's close family was killed by another house (yearly)
bp1_house_feud.0003 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0003.t
	desc = {
		desc = bp1_house_feud.0003.desc
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = anger
	}
	lower_left_portrait = scope:house_feud_victim
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 5 }

	trigger = {
		# Someone to feud with
		house ?= {
			any_house_member = {
				only_if_dead = yes
				exists = killer
				save_temporary_scope_as = house_feud_victim_temp
				killer = {
					any_secret = {
						type = secret_murder
						secret_target = scope:house_feud_victim_temp
						is_known_by = root
					}
				}
			}
		}
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_victim_temp.killer }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			house ?= {
				any_house_member = {
					only_if_dead = yes
					exists = killer
					save_temporary_scope_as = house_feud_victim_temp
					killer = {
						any_secret = {
							type = secret_murder
							secret_target = scope:house_feud_victim_temp
							is_known_by = root
						}
					}
				}
			}
			valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_victim_temp.killer }
		}
		modifier = {
			factor = 1.25
			culture = { has_cultural_parameter = house_hostility_more_common }
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		house = {
			random_house_member = {
				only_if_dead = yes
				limit = {	
					exists = killer
					save_temporary_scope_as = house_feud_victim_temp
					killer = {
						any_secret = {
							type = secret_murder
							secret_target = scope:house_feud_victim_temp
							is_known_by = root
						}
					}
					root = {
						valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_victim_temp.killer }
					}
				}
				save_scope_as = house_feud_victim
				killer = { house_feud_save_head_and_attacker_effect = yes }
			}
		}
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0003.a
		house_feud_start_effect = {
			# Feuding House Head
			ACTOR = root
			# Target House Head
			TARGET = scope:house_feud_attacker
			# Feud Reason
			REASON = family_killed
			# House Member attacker if relevant
			ATTACKER = scope:house_feud_attacker
			# House Member victim if relevant
			VICTIM = scope:house_feud_victim
		}
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0003.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_vengeance
			involved_character = scope:house_feud_victim
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0003.b
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0003.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# Inheriting House Head considers rivals of predecessor
bp1_house_feud.0004 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0004.t
	desc = {
		desc = bp1_house_feud.0004.desc
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = worry
	}
	lower_left_portrait = scope:old_house_head
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		# Someone to feud with
		any_in_list = {
			list = old_house_head_rivals
			NOR = {
				is_close_family_of = root
				has_any_good_relationship_with_character_trigger = { CHARACTER = root }
			}
			save_temporary_scope_as = old_rival_temp
			root = {
				valid_for_feud_events_with_target_trigger = { TARGET = scope:old_rival_temp }
			}
		}
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		random_in_list = {
			list = old_house_head_rivals
			limit = {
				NOR = {
					is_close_family_of = root
					has_any_good_relationship_with_character_trigger = { CHARACTER = root }
				}
				save_temporary_scope_as = old_rival_temp
				root = {
					valid_for_feud_events_with_target_trigger = { TARGET = scope:old_rival_temp }
				}
			}
			weight = {
				modifier = {
					factor = 10
					exists = scope:old_house_head.killer.house
					this = scope:old_house_head.killer
				}
				modifier = {
					factor = 10
					has_relation_rival = root
				}
				modifier = {
					factor = 100
					has_relation_nemesis = root
				}
				modifier = {
					factor = 10
					exists = var:dead_nemesis
					var:dead_nemesis = scope:old_house_head
				}
			}
			save_scope_as = house_feud_rival
		}
		scope:old_house_head = { save_scope_as = house_feud_victim }
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0004.a
		house_feud_start_effect = {
			# Feuding House Head
			ACTOR = root
			# Target House Head
			TARGET = scope:house_feud_rival
			# Feud Reason
			REASON = inherited_rivalry
			# House Member attacker if relevant
			ATTACKER = scope:house_feud_rival
			# House Member victim if relevant 
			VICTIM = scope:old_house_head
		}
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0004.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_rival }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_rival }
		}
		set_relation_rival = {
			target = scope:house_feud_rival
			reason = rival_house_feud_leadership
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0004.b
			trigger = { has_relation_rival = scope:house_feud_rival }
		}
		name = {
			text = bp1_house_feud.0005.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_rival }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# House Head's close family was killed by another house (on reveal)
bp1_house_feud.0005 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0005.t
	desc = {
		desc = bp1_house_feud.0005.desc
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = anger
	}
	lower_left_portrait = scope:house_feud_victim
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 5 }

	trigger = {
		# Is valid feuder
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_rival }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0005.a
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = family_killed
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_attacker
            # House Member victim if relevant
            VICTIM = scope:house_feud_victim
	    }
		if = {
			limit = {
				scope:house_feud_rival = {
					any_secret = {
						type = secret_murder
						is_known_by = root
						save_temporary_scope_as = murder_secret_to_reveal
					}
				}
			}

			scope:murder_secret_to_reveal = {
				expose_secret = root
			}
		}

		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
			modifier = {
				factor = 1.25
				culture = {
					has_cultural_parameter = house_hostility_more_common
				}
			}
		}
	}

	option = {
		name = bp1_house_feud.0005.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_vengeance
			involved_character = scope:house_feud_victim
		}
		if = {
			limit = {
				scope:house_feud_rival = {
					any_secret = {
						type = secret_murder
						is_known_by = root
						save_temporary_scope_as = murder_secret_to_reveal
					}
				}
			}

			scope:murder_secret_to_reveal = {
				expose_secret = root
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0005.c.rival
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0005.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

scripted_trigger house_feud_competing_claims_trigger = {
	save_temporary_scope_as = house_feud_claim_temp
	root = { has_strong_claim_on = scope:house_feud_claim_temp }
	tier >= root.primary_title.tier
	holder ?= {
		NOT = { is_at_war_with = root }
	}
	root = {
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_claim_temp.holder }
	}
}

# Strong claims on land of another House
bp1_house_feud.0006 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0006.t
	desc = {
		desc = bp1_house_feud.0006.desc
		first_valid = {
		    triggered_desc = {
		        trigger = { scope:house_feud_claim.tier > root.primary_title.tier }
		        desc = bp1_house_feud.0006.higher
		    }
		    triggered_desc = {
		        trigger = { scope:house_feud_claim.tier = root.primary_title.tier }
		        desc = bp1_house_feud.0006.same
		    }
		    desc = bp1_house_feud.0006.multi
		}
		triggered_desc = {
	        trigger = { exists = scope:house_feud_previous }
	        desc = bp1_house_feud.0006.previous
	    }
	    triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = bp1_bonfire }
	left_portrait = {
		character = root
		animation = eyeroll
	}
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 2 }

	trigger = {
		# Has claims on lands held by other House
		any_claim = { house_feud_competing_claims_trigger = yes }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	weight_multiplier = {
		base = 1
		# Weight up for multiple claims
		modifier = {
			factor = 2
			any_claim = {
				house_feud_competing_claims_trigger = yes
				holder = {
					any_held_title = {
						count >= 3
						any_claimant = { this = root }
					}
				}
			}
		}
		# Weight up for neighboring claims
		modifier = {
			factor = 2
			any_claim = {
				house_feud_competing_claims_trigger = yes
				holder = { character_is_realm_neighbor = root }
			}
		}
		# Weight up for previously held by House
		modifier = {
			factor = 2
			any_claim = {
				house_feud_competing_claims_trigger = yes
				exists = previous_holder.house
				previous_holder.house = root.house
			}
		}
		# Weight up for rival claimant
		modifier = {
			factor = 2
			any_claim = {
				house_feud_competing_claims_trigger = yes
				holder = {
					has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
				}
			}
		}
		# Weight down for Humble/Content
		modifier = {
			factor = 0.5
			OR = {
				has_trait = humble
				has_trait = content
			}
		}
		modifier = {
			factor = 1.25
			culture = {
				has_cultural_parameter = house_hostility_more_common
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		random_claim = {
			limit = { house_feud_competing_claims_trigger = yes }
			weight = {
				# Weight up for multiple claims
				modifier = {
					factor = 2
					holder = {
						any_held_title = {
							count >= 3
							any_claimant = { this = root }
						}
					}
				}
				# Weight up for neighboring claims
				modifier = {
					factor = 2
					holder = { character_is_realm_neighbor = root }
				}
				# Weight up for previously held by House
				modifier = {
					factor = 2
					previous_holder.house ?= root.house
				}
				# Weight up for previously held by House
				modifier = {
					factor = 2
					holder = {
						has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
					}
				}
			}
			holder = {
				save_scope_as = house_feud_rival
				ordered_held_title = {
					limit = {
						save_temporary_scope_as = house_feud_claim_temp
						root = { has_strong_claim_on = scope:house_feud_claim_temp }
						tier >= root.primary_title.tier
					}
					order_by = tier
					save_scope_as = house_feud_claim
					if = {
						limit = { previous_holder.house ?= root.house }
						previous_holder = { save_scope_as = house_feud_previous }
					}
				}
			}
		}
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0006.a
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = competing_claim
            # House Member attacker if relevant 
            ATTACKER = scope:house_feud_rival
            # House Member victim if relevant
            VICTIM = root
	    }
		stress_impact = { content = medium_stress_impact_gain }
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0006.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_rival }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_rival }
		}
		set_relation_rival = {
			target = scope:house_feud_rival
			reason = rival_house_feud_land
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = bp1_house_feud.0006.c
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# Imprisoned for a while
bp1_house_feud.0007 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0007.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					imprisoner = { has_government = landless_adventurer_government }
				}
				desc = bp1_house_feud.0007.camp
			}
			triggered_desc = {
				trigger = { is_in_prison_type = house_arrest }
				desc = bp1_house_feud.0007.house_arrest
			}
			desc = bp1_house_feud.0007.dungeon
		}
		desc = bp1_house_feud.0007.desc
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}

	theme = rival_relation
	override_background = {
		trigger = { is_in_prison_type = house_arrest }
		reference = sitting_room
	}
	override_background = {
		trigger = { is_in_prison_type = dungeon }
		reference = dungeon
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { is_in_prison_type = house_arrest }
			animation = prisonhouse
		}
		triggered_outfit = {
			trigger = { is_in_prison_type = dungeon }
			outfit_tags = { beggar_rags }
		}
	}
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		#Standard checks
		is_alive = yes
		is_imprisoned = yes
		# Imprisoned for a while
		NOT = { is_at_war_with = imprisoner }
		time_in_prison = { weeks >= 2 }
		valid_for_feud_events_with_target_trigger = { TARGET = imprisoner }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			time_in_prison = { years >= 2 }
		}
		modifier = {
			factor = 2
			is_in_prison_type = dungeon
		}
		modifier = {
			factor = 1.25
			culture = {
				has_cultural_parameter = house_hostility_more_common
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		imprisoner = { house_feud_save_head_and_attacker_effect = yes }
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0007.a
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = head_imprisoned
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_rival
            # House Member victim if relevant
            VICTIM = root
	    }
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0007.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_imprisonment
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0007.b
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0007.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

scripted_trigger house_feud_close_family_prison_trigger = {
	house = root.house
	NOT = {
		has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
	}
	is_imprisoned = yes
	time_in_prison = { months >= 6 }
	imprisoner = {
		NOT = { is_at_war_with = root }
	}
	save_temporary_scope_as = close_family_temp
	root = {
		valid_for_feud_events_with_target_trigger = { TARGET = scope:close_family_temp.imprisoner }
	}
}

# Close family imprisoned for a while
bp1_house_feud.0008 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0008.t
	desc = {
		desc = bp1_house_feud.0008.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:house_feud_victim.imprisoner = { has_government = landless_adventurer_government }
				}
				desc = bp1_house_feud.0008.camp
			}
			triggered_desc = {
				trigger = {
					scope:house_feud_victim = { is_in_prison_type = house_arrest }
				}
				desc = bp1_house_feud.0008.house_arrest
			}
			desc = bp1_house_feud.0008.dungeon
		}
		desc = bp1_house_feud.0008.closing
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = bp1_kitchen_western }
	left_portrait = {
		character = root
		animation = anger
	}
	lower_left_portrait = scope:house_feud_victim
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		# Close family member imprisoned
		any_close_family_member = { house_feud_close_family_prison_trigger = yes }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			any_close_family_member = {
				house_feud_close_family_prison_trigger = yes
				time_in_prison = { years >= 2 }
			}
		}
		modifier = {
			factor = 2
			any_close_family_member = {
				house_feud_close_family_prison_trigger = yes
				is_in_prison_type = dungeon
			}
		}
		modifier = {
			factor = 1.25
			culture = {
				has_cultural_parameter = house_hostility_more_common
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		random_close_family_member = {
			limit = { house_feud_close_family_prison_trigger = yes }
			weight = {
				base = 10
				modifier = {
					add = 10
					time_in_prison = { years >= 2 }
				}
				modifier = {
					add = 10
					is_in_prison_type = dungeon
				}
			}
			save_scope_as = house_feud_victim
			imprisoner = { house_feud_save_head_and_attacker_effect = yes }
		}
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0008.a
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = family_imprisoned
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_rival
            # House Member victim if relevant
            VICTIM = scope:house_feud_victim
	    }
		if = {
			limit = {
				scope:house_feud_victim = { is_ai = yes }
			}
			reverse_add_opinion = {
				target = scope:house_feud_victim
				modifier = house_feud_victim_feud_opinion
			}
		}
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0008.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_imprisonment
		}
		if = {
			limit = {
				scope:house_feud_victim = { is_ai = yes }
			}
			reverse_add_opinion = {
				target = scope:house_feud_victim
				modifier = house_feud_victim_rival_opinion
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0008.b
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0008.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		if = {
			limit = {
				scope:house_feud_victim = { is_ai = yes }
			}
			reverse_add_opinion = {
				target = scope:house_feud_victim
				modifier = house_feud_victim_ignored_opinion
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# House Head killed by another house (inheritor)
bp1_house_feud.0009 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0009.t
	desc = {
		first_valid = {
		    triggered_desc = {
		        trigger = { has_character_flag = house_feud_too_young_heir }
		        desc = bp1_house_feud.0009.child
		    }
		    desc = bp1_house_feud.0009.adult
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:house_feud_rival = {
						house_has_feud_relation_with_trigger = { TARGET = root }
					}
				}
				desc = bp1_house_feud.0009.reciprocate
			}
			desc = bp1_house_feud.0009.new
		}
		desc = bp1_house_feud.0009.closing
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = terrain }
	left_portrait = {
		character = root
		animation = anger
	}
	lower_left_portrait = scope:old_house_head
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		# Is valid feuder
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_rival }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0009.a
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = head_killed
            # House Member attacker if relevant
            ATTACKER = scope:old_house_head.killer
            # House Member victim if relevant
            VICTIM = scope:old_house_head
	    }
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
			modifier = {
				factor = 1.25
				culture = { has_cultural_parameter = house_hostility_more_common }
			}
		}
	}

	option = {
		name = bp1_house_feud.0009.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_death_of_house_head_vengeance
			involved_character = scope:old_house_head
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0009.b
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0009.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}

	after = {
		# Clear up flags
		if = {
			limit = { has_character_flag = house_feud_too_young_heir }
			remove_character_flag = house_feud_too_young_heir
		}
	}
}

scripted_effect house_feud_torture_flag_cleanup_effect = {
	if = {
		limit = { has_character_flag = house_feud_castration_flag }
		remove_character_flag = house_feud_castration_flag
	}
	else_if = {
		limit = { has_character_flag = house_feud_blinding_flag }
		remove_character_flag = house_feud_blinding_flag
	}
}

# House head tortured/blinded/castrated
bp1_house_feud.0010 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0010.t
	desc = {
		first_valid = {
			triggered_desc = {
		        trigger = { has_character_flag = house_feud_blinding_flag }
		        desc = bp1_house_feud.0010.blinding
		    }
		    triggered_desc = {
		        trigger = { has_character_flag = house_feud_castration_flag }
		        desc = bp1_house_feud.0010.castration
		  	}
		  	desc = bp1_house_feud.0010.torture
		}
		first_valid = {
		    triggered_desc = {
		        trigger = {	is_in_prison_type = house_arrest }
		        desc = bp1_house_feud.0010.house_arrest
		    }
		    triggered_desc = {
		        trigger = { is_in_prison_type = dungeon }
		        desc = bp1_house_feud.0010.dungeon
		    }
		    desc = bp1_house_feud.0010.free
		}
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = {
		trigger = { is_in_prison_type = house_arrest }
		reference = sitting_room
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { is_in_prison_type = house_arrest }
			animation = prisonhouse
		}
	}
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		# Is valid feuder
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_rival }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0010.a
		trigger = {
			house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
		}
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = head_tortured
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_rival
            # House Member victim if relevant
            VICTIM = root
	    }
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
			modifier = {
				factor = 1.25
				culture = { has_cultural_parameter = house_hostility_more_common }
			}
		}
	}

	#option = { # Swap feud
	#	name = bp1_house_feud.0501.b
	#	trigger = {
	#		exists = scope:house_feud_existing
	#		NOT = { exists = var:house_feud_swapped_house }
	#	}
	#	house_feud_swap_feud_effect = {
	#		# Feuding House Head
	#		ACTOR = root
	#		# Target House Head
	#		TARGET = scope:house_feud_attacker
	#		# Feud Reason
	#		REASON = head_tortured
	#		# House Member attacker if relevant
	#		ATTACKER = scope:house_feud_attacker
	#		 # House Member victim if relevant
	#		VICTIM = root
	#	}
	#	stress_impact = {
	#		just = medium_stress_impact_gain
	#		forgiving = medium_stress_impact_gain
	#	}
	#	ai_chance = {
	#		base = 25
	#		ai_value_modifier = {
	#			ai_honor = -0.5
	#			ai_boldness = 1
	#			ai_vengefulness = 1
	#		}
	#	}
	#}

	option = {
		name = bp1_house_feud.0010.c
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		if = {
			limit = { has_character_flag = house_feud_blinding_flag }
			set_relation_rival = {
				target = scope:house_feud_attacker
				reason = rival_house_feud_house_head_blinded
			}
		}
		else_if = {
			limit = { has_character_flag = house_feud_castration_flag }
			set_relation_rival = {
				target = scope:house_feud_attacker
				reason = rival_house_feud_house_head_castrated
			}
		}
		else = {
			set_relation_rival = {
				target = scope:house_feud_attacker
				reason = rival_house_feud_house_head_tortured
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0010.c
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0010.d
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
				ai_compassion = 0.5
			}
		}
	}

	after = { house_feud_torture_flag_cleanup_effect = yes }
}

# Close family tortured/blinded/castrated
bp1_house_feud.0011 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0011.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:house_feud_victim = { has_character_flag = house_feud_blinding_flag }
				}
				desc = bp1_house_feud.0011.blinding
			}
			triggered_desc = {
				trigger = {
					scope:house_feud_victim = { has_character_flag = house_feud_castration_flag }
				}
				desc = bp1_house_feud.0011.castration
			}
			desc = bp1_house_feud.0011.torture
		}
		first_valid = {
			triggered_desc = {
				trigger = {	
					scope:house_feud_attacker = { has_government = landless_adventurer_government }
				}
				desc = bp1_house_feud.0011.camp
			}
			triggered_desc = {
				trigger = {	
					scope:house_feud_victim = { is_in_prison_type = house_arrest }
				}
				desc = bp1_house_feud.0011.house_arrest
			}
			triggered_desc = {
				trigger = {
					scope:house_feud_victim = { is_in_prison_type = dungeon }
				}
				desc = bp1_house_feud.0011.dungeon
			}
			desc = bp1_house_feud.0011.free
		}
		desc = bp1_house_feud.0011.closing
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = worry
	}
	lower_left_portrait = scope:house_feud_victim
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		# Is valid feuder
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_rival }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0011.a
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = family_tortured
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_rival
            # House Member victim if relevant
            VICTIM = scope:house_feud_victim
	    }
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_feud_opinion
		}
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
			modifier = {
				factor = 1.25
				culture = { has_cultural_parameter = house_hostility_more_common }
			}
		}
		
	}

	option = {
		name = bp1_house_feud.0011.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		if = {
			limit = {
				scope:house_feud_victim = { has_character_flag = house_feud_blinding_flag }
			}
			set_relation_rival = {
				target = scope:house_feud_attacker
				reason = rival_house_feud_blinding
				involved_character = scope:house_feud_victim
			}
		}
		else_if = {
			limit = {
				scope:house_feud_victim = { has_character_flag = house_feud_castration_flag }
			}
			set_relation_rival = {
				target = scope:house_feud_attacker
				reason = rival_house_feud_castrated
				involved_character = scope:house_feud_victim
			}
		}
		else =	{
			set_relation_rival = {
				target = scope:house_feud_attacker
				reason = rival_house_feud_torture
				involved_character = scope:house_feud_victim
			}
		}
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_rival_opinion
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0011.b
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0011.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_ignored_opinion
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
				ai_compassion = 0.5
			}
		}
	}

	after = {
		scope:house_feud_victim = { house_feud_torture_flag_cleanup_effect = yes }
	}
}

# House Head cuckolded (yearly)
bp1_house_feud.0012 = {
	type = character_event
	content_source = dlc_006
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { is_female = yes }
				desc = bp1_house_feud.0012.t.female
			}
			desc = bp1_house_feud.0012.t
		}
	}
	desc = {
		desc = bp1_house_feud.0012.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:house_feud_victim }
				}
				desc = bp1_house_feud.0012.bad
			}
			desc = bp1_house_feud.0012.good
		}
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = rage
	}
	lower_left_portrait = scope:house_feud_spouse
	lower_right_portrait = scope:house_feud_attacker
	cooldown = { years = 10 }

	trigger = {
		# Someone to feud with
		any_spouse = {
			any_targeting_secret = {
				secret_type = secret_lover
				is_known_by = root
				secret_owner = { save_temporary_scope_as = cuckolder_temp }
				root = {
					valid_for_feud_events_with_target_trigger = { TARGET = scope:cuckolder_temp }
					NOT = {
						house_has_feud_relation_with_trigger = { TARGET = scope:cuckolder_temp }
					}
				}
			}
		}
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			any_spouse = {
				any_targeting_secret = {
					secret_type = secret_lover
					is_known_by = root
					secret_owner = {
						has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
						save_temporary_scope_as = cuckolder_temp
					}
				}
				root = {
					valid_for_feud_events_with_target_trigger = { TARGET = scope:cuckolder_temp }
					NOT = {
						house_has_feud_relation_with_trigger = { TARGET = scope:cuckolder_temp }
					}
				}
			}

		}
		modifier = {
			factor = 1.25
			culture = { has_cultural_parameter = house_hostility_more_common }
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		save_scope_as = house_feud_victim
		random_spouse = {
			limit = {	
				any_targeting_secret = {
					secret_type = secret_lover
					is_known_by = root
					secret_owner = { save_temporary_scope_as = cuckolder_temp }
					root = {
						valid_for_feud_events_with_target_trigger = { TARGET = scope:cuckolder_temp }
						NOT = {
							house_has_feud_relation_with_trigger = { TARGET = scope:cuckolder_temp }
						}
					}
				}
			}
			weight = {
				modifier = {
					factor = 10
					this = root.primary_spouse
				}
			}
			save_scope_as = house_feud_spouse
			random_targeting_secret = {
				limit = {
					secret_type = secret_lover
					is_known_by = root
					secret_owner = { save_temporary_scope_as = cuckolder_temp }
					root = {
						valid_for_feud_events_with_target_trigger = { TARGET = scope:cuckolder_temp }
						NOT = {
							house_has_feud_relation_with_trigger = { TARGET = scope:cuckolder_temp }
						}
					}
				}
				secret_owner = { house_feud_save_head_and_attacker_effect = yes }
			}
		}
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0012.a
		trigger = {
			NOT = {
				house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
			}
		}
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = head_cuckolded
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_attacker
            # House Member victim if relevant
            VICTIM = root
	    }
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	#option = { # Swap feud
	#	name = bp1_house_feud.0501.b
	#	trigger = {
	#		exists = scope:house_feud_existing
	#		NOT = { exists = var:house_feud_swapped_house }
	#	}
	#	house_feud_swap_feud_effect = {
	#		# Feuding House Head
	#		ACTOR = root
	#		# Target House Head
	#		TARGET = scope:house_feud_attacker
	#		# Feud Reason
	#		REASON = head_cuckolded
	#		# House Member attacker if relevant
	#		ATTACKER = scope:house_feud_attacker
	#		 # House Member victim if relevant
	#		VICTIM = root
	#	}
	#	stress_impact = {
	#		just = medium_stress_impact_gain
	#		forgiving = medium_stress_impact_gain
	#	}
	#	ai_chance = {
	#		base = 25
	#		ai_value_modifier = {
	#			ai_honor = -0.5
	#			ai_boldness = 1
	#			ai_vengefulness = 1
	#		}
	#	}
	#}

	option = {
		name = bp1_house_feud.0012.c
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_cuckold
			involved_character = scope:house_feud_spouse
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0012.c
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0012.d
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# House Head cuckolded (on reveal)
bp1_house_feud.0013 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0013.t
	desc = {
		desc = bp1_house_feud.0013.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:house_feud_victim }
				}
				desc = bp1_house_feud.0012.bad
			}
			desc = bp1_house_feud.0012.good
		}
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = anger
	}
	lower_left_portrait = scope:house_feud_spouse
	lower_right_portrait = scope:house_feud_attacker
	cooldown = { years = 5 }

	trigger = {
		# Is valid feuders
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_rival }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0013.a
		trigger = {
			NOT = {
				house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
			}
		}
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = head_cuckolded
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_attacker
            # House Member victim if relevant
            VICTIM = root
	    }
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
			modifier = {
				factor = 1.25
				culture = { has_cultural_parameter = house_hostility_more_common }
			}
		}
	}

	#option = { # Swap feud
	#	name = bp1_house_feud.0501.b
	#	trigger = {
	#		exists = scope:house_feud_existing
	#		NOT = { exists = var:house_feud_swapped_house }
	#	}
	#	house_feud_swap_feud_effect = {
	#		# Feuding House Head
	#		ACTOR = root
	#		# Target House Head
	#		TARGET = scope:house_feud_attacker
	#		# Feud Reason
	#		REASON = head_cuckolded
	#		# House Member attacker if relevant
	#		ATTACKER = scope:house_feud_attacker
	#		 # House Member victim if relevant
	#		VICTIM = root
	#	}
	#	stress_impact = {
	#		just = medium_stress_impact_gain
	#		forgiving = medium_stress_impact_gain
	#	}
	#	ai_chance = {
	#		base = 25
	#		ai_value_modifier = {
	#			ai_honor = -0.5
	#			ai_boldness = 1
	#			ai_vengefulness = 1
	#		}
	#	}
	#}

	option = {
		name = bp1_house_feud.0013.c
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_cuckold
			involved_character = scope:house_feud_spouse
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0013.c
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0013.d
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# Close family of House Head cuckolded (on reveal)
bp1_house_feud.0014 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0014.t
	desc = {
		desc = bp1_house_feud.0014.desc
		triggered_desc = {
			trigger = { exists = scope:relation.var:house_feud_reason }
			desc = bp1_house_feud.0001.target
		}
	}
	theme = rival_relation
	override_background = { reference = bp1_wine_cellar }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:house_feud_victim
		animation = rage
	}
	lower_left_portrait = scope:house_feud_spouse
	lower_right_portrait = scope:house_feud_attacker
	cooldown = { years = 5 }

	trigger = {
		# Is valid feuder
		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_attacker }
		NOT = {
			house = {
				any_house_relation = { has_variable = house_feud_cooldown }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_negative"
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0014.a
		house_feud_start_effect = {
            # Feuding House Head
            ACTOR = root
            # Target House Head
            TARGET = scope:house_feud_rival
            # Feud Reason
            REASON = family_cuckolded
            # House Member attacker if relevant
            ATTACKER = scope:house_feud_attacker
            # House Member victim if relevant
            VICTIM = scope:house_feud_victim
	    }
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_feud_opinion
		}
		# Stress effects in scripted_effect
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
			modifier = {
				factor = 1.25
				culture = { has_cultural_parameter = house_hostility_more_common }
			}
		}
	}

	option = {
		name = bp1_house_feud.0014.b
		trigger = {
			NOT = { has_relation_rival = scope:house_feud_attacker }
			can_set_relation_rival_trigger = { CHARACTER = scope:house_feud_attacker }
		}
		set_relation_rival = {
			target = scope:house_feud_attacker
			reason = rival_house_feud_cuckold_family
			involved_character = scope:house_feud_victim
		}
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_rival_opinion
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = {
			text = bp1_house_feud.0014.b
			trigger = { has_relation_rival = scope:house_feud_attacker }
		}
		name = {
			text = bp1_house_feud.0014.c
			trigger = {
				NOT = { has_relation_rival = scope:house_feud_attacker }
			}
		}
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_ignored_opinion
		}
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

##############################
##############################
####### ONGOING EVENTS #######
##############################
##############################

# bp1_house_feud.0100 - feud house is higher rank
# bp1_house_feud.0110 - feud house is lower rank
# bp1_house_feud.0200 - losing feud, start scheme
# bp1_house_feud.0210 - more deaths and recent one
# bp1_house_feud.0220 - more kills
# bp1_house_feud.0300 - long running feud
# bp1_house_feud.0410 - house members pleading to stop feud
# bp1_house_feud.0420 - liege tries to be a peacemaker

# Jealous of higher rank
bp1_house_feud.0100 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0100.t
	desc = bp1_house_feud.0100.desc
	theme = rival_relation
	left_portrait = {
		character = root
		animation = worry
	}
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 25 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		# Other house is higher overall rank
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				any_relation_house = {
					NOT = { this = root.house }
					house_head = {
						OR = {
							highest_held_title_tier > root.highest_held_title_tier
							AND = {
								is_ruler = yes
								root = { is_ruler = no }
							}
						}
						save_temporary_scope_as = other_head_temp
					}					
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			tier_difference = {
				target = scope:other_head_temp
				value <= -2
			}
		}
		modifier = {
			factor = 2
			OR = {
				has_trait = content
				has_trait = humble
			}
		}
	}

	immediate = {
		house ?= {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					any_relation_house = {
						NOT = { this = root.house }
						house_head = {
							OR = {
								highest_held_title_tier > root.highest_held_title_tier
								AND = {
									is_ruler = yes
									root = { is_ruler = no }
								}
							}
							save_temporary_scope_as = house_feud_rival_temp
						}					
					}
				}
				save_scope_as = relation
			}
			scope:house_feud_rival_temp = { save_scope_as = house_feud_rival }
		}
		scope:relation = {
			if = {
				limit = {
					NOT = { exists = var:house_feud_victim }
				}
				set_variable = { name = house_feud_victim value = scope:house_feud_rival }
			}
		}
	}

	option = {
		name = bp1_house_feud.0100.a
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_damage_minor_value
				REASON = lower_tier
				CHAR = root
				TARGET_CHAR = scope:house_feud_rival
				TITLE = scope:dummy_gender
			}
		}
		stress_impact = {
			base = minor_stress_impact_gain
			humble = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0100.b
		add_prestige = medium_prestige_loss
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		stress_impact = {
			base = minor_stress_impact_loss
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

# Scorning lower rank
bp1_house_feud.0110 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0110.t
	desc = bp1_house_feud.0110.desc
	theme = rival_relation
	override_background = { reference = garden }
	left_portrait = {
		character = root
		animation = worry
	}
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 25 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		# Other house is lower overall rank
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				any_relation_house = {
					this != root.house
					house_head = {
						OR = {
							highest_held_title_tier < root.highest_held_title_tier
							is_ruler = no
						}
						save_temporary_scope_as = other_head_temp
					}					
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			trigger_if = {
				limit = {
					exists = scope:other_head_temp
				}
				OR = {
					scope:other_head_temp = { is_landed = no }
					tier_difference = {
						target = scope:other_head_temp
						value >= 2
					}
				}	
			}
		}
		modifier = {
			factor = 2
			NOR = {
				has_trait = arrogant
				has_trait = ambitious
			}
		}
	}

	immediate = {
		house ?= {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					any_relation_house = {
						NOT = { this = root.house }
						house_head = {
							OR = {
								highest_held_title_tier < root.highest_held_title_tier
								is_ruler = no
							}
							save_temporary_scope_as = house_feud_rival_temp
						}					
					}
				}
				save_scope_as = relation
			}
			scope:house_feud_rival_temp = { save_scope_as = house_feud_rival }
		}
		scope:relation = {
			if = {
				limit = {
					NOT = { exists = var:house_feud_victim }
				}
				set_variable = { name = house_feud_victim value = scope:house_feud_rival }
			}
		}
	}

	option = { # Justice must be served
		name = bp1_house_feud.0110.a
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_damage_minor_value
				REASON = higher_tier
				CHAR = root
				TARGET_CHAR = scope:house_feud_rival
				TITLE = scope:dummy_gender
			}
		}
		stress_impact = {
			base = minor_stress_impact_gain
			ambitious = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = { # They are beneath our energies
		name = bp1_house_feud.0110.b
		add_prestige = medium_prestige_gain
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		stress_impact = {
			base = minor_stress_impact_loss
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
			}
		}
	}
}

scripted_trigger house_relation_feud_fewer_kills_trigger = {
	exists = var:house_feud_house_1
	exists = var:house_feud_house_2
	exists = var:house_feud_house_1_score
	exists = var:house_feud_house_2_score
	trigger_if = {
		limit = { root.house = var:house_feud_house_1 }
		var:house_feud_house_1_score < var:house_feud_house_2_score
	}
	trigger_else = { var:house_feud_house_1_score > var:house_feud_house_2_score }
}

# Feud house has killed more members than we have, start scheme?
bp1_house_feud.0200 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0200.t
	desc = bp1_house_feud.0200.desc
	theme = rival_relation
	override_background = { reference = corridor_night }
	left_portrait = {
		character = root
		animation = worry
	}
	lower_center_portrait = scope:house_feud_target
	lower_right_portrait = scope:other_house.house_head
	cooldown = { years = 10 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				# We have more deaths than kills
				house_relation_feud_fewer_kills_trigger = yes
				# Eligible scheme target exists
				any_relation_house = {
					NOT = { this = root.house }
					any_house_member = { house_feud_scheme_target_trigger = yes }
				}
			}
		}
	}

	immediate = {
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					house_relation_feud_fewer_kills_trigger = yes
					# Eligible scheme target exists
					any_relation_house = {
						NOT = { this = root.house }
						any_house_member = { house_feud_scheme_target_trigger = yes }
					}
				}
				random_relation_house = {
					limit = {
						NOT = { this = root.house }
					}
					save_scope_as = other_house
					house_head = { save_scope_as = house_feud_rival }
					while = {
						limit = {
							any_in_list = {
								list = house_feud_scheme_targets
								count < 2
							}
							any_house_member = {
								is_available_healthy_adult = yes
								house_feud_scheme_target_trigger = yes
							}
						}
						random_house_member = {
							limit = { house_feud_scheme_target_trigger = yes }
							weight = {
								modifier = {
									factor = 2
									scope:other_house.house_head.primary_heir ?= this
								}
								modifier = {
									factor = 2
									age < 50
								}
							}
							add_to_list = house_feud_scheme_targets
						}
					}
					ordered_in_list = {
						list = house_feud_scheme_targets
						order_by = age
						save_scope_as = house_feud_target
					}
				}
			}
		}
	}

	option = {
		name = bp1_house_feud.0200.a
		trigger = {
			NOT = {
				is_scheming_against = { target = scope:house_feud_rival }
			}
			can_start_scheme = {
				type = murder
				target_character = scope:house_feud_rival
			}
		}
		start_scheme = {
			target_character = scope:house_feud_rival
			type = murder
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
				ai_honor = -1
			}
		}
	}

	option = {
		name = bp1_house_feud.0200.b
		start_scheme = {
			target_character = scope:house_feud_target
			type = murder
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
				ai_honor = -1
			}
		}
	}

	option = {
		name = bp1_house_feud.0200.c
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_vengefulness = 0.5
				ai_honor = 0.5
			}
		}
	}

	option = {
		name = bp1_house_feud.0200.d
		add_prestige = medium_prestige_loss
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:other_house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
				ai_honor = -0.5
			}
		}
	}
}

# Losing, cut losses?
bp1_house_feud.0210 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0210.t
	desc = {
		desc = bp1_house_feud.0210.desc
		triggered_desc = {
			trigger = { exists = scope:house_feud_recent_death }
			desc = bp1_house_feud.0210.recent
		}
	}
	theme = rival_relation
	left_portrait = {
		character = root
		animation = worry
	}
	lower_left_portrait = scope:house_feud_recent_death
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 10 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		house = {
			any_house_relation = {
				# We have more deaths than kills
				has_house_relation_level = feud
				house_relation_feud_fewer_kills_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 10
			house = {
				any_house_relation = {
					has_house_relation_level = feud
					house_relation_feud_fewer_kills_trigger = yes
					trigger_if = {
						limit = { root.house = var:house_feud_house_1 }
						exists = var:house_feud_house_2_recent_kill
					}
					trigger_else = { exists = var:house_feud_house_1_recent_kill }
				}
			}
		}
	}

	immediate = {
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					house_relation_feud_fewer_kills_trigger = yes
					trigger_if = {
						limit = { var:house_feud_house_1 ?= root.house }
						exists = var:house_feud_house_2_recent_kill
					}
					trigger_else = { exists = var:house_feud_house_1_recent_kill }
				}
				alternative_limit = {
					has_house_relation_level = feud
					house_relation_feud_fewer_kills_trigger = yes
				}
				save_scope_as = relation
				if = {
					limit = { var:house_feud_house_1 ?= root.house }
					var:house_feud_house_2.house_head = { save_scope_as = house_feud_rival }
					var:house_feud_house_2_recent_kill ?= { save_scope_as = house_feud_recent_death }
				}
				else = {
					var:house_feud_house_1.house_head = { save_scope_as = house_feud_rival }
					var:house_feud_house_1_recent_kill ?= { save_scope_as = house_feud_recent_death }
				}
			}
		}
	}

	option = { # Continue feud
		name = bp1_house_feud.0210.a
		stress_impact = {
			base = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 1
			}
		}
	}

	option = { # End feud
		name = bp1_house_feud.0210.b
		add_prestige = medium_prestige_loss
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -1
				ai_vengefulness = -1
				ai_honor = -0.5
			}
		}
	}
}

scripted_trigger house_relation_feud_more_kills_trigger = {
	exists = var:house_feud_house_1
	exists = var:house_feud_house_2
	exists = var:house_feud_house_1_score
	exists = var:house_feud_house_2_score
	trigger_if = {
		limit = { root.house = var:house_feud_house_1 }
		var:house_feud_house_1_score > var:house_feud_house_2_score
	}
	trigger_else = { var:house_feud_house_1_score < var:house_feud_house_2_score }
}

# Winning, end it?
bp1_house_feud.0220 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0220.t
	desc = {
		desc = bp1_house_feud.0220.desc
		triggered_desc = {
			trigger = { exists = scope:house_feud_recent_kill }
			desc = bp1_house_feud.0220.recent
		}
	}
	theme = rival_relation
	left_portrait = {
		character = root
		animation = worry
	}
	lower_left_portrait = scope:house_feud_recent_kill
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 10 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				house_relation_feud_more_kills_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 10
			house = {
				any_house_relation = {
					has_house_relation_level = feud
					house_relation_feud_more_kills_trigger = yes
					trigger_if = {
						limit = { root.house = var:house_feud_house_1 }
						exists = var:house_feud_house_1_recent_kill
					}
					trigger_else = { exists = var:house_feud_house_2_recent_kill }
				}
			}
		}
	}

	immediate = {
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					house_relation_feud_more_kills_trigger = yes
					trigger_if = {
						limit = { var:house_feud_house_1 ?= root.house }
						exists = var:house_feud_house_1_recent_kill
					}
					trigger_else = { exists = var:house_feud_house_2_recent_kill }
				}
				alternative_limit = {
					has_house_relation_level = feud
					house_relation_feud_more_kills_trigger = yes
				}
				save_scope_as = relation
				if = {
					limit = { var:house_feud_house_1 ?= root.house }
					var:house_feud_house_2.house_head = { save_scope_as = house_feud_rival }
					var:house_feud_house_1_recent_kill ?= { save_scope_as = house_feud_recent_kill }
				}
				else = {
					var:house_feud_house_1.house_head = { save_scope_as = house_feud_rival }
					var:house_feud_house_2_recent_kill ?= { save_scope_as = house_feud_recent_kill }
				}
				if = { #Fallback for Loc
					limit = {
						NOT = { exists = var:house_feud_victim }
					}
					set_variable = { name = house_feud_victim value = scope:house_feud_rival }
				}
			}
		}
	}

	option = {
		name = bp1_house_feud.0220.a
		stress_impact = {
			base = minor_stress_impact_gain
			compassionate = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0220.b
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}
}

# End long running feud?
bp1_house_feud.0300 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0300.t
	desc = bp1_house_feud.0300.desc
	theme = rival_relation
	override_background = { reference = sitting_room }
	left_portrait = {
		character = root
		animation = boredom
	}
	lower_left_portrait = scope:house_feud_attacker
	lower_center_portrait = scope:house_feud_victim
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 10 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		#Standard checks
		is_available_adult = yes
		# Not the original feud starter
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				var:house_feud_house_1_first_head = { is_alive = no }
				var:house_feud_house_2_first_head = { is_alive = no }
				OR = { #If a victim and attacker exists, they must be dead. If not then we pass this check.
					AND = {
						var:house_feud_attacker ?= { is_alive = no }
						NOT = { exists = var:house_feud_attacker }
					}
					AND = {
						var:house_feud_victim ?= { is_alive = no }
						NOT = { exists = var:house_feud_victim }
					}
				}
				exists = var:house_relation_duration_years
				var:house_relation_duration_years >= 10
			}
		}
	}

	immediate = {
		house ?= {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					var:house_feud_house_1_first_head ?= { is_alive = no }
					var:house_feud_house_2_first_head ?= { is_alive = no }
					OR = { #If a victim and attacker exists, they must be dead. If not then we pass this check.
						AND = {
							var:house_feud_attacker ?= { is_alive = no }
							NOT = { exists = var:house_feud_attacker }
						}
						AND = {
							var:house_feud_victim ?= { is_alive = no }
							NOT = { exists = var:house_feud_victim }
						}
					}
					exists = var:house_relation_duration_years
					var:house_relation_duration_years >= 10	
				}
				random_relation_house = {
					limit = {
						NOT = { this = root.house }
					}
					house_head = { save_scope_as = house_feud_rival }
				}
				save_scope_as = relation
				if = {
					limit = {
						NOT = { exists = var:house_feud_victim }
					}
					set_variable = { name = house_feud_victim value = scope:first_owner }
				}
			}
		}
	}

	option = {
		name = bp1_house_feud.0300.a
		stress_impact = {
			base = minor_stress_impact_gain
			forgiving = major_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
				ai_honor = -0.5
			}
		}
	}

	option = {
		name = bp1_house_feud.0300.b
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
				ai_honor = 0.5
			}
		}
	}
}

# House members pleading to stop feud
bp1_house_feud.0410 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0410.t
	desc = bp1_house_feud.0410.desc
	theme = rival_relation
	left_portrait = {
		character = root
		animation = disapproval
	}
	right_portrait = {
		character = scope:house_feud_victim
		animation = beg
	}
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 10 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		# House member is friendly with feuding house member
		house = {
			any_house_member = {
				is_available_ai_adult = yes
				NOR = {
					this = root
					has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
					has_trait = vengeful
				}
				save_temporary_scope_as = member_temp
			}
			any_house_relation = {
				has_house_relation_level = feud
				any_relation_house = {
					NOR = {
						this = root.house
						house_head ?= {
							has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:member_temp }
						}
					}
				}
			}
		}
	}

	immediate = {
		house = {
			save_scope_as = house
			random_house_member = {
				limit = {
					is_available_ai_adult = yes
					NOR = {
						this = root
						has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
						has_trait = vengeful
					}
					save_temporary_scope_as = rival_temp
					scope:rival_temp.house = {
						any_house_relation = {
							has_house_relation_level = feud
							any_relation_house = {
								NOR = {
									this = root.house
									house_head ?= {
										has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:rival_temp }
									}
								}
							}
						}
					}
				}
				weight = {
					modifier = {
						factor = 2
						has_trait = paranoid
					}
					modifier = {
						factor = 10
						is_powerful_vassal_of = root
					}
					modifier = {
						factor = 10
						is_landed = yes
					}
				}
				save_scope_as = house_feud_victim
				stress_impact = {
					base = medium_stress_impact_gain
					paranoid = medium_stress_impact_gain
				}
				scope:rival_temp = { save_scope_as = house_feud_rival }
			}
		}
	}

	option = {
		name = bp1_house_feud.0410.a
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_liege_cancelled_opinion
		}
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}

	option = {
		name = bp1_house_feud.0410.b
		reverse_add_opinion = {
			target = scope:house_feud_victim
			modifier = house_feud_victim_ignored_opinion
		}
		stress_impact = {
			paranoid = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}
}

# Liege attempts to negotiate peace
bp1_house_feud.0420 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0420.t
	desc = bp1_house_feud.0420.desc
	theme = rival_relation
	left_portrait = {
		character = root
		animation = eyeroll
	}
	lower_left_portrait = scope:house_feud_liege
	lower_right_portrait = scope:house_feud_rival
	cooldown = { years = 10 }

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				any_relation_house = {
					NOT = { this = root.house }
					house_head = {
						exists = liege
						save_temporary_scope_as = rival_temp
					}
				}
			}
		}
		liege ?= {
			scope:rival_temp.liege ?= this
			is_available_ai_adult = yes
			NOR = {
				has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
				has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:rival_temp }
			}
		}
	}

	immediate = {
		liege = { save_scope_as = house_feud_liege }
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					any_relation_house = {
						NOT = { this = root.house }
						house_head = {
							exists = liege
							save_temporary_scope_as = rival_temp
						}
					}
				}
			}
		}
		scope:rival_temp = { save_scope_as = house_feud_rival }
	}

	option = {
		name = bp1_house_feud.0420.a
		reverse_add_opinion = {
			target = scope:house_feud_liege
			modifier = house_feud_liege_maintained_opinion
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0420.b
		reverse_add_opinion = {
			target = scope:house_feud_liege
			modifier = house_feud_liege_cancelled_opinion
		}
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}
}

#############################
#############################
####### TARGET EVENTS #######
#############################
#############################

# bp1_house_feud.0500 - decide to start feud with feuders ongoing
# bp1_house_feud.0501 - informed of feud starting against you
# bp1_house_feud.0502 - informed of feud against you ending

# deprecated

# Feud targets decide whether to reciprocate during
#bp1_house_feud.0500 = {
#	type = character_event
#	content_source = dlc_006
#	title = bp1_house_feud.0500.t
#	desc = bp1_house_feud.0500.desc
#	theme = rival_relation
#	left_portrait = {
#		character = root
#		animation = worry
#	}
#	lower_right_portrait = scope:house_feud_rival
#	cooldown = { years = 2 }
#
#	trigger = {
#		#DLC check
#		has_bp1_dlc_trigger = yes
#		#Standard checks
#		is_available_adult = yes
#		# Ensure feud exists
#		scope:house_feud_rival = {
#			house_has_feud_relation_with_trigger = { TARGET = root }
#		}
#		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_rival }
#	}
#
#	immediate = {		
#		set_variable = {
#			name = house_feud_reciprocate_cooldown
#			value = scope:house_feud_rival.house
#			years = 10
#		}
#	}
#
#	option = {
#		name = bp1_house_feud.0500.a
#		house_feud_start_effect = {
#			# Feuding House Head
#			ACTOR = root
#			# Target House Head
#			TARGET = scope:house_feud_rival
#			# Feud Reason
#			REASON = reciprocated_rivalry
#			# House Member attacker if relevant 
#			ATTACKER = scope:house_feud_rival
#			# House Member victim if relevant
#			VICTIM = root
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = 1
#				ai_boldness = 1
#			}
#		}
#	}
#
#	option = {
#		name = bp1_house_feud.0500.b
#		house_feud_vengeful_stress_effect = yes
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = -1
#				ai_boldness = -1
#			}
#		}
#	}
#}

# Feud target informed of feud at outset
#bp1_house_feud.0501 = {
#	type = character_event
#	content_source = dlc_006
#	title = bp1_house_feud.0501.t
#	desc = {
#		first_valid = {
#		    triggered_desc = {
#		       trigger = {
#					house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
#				}
#		        desc = bp1_house_feud.0501.reciprocating
#		    }
#		    desc = bp1_house_feud.0501.new
#		}
#		desc = bp1_house_feud.0501.desc
#	}
#	theme = rival_relation
#	override_background = { reference = sitting_room }
#	left_portrait = {
#		character = root
#		animation = eyeroll
#	}
#	lower_right_portrait = scope:story.story_owner
#	cooldown = { months = 6 }
#
#	trigger = {
#		#DLC check
#		has_bp1_dlc_trigger = yes
#		#Standard checks
#		is_available_adult = yes
#		is_playable_character = yes
#		NOR = {
#			# Only one Feud can be started per lifetime
#			has_character_flag = had_house_feud_story
#			exists = var:house_feud_reciprocate_cooldown
#		}
#		house_feud_house_any_end_modifier_trigger = no
#		valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_attacker }
#	}
#
#	immediate = {
#		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_attacker }
#		show_as_tooltip = {
#			if = {
#				limit = { has_relation_nemesis = scope:house_feud_attacker }
#				set_relation_nemesis = scope:house_feud_attacker #Show as tooltip does not require reason
#			}
#			else = { set_relation_rival = scope:house_feud_attacker } #Show as tooltip does not require reason
#			if = {
#				limit = {
#					scope:story.story_owner = { is_ai = yes }
#				}
#				reverse_add_opinion = {
#					target = scope:house_feud_attacker
#					modifier = house_feud_opinion
#				}
#			}
#		}
#		house_feud_existing_feud_effect = yes
#		set_variable = {
#			name = house_feud_reciprocate_cooldown
#			value = scope:house_feud_attacker.house
#			years = 5
#		}
#	}
#
#	option = { # Reciprocate
#		name = bp1_house_feud.0501.a
#		trigger = {
#			NOT = { exists = scope:house_feud_existing }
#		}
#	    house_feud_start_effect = {
#            # Feuding House Head
#            ACTOR = root
#            # Target House Head
#            TARGET = scope:house_feud_attacker
#            # Feud Reason
#            REASON = reciprocated_rivalry
#            # House Member attacker if relevant 
#            ATTACKER = scope:house_feud_attacker
#            # House Member victim if relevant
#            VICTIM = root
#        }
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = 1
#				ai_boldness = 1
#			}
#		}
#	}
#
#	option = { # Swap feud
#		name = bp1_house_feud.0501.b
#		trigger = {
#			exists = scope:house_feud_existing
#			NOT = { exists = var:house_feud_swapped_house }
#		}
#		house_feud_swap_feud_effect = {
#			# Feuding House Head
#			ACTOR = root
#			# Target House Head
#			TARGET = scope:house_feud_attacker
#			# Feud Reason
#			REASON = reciprocated_rivalry
#			# House Member attacker if relevant
#			ATTACKER = scope:house_feud_attacker
#			 # House Member victim if relevant
#			VICTIM = root
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = 0.5
#				ai_rationality = -1
#			}
#		}
#	}
#
#	option = { # Who cares
#		name = {
#			text = bp1_house_feud.0501.c.busy
#			trigger = { exists = scope:house_feud_existing }
#		}
#		name = {
#			text = bp1_house_feud.0501.c.existing
#			trigger = {
#				house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
#			}
#		}
#		name = {
#			text = bp1_house_feud.0501.c
#			trigger = {
#				NOR = {
#					exists = scope:house_feud_existing
#					house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
#				}
#			}
#		}
#		house_feud_vengeful_stress_effect = yes
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = -1
#				ai_boldness = -1
#			}
#		}
#	}
#}

# Feud target informed of feud end
#bp1_house_feud.0502 = {
#	type = character_event
#	content_source = dlc_006
#	title = bp1_house_feud.0502.t
#	desc = {
#		desc = bp1_house_feud.0502.desc
#		first_valid = {
#		    triggered_desc = {
#		        trigger = { exists = scope:house_feud_new }
#		        desc = bp1_house_feud.0502.another
#		    }
#		    desc = bp1_house_feud.0502.peace
#		}
#	}
#	theme = rival_relation
#	left_portrait = {
#		character = root
#		animation = worry
#	}
#	lower_right_portrait = scope:house_feud_attacker
#
#	trigger = {
#		#DLC check
#		has_bp1_dlc_trigger = yes
#		#Standard checks
#		is_available_adult = yes
#		NAND = {
#			exists = house
#			house = { exists = var:house_feud_ended }
#		}
#	}
#
#	immediate = {		
#		house_feud_existing_feud_effect = yes
#		scope:house_feud_attacker = {
#			house.house_head = { save_scope_as = house_feud_rival }
#			if = {
#				limit = {
#					any_owned_story = {
#						story_type = story_cycle_house_feud
#						exists = var:house_feud_house
#					}
#				}
#				random_owned_story = {
#					limit = {
#						story_type = story_cycle_house_feud
#						exists = var:house_feud_house
#					}
#					var:house_feud_house.house_head = { save_scope_as = house_feud_new }
#				}
#			}
#		}
#	}
#
#	option = { # Start feud
#		name = bp1_house_feud.0502.a
#		trigger = {
#			NOT = { exists = scope:house_feud_existing }
#			valid_for_feud_events_with_target_trigger = { TARGET = scope:house_feud_attacker }
#		}
#		house_feud_start_effect = {
#			# Feuding House Head
#			ACTOR = root
#			# Target House Head
#			TARGET = scope:house_feud_attacker
#			# Feud Reason
#			REASON = reciprocated_rivalry
#			# House Member attacker if relevant
#			ATTACKER = scope:house_feud_attacker
#			# House Member victim if relevant
#			VICTIM = root
#		}
#		stress_impact = {
#			forgiving = medium_stress_impact_gain
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = 1
#				ai_boldness = 1
#			}
#		}
#	}
#
#	option = { # End feud too
#		name = bp1_house_feud.0502.b
#		trigger = {
#			house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_attacker }
#		}
#		house_feud_end_story_effect = yes
#		# Stress for being Vengeful characters
#		house_feud_vengeful_stress_effect = yes
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = -0.5
#				ai_boldness = 0.5
#			}
#		}
#	}
#
#	option = { # Swap feud
#		name = bp1_house_feud.0502.c
#		trigger = {
#			exists = scope:house_feud_existing
#			NOT = { exists = var:house_feud_swapped_house }
#		}
#		house_feud_swap_feud_effect = {
#			# Feuding House Head
#			ACTOR = root
#			# Target House Head
#			TARGET = scope:house_feud_attacker
#			# Feud Reason
#			REASON = reciprocated_rivalry
#			# House Member attacker if relevant
#			ATTACKER = scope:house_feud_attacker
#			 # House Member victim if relevant
#			VICTIM = root
#		}
#		stress_impact = {
#			forgiving = minor_stress_impact_gain
#			vengeful = minor_stress_impact_gain
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = -0.5
#				ai_boldness = 0.5
#			}
#		}
#	}
#	
#	option = { # Ok
#		name = bp1_house_feud.0502.d
#		stress_impact = {
#			vengeful = medium_stress_impact_gain
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = -1
#				ai_boldness = -1
#			}
#		}
#	}
#}

#############################
#############################
#### NOTIFICATION EVENTS ####
#############################
#############################

# bp1_house_feud.0600 - house members decide to adopt feud too

# deprecated

# House Member decides whether to adopt feud
#bp1_house_feud.0600 = {
#	type = character_event
#	content_source = dlc_006
#	title = bp1_house_feud.0600.t
#	desc = bp1_house_feud.0600.desc
#	theme = rival_relation
#	override_background = { reference = relaxing_room }
#	left_portrait = {
#		character = root
#		animation = worry
#	}
#	lower_left_portrait = scope:house_head_scope
#	lower_right_portrait = scope:house_feud_rival
#	cooldown = { years = 10 }
#
#	trigger = {
#		#DLC check
#		has_bp1_dlc_trigger = yes
#		#Standard checks
#		is_available_adult = yes
#		#
#		is_adult = yes
#		in_diplomatic_range = scope:house_feud_rival
#		NOR = {
#			this = this.house.house_head
#			has_opinion_modifier = {
#				target = scope:house_feud_rival
#				modifier = house_feud_opinion
#			}
#		}
#	}
#
#	immediate = {
#		house.house_head = { save_scope_as = house_head_scope }
#	}
#
#	option = {
#		name = bp1_house_feud.0600.a
#		trigger = {
#			NOT = { has_relation_rival = scope:house_feud_rival }
#		}
#		if = {
#			limit = {
#				is_ai = yes
#				scope:house_feud_rival = { is_alive = yes }
#			}
#			add_opinion = {
#				target = scope:house_feud_rival
#				modifier = house_feud_opinion
#			}
#		}
#		if = {
#			limit = {
#				scope:house_head_scope = {
#					is_ai = yes
#					is_alive = yes
#				}
#			}
#			reverse_add_opinion = {
#				target = scope:house_head_scope
#				modifier = house_feud_followed_opinion
#			}
#		}
#		stress_impact = {
#			forgiving = minor_stress_impact_gain
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = 0.5
#				ai_boldness = 0.5
#			}
#		}
#	}
#
#	option = {
#		name = bp1_house_feud.0600.b
#		trigger = { has_relation_rival = scope:house_feud_rival }
#		if = {
#			limit = {
#				is_ai = yes
#				scope:house_feud_rival = { is_alive = yes }
#			}
#			add_opinion = {
#				target = scope:house_feud_rival
#				modifier = house_feud_opinion
#			}
#		}
#		if = {
#			limit = {
#				scope:house_head_scope = {
#					is_ai = yes
#					is_alive = yes
#				}
#			}
#			reverse_add_opinion = {
#				target = scope:house_head_scope
#				modifier = house_feud_enthusiast_opinion
#			}
#		}
#		stress_impact = {
#			forgiving = medium_stress_impact_gain
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = 1
#				ai_boldness = 1
#			}
#		}
#	}
#
#	option = {
#		name = bp1_house_feud.0600.c
#		if = {
#			limit = {
#				scope:house_head_scope = {
#					is_ai = yes
#					is_alive = yes
#				}
#			}
#			reverse_add_opinion = {
#				target = scope:house_head_scope
#				modifier = house_feud_ignored_opinion
#			}
#		}
#		stress_impact = {
#			vengeful = medium_stress_impact_gain
#		}
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = -1
#				ai_boldness = -1
#			}
#		}
#	}
#}

#############################
#############################
####### SCHEME EVENTS #######
#############################
#############################

# bp1_house_feud.0700 - seduction hard rejection choice for feuders
# bp1_house_feud.0701 - seduction hard rejection ping for seducer

#Target: hard reject choice
#by Joe Parkin, based on seduce_outcome.8101 by Linnéa Thimrén
bp1_house_feud.0700 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0700.t
	desc = {
		desc = bp1_house_feud.0700.desc
		first_valid = {
			#It's love!
			triggered_desc = {
				trigger = { has_relation_potential_lover = scope:owner }
				desc = bp1_house_feud.0700.desc_positive
			}
			#I hate them / it's forbidden!
			triggered_desc = {
				trigger = {
					OR = {
						opinion = {
							target = scope:owner
							value < 0
						}
						has_relation_rival = scope:owner
					}
				}
				desc = bp1_house_feud.0700.desc_negative
			}
			#Neutral
			desc = bp1_house_feud.0700.desc_neutral
		}
	}
	
	theme = seduce_scheme
	left_portrait = scope:owner

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes  
		exists = scope:scheme
		scope:owner = { is_alive = yes }
	}

	immediate = {
		scope:owner = { save_scope_as = house_feud_rival }
		hidden_effect = {
			#For clearer and more controllable ai outcomes, we determine the outcome here:

			#HARD REJECT OR NOT?
			if = { #Guaranteed acceptance
				limit = { scope:owner = { has_perk = subtle_desire_perk } }
				save_scope_value_as = {
					name = house_feud_seduction_outcome
					value = flag:accept
				}
			}
			else = { #Randomization
				random = {
					chance = 50
					simple_attraction_modifier = {
						WHO = scope:target
						TARGET = scope:owner
						MAX_PERSONALITY = 150 # -150 at low trait combatibility, +150 at high trait combatibility.
						MAX_PHYSICAL = 150 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
					}
					save_scope_value_as = {
						name = house_feud_seduction_outcome
						value = flag:accept
					}					
				}	
				if = {
					limit = { NOT = { exists = scope:house_feud_seduction_outcome } }
					save_scope_value_as = {
						name = house_feud_seduction_outcome
						value = flag:reject
					}
				}
			}
		}
	}

	option = { #Ew, get out of here
		name = bp1_house_feud.0700.a
		trigger = {
			trigger_if = {
				limit = {
					scope:owner = { has_perk = graceful_recovery_perk }
			    }
			    is_ai = no
			}
		}
		reverse_add_opinion = {
			target = scope:owner
			modifier = refusal_opinion
			opinion = -20
		}
		seduction_block_character_effect = { CHARACTER = scope:owner }
		scope:owner = {
			trigger_event = bp1_house_feud.0701
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				exists = scope:incest_outcome
				scope:incest_outcome = flag:reject_no_reveal
			}
		}
	}

	option = { #This is more important than family!
		name = bp1_house_feud.0700.b
		custom_tooltip = seduce_outcome.8101.b.tt
		ai_chance = {
			base = 0
			modifier = {
				add = 100
				exists = scope:house_feud_seduction_outcome
				scope:house_feud_seduction_outcome = flag:accept
			}
		}
	}
}

#Seducer: hard reject ping
#by Joe Parkin, based on seduce_outcome.8103 by Linnéa Thimrén
bp1_house_feud.0701 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0701.t
	desc = bp1_house_feud.0701.desc
	
	theme = seduce_scheme
	left_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
	}

	option = {
		name = bp1_house_feud.0701.a
		custom_tooltip = seduce_outcome.blocked_from_seduction

		scope:target = { seduction_block_character_effect = { CHARACTER = scope:owner } }

		if = {
			limit = { exists = scope:scheme }
			scope:scheme = {
				end_scheme = yes
			}
		}
		
		reverse_add_opinion = {
			target = scope:target
			modifier = respect_opinion
			opinion = -25
		}
	}
}

##############################
##############################
####### REVENGE EVENTS #######
##############################
##############################

# bp1_house_feud.7000 - original claim achieved
# bp1_house_feud.7001 - original killer killed
# bp1_house_feud.7002 - original torturer tortured
# bp1_house_feud.7003 - original cuckolder cuckolded

# Original claim achieved
bp1_house_feud.7000 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.7000.t
	desc = bp1_house_feud.7000.desc
	theme = rival_relation
	left_portrait = {
		character = root
		animation = war_over_win
	}
	lower_left_portrait = {
		character = scope:previous_holder
		trigger = {
			scope:previous_holder != scope:house_feud_rival
		}
	}
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
	}

	immediate = {
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
		scope:relation.var:house_feud_title ?= {
			save_scope_as = house_feud_title
			set_variable = { name = feud_avenged }
		}
		house = {
			change_house_relation_feud_score_effect = {
				TARGET = scope:house_feud_rival.house
				REASON = avenged
				VALUE = house_feud_major_counter_value
			}
		}
		dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
		create_character_memory = {
			type = feud_vengeance_title
			participants = {
				previous_holder = scope:previous_holder
			}
		}
		random_memory = {
			memory_type = feud_vengeance_title
			limit = {
				has_memory_participant  = scope:previous_holder
				NOT = { exists = var:feud_vengeance_title }
			}
			set_variable = {
				name = feud_vengeance_title
				value = scope:relation.var:house_feud_title
			}
		}
		stress_impact = { base = medium_stress_impact_loss }
	}

	option = {
		name = bp1_house_feud.7000.a
		house_feud_forgiving_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.7000.b
		house = {
			change_house_relation_effect = {
				HOUSE = scope:previous_holder.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}
}

# Original killer killed
bp1_house_feud.7001 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.7001.t
	desc = bp1_house_feud.7001.desc
	theme = rival_relation
	left_portrait = {
		character = root
		animation = war_over_win
	}
	lower_left_portrait = scope:house_feud_victim
	lower_right_portrait = scope:house_feud_attacker

	trigger = {
		house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
	}

	immediate = {
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
		scope:relation = {
			var:house_feud_victim ?= { save_scope_as = house_feud_victim }
			var:house_feud_attacker ?= { save_scope_as = house_feud_attacker }
			set_variable = { name = feud_avenged }
		}
		house = {
			change_house_relation_feud_score_effect = {
				TARGET = scope:house_feud_rival.house
				REASON = avenged
				VALUE = house_feud_major_counter_value
			}
		}
		dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
		create_character_memory = {
			type = feud_vengeance_killer
			participants = {
				dead_relation = scope:house_feud_victim
				relation_killer = scope:house_feud_attacker
				relation_avenger = scope:house_feud_attacker.killer
			}
		}
		stress_impact = { base = medium_stress_impact_loss }
	}

	option = {
		name = bp1_house_feud.7001.a
		house_feud_forgiving_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.7001.b
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_attacker.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}
}

# Original torturer tortured
bp1_house_feud.7002 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.7002.t
	desc = {
		first_valid = {
		    triggered_desc = {
		        trigger = { root = scope:house_feud_victim }
		        desc = bp1_house_feud.7002.opening_self
		    }
		    desc = bp1_house_feud.7002.opening
		}
		desc = bp1_house_feud.7002.desc
	}
	theme = rival_relation
	override_background = { reference = corridor_night }
	left_portrait = {
		character = root
		animation = war_over_win
	}
	lower_left_portrait = {
		character = scope:house_feud_victim
		trigger = {
			root != scope:house_feud_victim
		}
	}
	lower_right_portrait = scope:house_feud_attacker

	trigger = {
		house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
	}

	immediate = {
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
		scope:relation = {
			var:house_feud_victim ?= { save_scope_as = house_feud_victim }
			var:house_feud_attacker ?= {
				save_scope_as = house_feud_attacker
				house_head = { save_scope_as = house_feud_rival }
			}
			set_variable = { name = feud_avenged }
		}
		house = {
			change_house_relation_feud_score_effect = {
				TARGET = scope:house_feud_rival.house
				REASON = avenged
				VALUE = house_feud_major_counter_value
			}
		}
		dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
		create_character_memory = {
			type = feud_vengeance_torture
			participants = {
				relation_victim = scope:house_feud_victim
				relation_torturer = scope:house_feud_attacker
				relation_avenger = scope:actor
			}
		}
		stress_impact = { base = medium_stress_impact_loss }
	}

	option = {
		name = bp1_house_feud.7002.a
		house_feud_forgiving_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.7002.b
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_attacker.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}
}

# Original cuckolder cuckolded
bp1_house_feud.7003 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.7003.t
	desc = {
		first_valid = {
		    triggered_desc = {
		        trigger = { root = scope:house_feud_victim }
		        desc = bp1_house_feud.7003.opening_self
		    }
		    desc = bp1_house_feud.7003.opening
		}
		desc = bp1_house_feud.7003.desc
	}
	theme = rival_relation
	left_portrait = {
		character = root
		animation = war_over_win
	}
	lower_left_portrait = {
		character = scope:house_feud_victim
		trigger = {
			root != scope:house_feud_victim
		}
	}
	lower_right_portrait = scope:house_feud_attacker

	trigger = {
		house_has_feud_relation_with_trigger = { TARGET = scope:house_feud_rival }
	}

	immediate = {
		save_ongoing_house_relation_effect = { TARGET = scope:house_feud_rival }
		scope:relation = {
			var:house_feud_victim ?= { save_scope_as = house_feud_victim }
			var:house_feud_attacker ?= {
				save_scope_as = house_feud_attacker
				house_head = { save_scope_as = house_feud_rival }
			}
			var:house_feud_spouse ?= { save_scope_as = house_feud_spouse }
			set_variable = { name = feud_avenged }
		}
		house = {
			change_house_relation_feud_score_effect = {
				TARGET = scope:house_feud_rival.house
				REASON = avenged
				VALUE = house_feud_major_counter_value
			}
		}
		dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
		create_character_memory = {
			type = feud_vengeance_cuckold
			participants = {
				relation_cuckolded = scope:house_feud_victim
				relation_cuckolder = scope:house_feud_attacker
				relation_avenger = scope:sex_partner
			}
		}
		stress_impact = { base = medium_stress_impact_loss }
	}

	option = {
		name = bp1_house_feud.7003.a
		house_feud_forgiving_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.7003.b
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}
}

############################
############################
#### MAINTENANCE EVENTS ####
############################
############################

# bp1_house_feud.0810 - fued inherited by new house head
# bp1_house_feud.0830 - wiped out target house
# bp1_house_feud.0840 - make rivalry with target house head if not existing
# bp1_house_feud.9000 - save rivals on death and fire inheritance on action
# bp1_house_feud.9001 - 0009 setup
# bp1_house_feud.9002 - 0004 setup
# bp1_house_feud.9003 - 0009 fallback
# bp1_house_feud.9004 - 0810 fallback

# Feud inherited ping for new House Head
#bp1_house_feud.0810 = {
#	type = character_event
#	content_source = dlc_006
#	title = bp1_house_feud.0810.t
#	desc = {
#		first_valid = {
#		    triggered_desc = {
#		        trigger = { has_character_flag = house_feud_too_young_inheritor }
#		        desc = bp1_house_feud.0810.child
#		    }
#		    desc = bp1_house_feud.0810.adult
#		}
#		desc = bp1_house_feud.0810.desc
#	}
#	theme = rival_relation
#	override_background = { reference = courtyard }
#	left_portrait = {
#		character = root
#		animation = worry
#	}
#	lower_left_portrait = scope:old_house_head
#	lower_right_portrait = scope:house_feud_rival
#
#	trigger = {
#		age >= 9
#		#DLC check
#		has_bp1_dlc_trigger = yes
#		house ?= {
#			any_house_relation = {
#				has_house_relation_level = feud
#				any_relation_house = { scope:house_feud_rival.house ?= this }
#			}
#		}
#	}
#
#	immediate = {
#		house = {
#			random_house_relation = {
#				limit = {
#					has_house_relation_level = feud
#					any_relation_house = { scope:house_feud_rival.house ?= this }
#				}
#				save_scope_as = relation 
#			}
#		}
#	}
#
#	option = {
#		name = bp1_house_feud.0810.a
#		if = {
#			limit = {
#				NOT = { has_relation_nemesis = scope:house_feud_rival }
#				can_set_relation_nemesis_trigger = { CHARACTER = scope:house_feud_rival }
#			}
#			set_relation_nemesis = {
#				target = scope:house_feud_rival
#				reason = rival_house_feud_old_rivalry
#			}
#		}
#		else = {
#			set_relation_rival = {
#				target = scope:house_feud_rival
#				reason = rival_house_feud_old_rivalry
#			}
#		}
#		house_feud_forgiving_stress_effect = yes
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = 1
#				ai_boldness = 1
#			}
#		}
#	}
#
#	option = {
#		name = {
#			text = bp1_house_feud.0810.b.rival
#			trigger = { has_relation_rival = scope:house_feud_rival }
#		}
#		name = {
#			text = bp1_house_feud.0810.b
#			trigger = {
#				NOT = { has_relation_rival = scope:house_feud_rival }
#			}
#		}
#		change_house_relation_effect = {
#			HOUSE = scope:house_feud_rival.house
#			VALUE = house_relation_improve_major_value
#			REASON = de_escalation
#		}
#		# Stress for being Vengeful characters
#		house_feud_vengeful_stress_effect = yes
#		ai_chance = {
#			base = 25
#			ai_value_modifier = {
#				ai_vengefulness = -1
#				ai_boldness = -1
#			}
#		}
#	}
#
#	after = {
#		if = {
#			limit = { has_character_flag = house_feud_too_young_inheritor }
#			remove_character_flag = house_feud_too_young_inheritor
#		}
#	}
#}

# No enemy members left
bp1_house_feud.0830 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0830.t
	desc = {
		first_valid = {
		    triggered_desc = {
		        trigger = {
					OR = {
						faith = { trait_is_sin = drunkard }
						is_adult = no
					}
		        }
		        desc = bp1_house_feud.0830.opening
		    }
		    desc = bp1_house_feud.0830.opening_drink
		}
		desc = bp1_house_feud.0830.desc
		first_valid = {
		    triggered_desc = {
		        trigger = {
		        	scope:relation = { house_feud_balance_value <= -2 }
		        }
		        desc = bp1_house_feud.0830.losing
		    }
		    triggered_desc = {
		        trigger = {
		        	scope:relation = { house_feud_balance_value >= 2 }
		        }
		        desc = bp1_house_feud.0830.winning
		    }
		    desc = bp1_house_feud.0830.even
		}
		first_valid = {
		    triggered_desc = {
		        trigger = {
		        	NOT = { exists = scope:first_owner }
		        }
		        desc = bp1_house_feud.0830.first_owner
		    }
		    desc = bp1_house_feud.0830.fallback
		}
	}
	theme = rival_relation
	override_background = { reference = feast }
	left_portrait = {
		character = root
		animation = toast_goblet
		triggered_animation = {
			trigger = {
				faith = { trait_is_sin = drunkard }
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				NOT = {
					faith = { trait_is_sin = drunkard }
				}
			}
			animation = toast_goblet
		}
	}
	right_portrait = { character = scope:first_owner }
	lower_right_portrait = {
		trigger = { exists = scope:first_rival }
		character = scope:first_rival
	}
	cooldown = { years = 1 }

	trigger = {
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				exists = var:house_feud_house_1_first_head
				exists = var:house_feud_house_2_first_head
				exists = var:house_feud_house_1_score
				exists = var:house_feud_house_2_score
				any_relation_house = {
					NOR = {
						this = root.house
						any_house_member = { is_alive = yes }
					}
				}
			}
		}
	}

	immediate = {
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					exists = var:house_feud_house_1_first_head
					exists = var:house_feud_house_2_first_head
					exists = var:house_feud_house_1_score
					exists = var:house_feud_house_2_score
					any_relation_house = {
						NOR = {
							this = root.house
							any_house_member = { is_alive = yes }
						}
					}
				}
				save_scope_as = relation
				if = {
					limit = { var:house_feud_house_1_first_head.house = root.house }
					var:house_feud_house_2_first_head = { save_scope_as = first_rival }
					if = {
						limit = { var:house_feud_house_1_first_head != root }
						var:house_feud_house_1_first_head = { save_scope_as = first_owner }
					}
				}
				else = {
					var:house_feud_house_1_first_head = { save_scope_as = first_rival }
					if = {
						limit = { var:house_feud_house_2_first_head != root }
						var:house_feud_house_2_first_head = { save_scope_as = first_owner }
					}
				}
				#For fallback loc
				if = {
					limit = {
						NOT = { exists = var:house_feud_victim }
					}
					set_variable = { name = house_feud_victim value = scope:first_owner }
				}
			}
		}
		stress_impact = { base = medium_stress_impact_loss }
	}

	option = {
		name = bp1_house_feud.0830.a
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:first_owner.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
	}
}

# Not rival with feud house head
bp1_house_feud.0840 = {
	type = character_event
	content_source = dlc_006
	title = bp1_house_feud.0840.t
	desc = {
		desc = bp1_house_feud.0840.desc
	    triggered_desc = {
	        trigger = {
	        	scope:house_feud_rival = { is_adult = no }
	        }
	        desc = bp1_house_feud.0840.child
	    }
	    desc = bp1_house_feud.0840.closing
	}
	theme = rival_relation
	override_background = { reference = feast }
	left_portrait = {
		character = root
		animation = worry
	}
	lower_right_portrait = scope:house_feud_rival

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		house = {
			any_house_relation = {
				has_house_relation_level = feud
				any_relation_house = {
					NOT = { this = root.house }
					house_head ?= {
						NOT = { has_relation_rival = root }
						can_set_relation_rival_trigger = { CHARACTER = root }
					}
				}
			}
		}
	}

	immediate = {
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_level = feud
					any_relation_house = {
						NOT = { this = root.house }
						house_head ?= {
							NOT = { has_relation_rival = root }
							can_set_relation_rival_trigger = { CHARACTER = root }
						}
					}
				}
				save_scope_as = relation
				random_relation_house = {
					limit = {
						NOT = { this = root.house }
						house_head ?= {
							NOT = { has_relation_rival = root }
							can_set_relation_rival_trigger = { CHARACTER = root }
						}
					}
					save_scope_as = house_feud_house
					house_head = {
						save_scope_as = house_feud_rival
					}
				}
			}
		}
		scope:relation = { #For fallback loc
			if = {
				limit = {
					NOT = { exists = var:house_feud_victim }
				}
				set_variable = { name = house_feud_victim value = scope:house_feud_rival }
			}
		}
	}

	option = {
		name = bp1_house_feud.0840.a
		set_relation_rival = {
			target = scope:house_feud_rival
			reason = rival_house_feud_feud_lives_on
		}
		house_feud_forgiving_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_boldness = 1
			}
		}
	}

	option = {
		name = bp1_house_feud.0840.b
		house ?= {
			change_house_relation_effect = {
				HOUSE = scope:house_feud_rival.house
				VALUE = house_relation_improve_major_value
				REASON = de_escalation
				CHAR = root
				TARGET_CHAR = scope:dummy_gender
				TITLE = scope:dummy_gender
			}
		}
		# Stress for being Vengeful characters
		house_feud_vengeful_stress_effect = yes
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_boldness = -1
			}
		}
	}
}

# Save rivals to list on death for .9002, and trigger inheritance on action
bp1_house_feud.9000 = {
	type = character_event
	content_source = dlc_006
	hidden = yes

	trigger = {
		#DLC check
		has_bp1_dlc_trigger = yes
		age >= 9
		is_house_head = yes
		exists = player_heir
		NOT = {
			house = {
				any_house_relation = { has_house_relation_level = feud }
			}
		}
	}

	immediate = {
		save_scope_as = old_house_head	
		every_relation = {
			type = rival
			limit = {
				this = this.house.house_head
				house != root.house
			}
			add_to_list = old_house_head_rivals
			if = {
				limit = { has_relation_nemesis = root }
				set_variable = {
					name = dead_nemesis
					value = root
					months = 1
				}
			}
		}
		primary_heir = {
			trigger_event = {
				on_action = house_feud_inheritance_events
				days = { 5 15 }
			}
		}
	}
}

# Check if heir wants to consider retaliation in .0009
bp1_house_feud.9001 = {
	type = character_event
	content_source = dlc_006
	hidden = yes

	trigger = {
		has_bp1_dlc_trigger = yes
		NOR = {
			house = {
				any_house_relation = { has_house_relation_level = feud }
			}
			has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:old_house_head }
		}
		scope:old_house_head.killer ?= {
			trigger_if = {
				limit = {
					any_secret = {
						type = secret_murder
						secret_target = scope:old_house_head
					}
				}
				any_secret = {
					type = secret_murder
					secret_target = scope:old_house_head
					is_known_by = root
				}
			}
			save_temporary_scope_as = killer_temp
		}
		valid_for_feud_events_with_target_trigger = { TARGET = scope:killer_temp }
	}

	immediate = {
		scope:old_house_head = {
			save_scope_as = house_feud_victim
			killer = { house_feud_save_head_and_attacker_effect = yes }
		}
		if = {
			limit = { age < 9 }
			add_character_flag = house_feud_too_young_heir
		}
		else = {
			random = {
				chance = 50
				modifier = {
					add = 25
					has_trait = vengeful
				}
				modifier = {
					add = -25
					has_trait = forgiving
				}
				trigger_event = bp1_house_feud.0009
			}
		}
	}
}

# Check if heir can consider starting feud in .0004
bp1_house_feud.9002 = {
	type = character_event
	content_source = dlc_006
	hidden = yes

	trigger = {
		has_bp1_dlc_trigger = yes
		is_adult = yes
		is_house_head = yes
		NOR = {
			exists = scope:old_house_head.killer
			house = {
				any_house_relation = { has_house_relation_level = feud }
			}
		}
		any_in_list = {
			list = old_house_head_rivals
			this = this.house.house_head
			house != root.house
		}
	}

	immediate = {
		random = {
			chance = 50
			modifier = {
				add = 25
				has_trait = vengeful
			}
			modifier = {
				add = 10
				culture = { has_cultural_parameter = house_hostility_more_common }
			}
			modifier = {
				add = -25
				has_trait = forgiving
			}
			modifier = {
				add = 50
				any_in_list = {
					list = old_house_head_rivals
					exists = var:dead_nemesis
					var:dead_nemesis = root
				}
			}
			modifier = {
				add = 25
				any_in_list = {
					list = old_house_head_rivals
					this = this.house.house_head
					house != root.house
					has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
				}
			}
			trigger_event = bp1_house_feud.0004
		}
	}
}

# 10th birthday event to fire .0009
#bp1_house_feud.9003 = {
#	type = character_event
#	content_source = dlc_006
#	hidden = yes
#
#	trigger = {
#		has_bp1_dlc_trigger = yes
#		has_character_flag = house_feud_too_young_heir
#		is_house_head = yes
#		house = {
#			any_house_relation = { has_house_relation_level = feud }
#		}
#	}
#
#	immediate = { trigger_event = bp1_house_feud.0009 }
#}

# 10th birthday event to fire .0810
#bp1_house_feud.9004 = {
#	type = character_event
#	content_source = dlc_006
#	hidden = yes
#
#	trigger = {
#		has_bp1_dlc_trigger = yes
#		#has_character_flag = house_feud_too_young_inheritor
#		is_house_head = yes
#		house = {
#			any_house_relation = { has_house_relation_level = feud }
#		}
#	}
#
#	immediate = {
#		house = {
#			random_house_relation = {
#				limit = { has_house_relation_level = feud }
#				random_relation_house = {
#					limit = {
#						NOT = { this = root.house }
#					}
#					house_head = { save_scope_as = house_feud_rival }
#				}
#			}
#		}
#		trigger_event = bp1_house_feud.0810
#	}
#}

# AI scheme events

# AI murder scheme joiner
bp1_house_feud.9500 = {
	type = character_event
	hidden = yes

	trigger = {
		house_feud_ai_murder_join_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = { add = ai_vengefulness }
		modifier = { add = ai_boldness }
		modifier = { add = ai_energy }
	}

	immediate = {
		save_scope_as = joiner
		house = {
			random_house_member = {
				limit = {
					any_scheme = {
						type = murder
						scheme_target_character.house ?= {
							any_house_relation = {
								has_house_relation_parameter = members_more_likely_to_scheme_hostile
								any_relation_house = { this = scope:joiner.house }
								save_temporary_scope_as = relation_temp
							}
						}
						NOR = {
							scheme_owner = scope:joiner
							any_scheme_agent_character = { this = scope:joiner }
						}
						save_temporary_scope_as = murder_scheme_temp #Unop: Move this up here since it will be used just after
						scope:joiner = {
							NOR = {
								is_scheming_against = { target = scope:murder_scheme_temp.scheme_target_character }
								has_any_good_relationship_with_character_trigger = { CHARACTER = scope:murder_scheme_temp.scheme_target_character }
							}
							char_can_fit_into_scheme_trigger = { SCHEME = scope:murder_scheme_temp }
						}
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:joiner }

					}
				}
			}
		}
		if = {
			limit = { exists = scope:murder_scheme_temp }
			force_assign_character_to_random_agent_slot_effect = {
				SCHEME = scope:murder_scheme_temp
				CHAR = scope:joiner
				YEARS = 5
			}
		}
		scope:relation_temp = {
			set_variable = {
				name = recent_ai_feud_scheme 
				years = 5
			}
		}
	}
}

# AI murder scheme starter
bp1_house_feud.9501 = {
	type = character_event
	hidden = yes

	trigger = {
		house_feud_ai_murder_start_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = { add = ai_vengefulness }
		modifier = { add = ai_boldness }
		modifier = { add = ai_energy }
	}

	immediate = {
		save_scope_as = starter
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_parameter = members_more_likely_to_scheme_hostile
					any_relation_house = {
						NOT = { this = scope:starter.house }
						any_house_member = { save_temporary_scope_as = target_temp }
						save_temporary_scope_as = relation_temp
					}
					scope:starter = {
						NOR = {
							is_scheming_against = { target = scope:target_temp }
							has_any_good_relationship_with_character_trigger = { CHARACTER = scope:target_temp }
						}
						can_start_scheme = {
							type = murder
							target_character = scope:target_temp
						}
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						scope:starter = {
							has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:target_temp }
						}
					}
				}
			}
		}
		if = {
			limit = { exists = scope:target_temp }
			start_scheme = {
				type = murder
				target_character = scope:target_temp
			}
		}
		scope:relation_temp = {
			set_variable = {
				name = recent_ai_feud_scheme 
				years = 5
			}
		}
	}
}

# AI seduce scheme starter
bp1_house_feud.9502 = {
	type = character_event
	hidden = yes

	trigger = {
		house_feud_ai_seduce_start_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = { add = ai_vengefulness }
		modifier = { add = ai_sociability }
		modifier = { add = ai_energy }
	}

	immediate = {
		save_scope_as = seducer
		house = {
			random_house_relation = {
				limit = {
					has_house_relation_parameter = members_more_likely_to_scheme_hostile
					any_relation_house = {
						NOT = { this = scope:seducer.house }
						any_house_member = {
							is_married = yes
							save_temporary_scope_as = target_temp
							any_spouse = {
								trigger_if = {
									limit = { exists = house }
									NOR = {
										house = scope:seducer.house
										house = scope:target_temp.house
									}						
								}
								NOR = {
									has_any_good_relationship_with_character_trigger = { CHARACTER = scope:target_temp }
									has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:seducer }
								}
								save_temporary_scope_as = spouse_temp
								scope:seducer = {
									can_start_scheme = {
										type = seduce
										target_character = scope:spouse_temp
									}
								}
							}
						}
						save_temporary_scope_as = relation_temp
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						root = {
							has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:target_temp }
						}
					}
				}
			}
		}
		if = {
			limit = { exists = scope:spouse_temp }
			start_scheme = {
				type = seduce
				target_character = scope:spouse_temp
			}
		}
		scope:relation_temp ?= {
			set_variable = {
				name = recent_ai_feud_scheme 
				years = 5
			}
		}
	}
}
