### DEPRECATED

#story_cycle_house_feud = {
#
#	on_setup = {
#		### Scopes
#		save_scope_as = house_feud_story
#	}
#
#	on_end = {
#		var:house_feud_house.house_head ?= { save_scope_as = house_feud_rival }
#		if = {
#			limit = {
#				NAND = {
#					exists = story_owner.var:house_feud_swapped_house
#					story_owner.var:house_feud_swapped_house = var:house_feud_house
#				}
#			}
#			house_feud_end_modifier_effect = yes
#		}
#		story_owner = {
#			save_scope_as = house_feud_ender
#			if = {
#				limit = { exists = scope:house_feud_rival }
#				create_character_memory = {
#					type = house_feud_ended_memory
#					participants = {
#						house_head = scope:house_feud_rival
#					}
#				}
#			}
#			house = {
#				set_variable = {
#					name = house_feud_cooldown
#					years = 25
#				}
#				set_variable = {
#					name = house_feud_ended
#					years = 1
#				}
#				hidden_effect = {
#					if = {
#						limit = {
#							any_house_member = { is_alive = yes }
#						}
#						every_house_member = {
#							limit = { is_alive = yes }
#							if = {
#								limit = {
#									exists = scope:house_feud_rival
#									scope:house_feud_rival = { is_alive = yes }
#									has_opinion_modifier = {
#										modifier = house_feud_opinion
#										target = scope:house_feud_rival
#									}
#								}
#								remove_opinion = {
#									modifier = house_feud_opinion
#									target = scope:house_feud_rival
#								}
#							}
#						}
#					}
#				}
#			}
#		}
#		# Inform target feud has ended
#		if = {
#			limit = {
#				exists = var:house_feud_house.house_head
#				var:house_feud_house.house_head = { is_alive = yes }
#			}
#			story_owner = { save_scope_as = house_feud_attacker }
#			var:house_feud_house.house_head = {
#				trigger_event = {
#					id = bp1_house_feud.0502
#					days = 5
#				}
#			}
#		}
#	}
#
#	on_owner_death = {
#		# Transfer to heir
#		if = {
#			limit = {
#				exists = scope:story.var:house_feud_house.house_head
#				story_owner = {
#					is_playable_character = yes
#					exists = player_heir
#				}
#			}
#			var:house_feud_house.house_head = { save_scope_as = house_feud_rival }
#			story_owner = {
#				save_scope_as = old_house_head
#				player_heir = { save_scope_as = new_story_owner }
#			}
#			#transfer_house_feud_story_cycle_to_effect = {
#			#	CHARACTER = scope:new_story_owner
#			#	STORY = scope:story
#			#}
#		}
#		# Or destroy
#		else = {
#			scope:story = { end_story = yes }
#		}
#	}
#
#	# Something happens - random events
#	effect_group = {
#		years = { 1 2 }
#		chance = 50
#
#		trigger = {
#			exists = var:house_feud_house.house_head
#			var:house_feud_house.house_head = { is_alive = yes }
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				var:house_feud_house.house_head = { save_scope_as = house_feud_rival }
#				story_owner = {
#					trigger_event = { on_action = ongoing_house_feud_events }
#				}
#			}
#		}
#	}
#
#	#Achieved claim
#	effect_group = {
#		days = 1
#
#		trigger = {
#			NOT = { has_variable = house_feud_revenged }
#			story_owner = { age >= 9 }
#			has_variable = house_feud_reason
#			var:house_feud_reason = flag:competing_claim
#			has_variable = house_feud_title
#			var:house_feud_title = {
#				exists = previous_holder.house
#				previous_holder.house = scope:story.var:house_feud_house_2_first_head.house
#				holder.house = scope:story.story_owner.house
#			}
#		}
#
#		
#	}
#
#	#Avenged death
#	effect_group = {
#		days = 1
#
#		trigger = {
#			NOT = { has_variable = house_feud_revenged }
#			story_owner = { age >= 9 }
#			has_variable = house_feud_reason
#			OR = {
#				var:house_feud_reason = flag:head_killed
#				var:house_feud_reason = flag:family_killed
#			}
#			has_variable = house_feud_attacker
#			var:house_feud_attacker = {
#				is_alive = no
#				exists = killer
#				killer.house = scope:story.story_owner.house
#			}
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				var:house_feud_house.house_head = { save_scope_as = house_feud_rival }
#				var:house_feud_attacker = { save_scope_as = house_feud_attacker }
#				var:house_feud_victim = { save_scope_as = house_feud_victim }
#				set_variable = {
#					name = house_feud_revenged
#					value = scope:house_feud_rival.house
#				}
#				story_owner = { trigger_event = bp1_house_feud.7001 }
#			}
#		}
#	}
#	
#	#Count length of the feud
#	effect_group = {
#		years = 1
#
#		trigger = { exists = var:house_feud_length_counter }
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				change_variable = {
#					name = house_feud_length_counter
#					add = 1
#				}
#			}
#		}
#	}
#
#	#Out of diplo range
#	effect_group = {
#		days = 1
#
#		trigger = {
#			story_owner = { save_temporary_scope_as = story_owner_temp }
#			var:house_feud_house.house_head ?= {
#				is_alive = yes
#				NOT = { in_diplomatic_range = scope:story_owner_temp }
#			}
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				var:house_feud_house.house_head = { save_scope_as = house_feud_rival }
#				end_story = yes
#			}
#		}
#	}
#
#	#Wiped out
#	effect_group = {
#		days = 1
#
#		trigger = {
#			story_owner.age >= 9
#			house_feud_wiped_out_trigger = yes
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				story_owner = { trigger_event = bp1_house_feud.0830 }
#			}
#		}
#	}
#
#	#Not rival with house head
#	effect_group = {
#		months = { 1 2 }
#
#		trigger = {
#			story_owner = {
#				age >= 9
#				trigger_if = {
#					limit = {  has_variable = house_feud_next_cooldown }
#					NOT = { var:house_feud_next_cooldown = scope:story.var:house_feud_house.house_head } 
#				}
#			}
#			exists = var:house_feud_house.house_head
#			exists = var:house_feud_house_2_first_head
#			var:house_feud_house = var:house_feud_house_2_first_head.house
#			var:house_feud_house.house_head = {
#				is_alive = yes
#				age >= 9
#				NOT = { has_relation_rival = scope:story.story_owner }
#			}
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				var:house_feud_house.house_head = { save_scope_as = house_feud_rival }
#				story_owner = { trigger_event = bp1_house_feud.0840 }
#			}
#		}
#	}
#
#	#Add opinion modifiers
#	effect_group = {
#		months = 6
#
#		trigger = {
#			var:house_feud_house.house_head ?= { save_temporary_scope_as = house_feud_head_temp } 
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				var:house_feud_house.house_head = { save_scope_as = house_feud_rival }
#				story_owner.house = {
#					every_house_member = { trigger_event = bp1_house_feud.0600 }
#				}
#			}
#		}
#	}
#
#	# Target house can decide to reciprocate
#	effect_group = {
#		months = 6
#		trigger = {
#			scope:story.var:house_feud_house.house_head ?= {
#				valid_for_feud_events_with_target_trigger = { TARGET = scope:story.story_owner }
#				trigger_if = {
#					limit = { has_variable = house_feud_reciprocate_cooldown }
#					NOT = { var:house_feud_reciprocate_cooldown = scope:story.story_owner.house }
#				}
#			}
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				story_owner = { save_scope_as = house_feud_rival }
#				scope:story = { save_scope_as = other_house_feud_story }
#				scope:story.var:house_feud_house.house_head = {
#					random = {
#						chance = 50
#						modifier = {
#							add = 25
#							intrigue > scope:house_feud_rival.intrigue
#						}
#						modifier = {
#							add = 25
#							has_relation_nemesis = scope:house_feud_rival
#						}
#						modifier = {
#							add = -25
#							has_trait = trusting
#						}
#						trigger_event = bp1_house_feud.0500
#					}
#				}
#			}
#		}
#	}
#
#	#Murder inform
#	effect_group = {
#		months = 1
#
#		trigger = {
#			story_owner.house = {
#				any_house_member = {
#					opinion = {
#						target = scope:story.story_owner
#						value >= -25
#					}
#					NOT = {
#						has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:story.story_owner }
#					}
#					any_secret = {
#						secret_type = secret_murder
#						secret_target = {
#							exists = house
#							house = scope:story.var:house_feud_house
#						}
#						NOT = {
#							any_secret_knower = { this = scope:story.story_owner }
#						}
#					}
#				}
#			}
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				story_owner.house = {
#					random_house_member = {
#						limit = {
#							opinion = {
#								target = scope:story.story_owner
#								value >= -25
#							}
#							NOT = {
#								has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:story.story_owner }
#							}
#						}
#						random_secret = {
#							limit = {
#								secret_type = secret_murder
#								secret_target = {
#									exists = house
#									house = scope:story.var:house_feud_house
#								}
#								NOT = {
#									any_secret_knower = { this = scope:story.story_owner }
#								}
#							}
#							reveal_to = scope:story.story_owner
#						}
#					}
#				}
#			}
#		}
#	}
#
#	# Cuckoldry inform
#	effect_group = {
#		months = 1
#
#		trigger = {
#			story_owner.house = {
#				any_house_member = {
#					opinion = {
#						target = scope:story.story_owner
#						value >= -25
#					}
#					NOT = {
#						has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:story.story_owner }
#					}
#					any_secret = {
#						secret_type = secret_lover
#						secret_target = {
#							exists = house
#							house = scope:story.var:house_feud_house
#						}
#						NOT = {
#							any_secret_knower = { this = scope:story.story_owner }
#						}
#					}
#				}
#			}
#		}
#
#		triggered_effect = {
#			trigger = { always = yes }
#			effect = {
#				story_owner.house = {
#					random_house_member = {
#						limit = {
#							opinion = {
#								target = scope:story.story_owner
#								value >= -25
#							}
#							NOT = {
#								has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:story.story_owner }
#							}
#						}
#						random_secret = {
#							limit = {
#								secret_type = secret_lover
#								secret_target = {
#									exists = house
#									house = scope:story.var:house_feud_house
#								}
#								NOT = {
#									any_secret_knower = { this = scope:story.story_owner }
#								}
#							}
#							reveal_to = scope:story.story_owner
#						}
#					}
#				}
#			}
#		}
#	}
#
#	# Stop AI feuds from going too hard against players
#	effect_group = {
#		months = 1
#		trigger = { always = yes }
#
#		triggered_effect = {
#			trigger = {
#				story_owner = { is_ai = yes }
#				var:house_feud_house.house.house_head ?= { is_ai = no }
#				# House must be sufficiently large to support a Feud
#				var:house_feud_house.house = {
#					any_house_member = {
#						count < 5
#						is_alive = yes
#						is_adult = yes
#					}
#				}
#			}
#			effect = {
#				story_owner = { save_scope_as = story_owner }
#				debug_log = "House Feud cancelled against player"
#				debug_log_scopes = yes
#				end_story = yes
#			}
#		}
#	}
#
#	# Maintenance group
#	effect_group = {
#		months = 1
#		trigger = { always = yes }
#
#		triggered_effect = {
#			trigger = {
#				OR = {
#					NOT = { exists = var:house_feud_house }
#					NOT = { exists = var:house_feud_house_1_first_head }
#					NOT = { exists = var:house_feud_house_2_first_head }
#					NOT = { exists = var:house_feud_length_counter }
#					NOT = { exists = var:house_feud_death_counter }
#					NOT = { exists = var:house_feud_kill_counter }
#					NOT = { exists = var:house_feud_reason }
#				}
#			}
#			effect = {
#				# Variable is missing! Ending story prematurely.
#				story_owner = { save_scope_as = story_owner }
#				debug_log = "House Feud invalidated"
#				debug_log_scopes = yes
#				end_story = yes
#			}
#		}
#	}
#}
