﻿###################
# AGOT Bookmarked #
###################

##################################
# War of the Five Kings Scenario #
##################################
agot_8299_1_17_wotfk_scenario_setup = {
	### RULER DESIGNER FIX ###

	title:h_the_iron_throne.holder = { save_scope_as = historical_setup }

	# Starks aganist Lannisters
	if = { # fire only if you used ruler designer; else there is no war
		limit = { NOT = { title:e_the_north.holder = character:Stark_6 } }

		title:e_the_north.holder = {
			start_war = {
				cb = agot_independence_war
				target = title:h_the_iron_throne.holder
			}
			every_character_war = {
				add_attacker = title:e_the_riverlands.holder
			}
		}
	}
	if = { # fire only if you used ruler designer; else there is no war
		limit = { NOT = { title:h_the_iron_throne.holder = character:Baratheon_5  } }

		title:h_the_iron_throne.holder = {
			add_character_flag = { flag = mw_init_event_blocker days = 2 }
			every_character_war = {
				add_defender = title:e_the_reach.holder
				add_defender = title:e_the_westerlands.holder
			}
		}
	}

	# Greyjoys aganist Lannisters
	if = { # fire only if you used ruler designer; else there is no war
		limit = { NOT = { title:e_the_iron_islands.holder = character:Greyjoy_5 } }

		title:e_the_iron_islands.holder = {
			start_war = {
				cb = agot_independence_war
				target = title:h_the_iron_throne.holder
			}
		}
	}
	if = { # fire only if you used ruler designer; else there is no war
		limit = { NOT = { title:h_the_iron_throne.holder = character:Baratheon_5  } }

		title:h_the_iron_throne.holder = {
			add_character_flag = { flag = mw_init_event_blocker days = 2 }
			every_character_war = {
				add_defender = title:e_the_reach.holder
				add_defender = title:e_the_westerlands.holder
			}
		}
	}
	###

	hidden_effect = { # Starks aganist Lannisters
		title:e_the_north.holder = {
			save_scope_as = mw_rebel_leader_robb
			agot_mw_scenario_rebel_setup = { # Set up story
				SOURCE = flag:mw_internal
				MODE = flag:mw_regular
				REALM_BREAK_UP = flag:yes
				REBEL_MAY_VASSALIZE = flag:no
				HELD_TITLE = title:e_the_north
				CASUS_BELLI = agot_independence_war
				PRE_WAR_LIEGE = title:h_the_iron_throne.holder
				MW_TARGET = title:h_the_iron_throne.holder
			}
			# ADD REBEL SUPPORTERS #
			# Add vassal rebels
			every_vassal_or_below = {
				limit = { primary_title.tier > tier_barony }

				scope:mw_rebel_story = {
					add_to_variable_list = {
						name = mw_rebel_supporter_list
						target = prev
					}
				}
			}
		}
		# Add independent rebels
		agot_mw_add_character_to_mw_list = {
			CHARACTER_SCOPE = title:e_the_riverlands.holder
			STORY_SCOPE = scope:mw_rebel_story
			LIST = mw_rebel_supporter_list
			PRE_WAR_LIEGE_SCOPE = title:h_the_iron_throne.holder
		}
		######
	}
	# hidden_effect = { # Greyjoys aganist Lannisters
		# title:e_the_iron_islands.holder = {
			# save_scope_as = mw_rebel_leader_balon
			# agot_mw_scenario_rebel_setup = { # Set up story
				# SOURCE = flag:mw_internal
				# MODE = flag:mw_regular
				# REALM_BREAK_UP = flag:yes
				# REBEL_MAY_VASSALIZE = flag:no
				# HELD_TITLE = title:e_the_iron_islands
				# CASUS_BELLI = agot_independence_war
				# PRE_WAR_LIEGE = title:h_the_iron_throne.holder
				# MW_TARGET = title:h_the_iron_throne.holder
			# }
			# # ADD REBEL SUPPORTERS #
			# # Add vassal rebels
			# every_vassal_or_below = {
				# limit = {
					# primary_title.tier > tier_barony
					# NOR = {
						# primary_title = title:k_the_most_devout
					# }
				# }

				# scope:mw_rebel_story = {
					# add_to_variable_list = {
						# name = mw_rebel_supporter_list
						# target = prev
					# }
				# }
			# }
		# }
		# # Add independent rebels
		# agot_mw_add_character_to_mw_list = {
			# CHARACTER_SCOPE = title:d_brightwater.holder
			# STORY_SCOPE = scope:mw_rebel_story
			# LIST = mw_rebel_supporter_list
			# PRE_WAR_LIEGE_SCOPE = title:e_the_reach.holder
		# }
		# agot_mw_add_character_to_mw_list = {
			# CHARACTER_SCOPE = title:d_blueburn.holder
			# STORY_SCOPE = scope:mw_rebel_story
			# LIST = mw_rebel_supporter_list
			# PRE_WAR_LIEGE_SCOPE = title:e_the_reach.holder
		# }
		# agot_mw_add_character_to_mw_list = {
			# CHARACTER_SCOPE = title:c_glasswater.holder
			# STORY_SCOPE = scope:mw_rebel_story
			# LIST = mw_rebel_supporter_list
			# PRE_WAR_LIEGE_SCOPE = title:d_masseys_hook.holder
		# }
		# ######
	# }

	### SET UP CROWN
	agot_mw_scenario_crown_setup = {
		MODE = flag:mw_regular
		REALM_BREAK_UP = flag:yes
		HELD_TITLE = title:h_the_iron_throne
	}
	# ADD LOYALISTS #
	# Add vassal loyalists
	title:h_the_iron_throne.holder = {
		every_vassal_or_below = {
			limit = {
				primary_title.tier > tier_barony
				NOT = {
					OR = {
						primary_title = title:k_the_most_devout
						primary_title = title:d_kingsguard
					}
				}
			}

			scope:mw_crown_story = {
				add_to_variable_list = {
					name = mw_loyalist_list
					target = prev
				}
			}
		}
	}
	######

	### ADD NEUTRALS ###
	agot_mw_add_character_to_mw_list = {
		CHARACTER_SCOPE = title:e_the_vale.holder
		STORY_SCOPE = scope:mw_crown_story
		LIST = mw_neutral_list
		PRE_WAR_LIEGE_SCOPE = title:h_the_iron_throne.holder
	}
	agot_mw_add_character_to_mw_list = {
		CHARACTER_SCOPE = title:e_dorne.holder
		STORY_SCOPE = scope:mw_crown_story
		LIST = mw_neutral_list
		PRE_WAR_LIEGE_SCOPE = title:h_the_iron_throne.holder
	}
	######

	### SET OPINIONS ###
	agot_mw_set_opinions_up = { REBEL_STORY_OWNER_SCOPE = scope:mw_rebel_leader_robb }
	# agot_mw_set_opinions_up = { REBEL_STORY_OWNER_SCOPE = scope:mw_rebel_leader_balon }
	######
}