﻿# Leo VI's Mass Vassal Directives - the panel's option lists
#
# GENERATED by tools/gen_panel.sh - edits here will be overwritten.
#
# Rebuilt at every game start rather than trusted from the save, so that
# installing or removing a DLC between sessions is picked up.

leo_mvd_build_options_effect = {
	# Which administration types this realm uses. Decided first: the
	# condition below and the preset's visibility both read it.
	leo_mvd_set_admin_family_effect = yes

	# Conditions offered by the settled waterfall, in panel order.
	clear_variable_list = leo_mvd_conds
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_1 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_2 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_3 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_4 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_5 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_19 }
	if = { limit = { OR = { has_dlc_feature = roads_to_power has_dlc_feature = all_under_heaven } } add_to_variable_list = { name = leo_mvd_conds target = flag:cond_6 } }
	if = { limit = { leo_mvd_admin_family_any_trigger = yes } add_to_variable_list = { name = leo_mvd_conds target = flag:cond_20 } }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_7 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_8 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_9 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_10 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_21 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_11 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_12 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_13 }
	add_to_variable_list = { name = leo_mvd_conds target = flag:cond_14 }

	# Conditions offered by the nomad waterfall.
	clear_variable_list = leo_mvd_qconds
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_1 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_2 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_3 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_4 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_5 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_19 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_7 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_8 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_9 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_10 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_21 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_11 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_12 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_13 }
	add_to_variable_list = { name = leo_mvd_qconds target = flag:cond_14 }

	# Directives, in panel order, gated in place like the conditions.
	clear_variable_list = leo_mvd_dirs
	add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_1 }
	add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_2 }
	if = { limit = { OR = { has_dlc_feature = roads_to_power has_dlc_feature = all_under_heaven } } add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_3 } }
	if = { limit = { OR = { has_dlc_feature = roads_to_power has_dlc_feature = all_under_heaven } } add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_4 } }
	if = { limit = { OR = { has_dlc_feature = roads_to_power has_dlc_feature = all_under_heaven } } add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_5 } }
	add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_6 }
	add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_7 }
	add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_8 }
	add_to_variable_list = { name = leo_mvd_dirs target = flag:dir_9 }
	clear_variable_list = leo_mvd_qdirs
	add_to_variable_list = { name = leo_mvd_qdirs target = flag:dir_10 }
	add_to_variable_list = { name = leo_mvd_qdirs target = flag:dir_11 }
	add_to_variable_list = { name = leo_mvd_qdirs target = flag:dir_12 }
	add_to_variable_list = { name = leo_mvd_qdirs target = flag:dir_13 }

	# One threshold ladder per measured condition.
	clear_variable_list = leo_mvd_t_9
	add_to_variable_list = { name = leo_mvd_t_9 target = flag:thresh_500 }
	add_to_variable_list = { name = leo_mvd_t_9 target = flag:thresh_1000 }
	add_to_variable_list = { name = leo_mvd_t_9 target = flag:thresh_2000 }
	add_to_variable_list = { name = leo_mvd_t_9 target = flag:thresh_5000 }
	clear_variable_list = leo_mvd_t_10
	add_to_variable_list = { name = leo_mvd_t_10 target = flag:thresh_2 }
	add_to_variable_list = { name = leo_mvd_t_10 target = flag:thresh_3 }
	add_to_variable_list = { name = leo_mvd_t_10 target = flag:thresh_4 }
	add_to_variable_list = { name = leo_mvd_t_10 target = flag:thresh_5 }
	clear_variable_list = leo_mvd_t_11
	add_to_variable_list = { name = leo_mvd_t_11 target = flag:thresh_10 }
	add_to_variable_list = { name = leo_mvd_t_11 target = flag:thresh_20 }
	add_to_variable_list = { name = leo_mvd_t_11 target = flag:thresh_40 }
	add_to_variable_list = { name = leo_mvd_t_11 target = flag:thresh_60 }
	add_to_variable_list = { name = leo_mvd_t_11 target = flag:thresh_80 }
	clear_variable_list = leo_mvd_t_12
	add_to_variable_list = { name = leo_mvd_t_12 target = flag:thresh_0 }
	add_to_variable_list = { name = leo_mvd_t_12 target = flag:thresh_25 }
	add_to_variable_list = { name = leo_mvd_t_12 target = flag:thresh_50 }
	add_to_variable_list = { name = leo_mvd_t_12 target = flag:thresh_75 }
	clear_variable_list = leo_mvd_t_13
	add_to_variable_list = { name = leo_mvd_t_13 target = flag:thresh_1 }
	add_to_variable_list = { name = leo_mvd_t_13 target = flag:thresh_2 }
	add_to_variable_list = { name = leo_mvd_t_13 target = flag:thresh_3 }
	add_to_variable_list = { name = leo_mvd_t_13 target = flag:thresh_5 }
	add_to_variable_list = { name = leo_mvd_t_13 target = flag:thresh_10 }
	clear_variable_list = leo_mvd_t_14
	add_to_variable_list = { name = leo_mvd_t_14 target = flag:thresh_10 }
	add_to_variable_list = { name = leo_mvd_t_14 target = flag:thresh_25 }
	add_to_variable_list = { name = leo_mvd_t_14 target = flag:thresh_50 }
	add_to_variable_list = { name = leo_mvd_t_14 target = flag:thresh_75 }
	add_to_variable_list = { name = leo_mvd_t_14 target = flag:thresh_90 }
	clear_variable_list = leo_mvd_t_20
	if = {
		limit = { leo_mvd_admin_family_rtp_trigger = yes }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_1 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_2 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_3 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_4 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_5 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_6 }
	}
	else_if = {
		limit = { leo_mvd_admin_family_celestial_trigger = yes }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_7 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_8 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_9 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_3 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_10 }
	}
	else_if = {
		limit = { leo_mvd_admin_family_meritocratic_trigger = yes }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_7 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_8 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_3 }
	}
	else_if = {
		limit = { leo_mvd_admin_family_ritsuryo_trigger = yes }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_7 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_8 }
		add_to_variable_list = { name = leo_mvd_t_20 target = flag:thresh_3 }
	}
	clear_variable_list = leo_mvd_t_21
	add_to_variable_list = { name = leo_mvd_t_21 target = flag:thresh_5 }
	add_to_variable_list = { name = leo_mvd_t_21 target = flag:thresh_10 }
	add_to_variable_list = { name = leo_mvd_t_21 target = flag:thresh_20 }
	add_to_variable_list = { name = leo_mvd_t_21 target = flag:thresh_40 }
	add_to_variable_list = { name = leo_mvd_t_21 target = flag:thresh_60 }

	# The code each option carries, keyed by its own flag, so a datamodel
	# row can read its identity as a number and compare it against a node
	# variable - which is a number too. GUI cannot compare the row's flag
	# string against a number directly, so this table stands in.
	#
	# Two gates use it. A child hides the yes/no question its parent already
	# settled (measured conditions carry -1 and never match, staying
	# selectable under themselves to carve a band). And each branch of a
	# condition hides whatever its sibling already picked, so the two can
	# never be made identical: same directive, same yes/no condition, or
	# same measured condition at the same threshold.
	set_variable = { name = leo_mvd_x_cond_1 value = 1 }
	set_variable = { name = leo_mvd_x_cond_2 value = 2 }
	set_variable = { name = leo_mvd_x_cond_3 value = 3 }
	set_variable = { name = leo_mvd_x_cond_4 value = 4 }
	set_variable = { name = leo_mvd_x_cond_5 value = 5 }
	set_variable = { name = leo_mvd_x_cond_19 value = 19 }
	set_variable = { name = leo_mvd_x_cond_6 value = 6 }
	set_variable = { name = leo_mvd_x_cond_20 value = -1 }
	set_variable = { name = leo_mvd_x_cond_7 value = 7 }
	set_variable = { name = leo_mvd_x_cond_8 value = 8 }
	set_variable = { name = leo_mvd_x_cond_9 value = -1 }
	set_variable = { name = leo_mvd_x_cond_10 value = -1 }
	set_variable = { name = leo_mvd_x_cond_21 value = -1 }
	set_variable = { name = leo_mvd_x_cond_11 value = -1 }
	set_variable = { name = leo_mvd_x_cond_12 value = -1 }
	set_variable = { name = leo_mvd_x_cond_13 value = -1 }
	set_variable = { name = leo_mvd_x_cond_14 value = -1 }
	set_variable = { name = leo_mvd_x_dir_1 value = 1 }
	set_variable = { name = leo_mvd_x_dir_2 value = 2 }
	set_variable = { name = leo_mvd_x_dir_3 value = 3 }
	set_variable = { name = leo_mvd_x_dir_4 value = 4 }
	set_variable = { name = leo_mvd_x_dir_5 value = 5 }
	set_variable = { name = leo_mvd_x_dir_6 value = 6 }
	set_variable = { name = leo_mvd_x_dir_7 value = 7 }
	set_variable = { name = leo_mvd_x_dir_8 value = 8 }
	set_variable = { name = leo_mvd_x_dir_9 value = 9 }
	set_variable = { name = leo_mvd_x_dir_10 value = 10 }
	set_variable = { name = leo_mvd_x_dir_11 value = 11 }
	set_variable = { name = leo_mvd_x_dir_12 value = 12 }
	set_variable = { name = leo_mvd_x_dir_13 value = 13 }
	set_variable = { name = leo_mvd_x_thresh_0 value = 0 }
	set_variable = { name = leo_mvd_x_thresh_1 value = 1 }
	set_variable = { name = leo_mvd_x_thresh_2 value = 2 }
	set_variable = { name = leo_mvd_x_thresh_3 value = 3 }
	set_variable = { name = leo_mvd_x_thresh_4 value = 4 }
	set_variable = { name = leo_mvd_x_thresh_5 value = 5 }
	set_variable = { name = leo_mvd_x_thresh_6 value = 6 }
	set_variable = { name = leo_mvd_x_thresh_7 value = 7 }
	set_variable = { name = leo_mvd_x_thresh_8 value = 8 }
	set_variable = { name = leo_mvd_x_thresh_9 value = 9 }
	set_variable = { name = leo_mvd_x_thresh_10 value = 10 }
	set_variable = { name = leo_mvd_x_thresh_20 value = 20 }
	set_variable = { name = leo_mvd_x_thresh_25 value = 25 }
	set_variable = { name = leo_mvd_x_thresh_40 value = 40 }
	set_variable = { name = leo_mvd_x_thresh_50 value = 50 }
	set_variable = { name = leo_mvd_x_thresh_60 value = 60 }
	set_variable = { name = leo_mvd_x_thresh_75 value = 75 }
	set_variable = { name = leo_mvd_x_thresh_80 value = 80 }
	set_variable = { name = leo_mvd_x_thresh_90 value = 90 }
	set_variable = { name = leo_mvd_x_thresh_500 value = 500 }
	set_variable = { name = leo_mvd_x_thresh_1000 value = 1000 }
	set_variable = { name = leo_mvd_x_thresh_2000 value = 2000 }
	set_variable = { name = leo_mvd_x_thresh_5000 value = 5000 }

	# Everything above is read only by the panel's datamodels, and the
	# script validator does not count GUI use - left unnamed in script it
	# reports every flag and variable as "set but never used". Naming
	# them once here is what keeps error.log clean. The branch never runs.
	if = {
		limit = { leo_mvd_options_ack_trigger = yes }
	}
}

# Current scope: the player. Rebuild the option lists, always.
#
# The lists live in the save, and only a new campaign rebuilds them on its
# own - on_game_start_after_lobby does not fire when a save is loaded. So a
# save carries whatever its lists held the day it was made, and every way
# they can go stale (a mod update that regates an option, a DLC installed
# between sessions) can leave the option count untouched. There is nothing
# cheap and reliable to compare against, so this does not try: it rebuilds.
#
# Affordable because nothing on a tick calls it. Every caller is a panel
# interaction - opening a dropdown, picking a preset, Apply Now - so the
# cost is a few dozen variable writes on a click.
leo_mvd_ensure_options_effect = {
	leo_mvd_build_options_effect = yes
}
