﻿# EOTM Stewardship progression and death inheritance helpers.
#
# Mirrors the frozen Learning/Martial architecture. Base CK3 Stewardship only;
# Wanderer/DLC lifestyle support is intentionally separate.

eotm_count_stewardship_visible_perks = {
	set_variable = { name = eotm_stewardship_visible_perk_count value = 0 }
	if = { limit = { has_perk = golden_obligations_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = heregeld_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = detailed_ledgers_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = war_profiteer_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = fearful_troops_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = it_is_my_domain_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = golden_aplomb_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = at_any_cost_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = avaricious_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = tax_man_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = defensive_measures_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = organized_muster_rolls_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = cutting_corners_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = professional_workforce_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = centralization_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = popular_figurehead_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = divided_attention_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = architect_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = meritocracy_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = chains_of_loyalty_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = likable_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = positions_of_power_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = large_levies_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = soon_forgiven_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = toe_the_line_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = honored_to_serve_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = administrator_perk } change_variable = { name = eotm_stewardship_visible_perk_count add = 1 } }
}

eotm_count_parent_stewardship_visible_perks = {
	set_variable = { name = eotm_parent_stewardship_visible_perk_count value = 0 }
	if = { limit = { has_perk = golden_obligations_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = heregeld_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = detailed_ledgers_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = war_profiteer_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = fearful_troops_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = it_is_my_domain_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = golden_aplomb_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = at_any_cost_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = avaricious_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = tax_man_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = defensive_measures_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = organized_muster_rolls_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = cutting_corners_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = professional_workforce_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = centralization_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = popular_figurehead_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = divided_attention_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = architect_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = meritocracy_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = chains_of_loyalty_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = likable_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = positions_of_power_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = large_levies_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = soon_forgiven_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = toe_the_line_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = honored_to_serve_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
	if = { limit = { has_perk = administrator_perk } change_variable = { name = eotm_parent_stewardship_visible_perk_count add = 1 } }
}

eotm_count_stewardship_final_visible_perks = {
	set_variable = { name = eotm_stewardship_final_visible_perk_count value = 0 }
	if = { limit = { has_perk = avaricious_perk } change_variable = { name = eotm_stewardship_final_visible_perk_count add = 1 } }
	if = { limit = { has_perk = architect_perk } change_variable = { name = eotm_stewardship_final_visible_perk_count add = 1 } }
	if = { limit = { has_perk = administrator_perk } change_variable = { name = eotm_stewardship_final_visible_perk_count add = 1 } }
}

eotm_count_parent_stewardship_final_visible_perks = {
	set_variable = { name = eotm_parent_stewardship_final_visible_perk_count value = 0 }
	if = { limit = { has_perk = avaricious_perk } change_variable = { name = eotm_parent_stewardship_final_visible_perk_count add = 1 } }
	if = { limit = { has_perk = architect_perk } change_variable = { name = eotm_parent_stewardship_final_visible_perk_count add = 1 } }
	if = { limit = { has_perk = administrator_perk } change_variable = { name = eotm_parent_stewardship_final_visible_perk_count add = 1 } }
}

eotm_debug_log_stewardship_visible_perk_count = {
	if = {
		limit = { exists = var:eotm_stewardship_visible_perk_count }
		if = { limit = { var:eotm_stewardship_visible_perk_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_stewardship_parent_visible_count = {
	if = {
		limit = { exists = var:eotm_parent_stewardship_visible_perk_count }
		if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_visible_perk_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_stewardship_final_visible_perk_count = {
	if = {
		limit = { exists = var:eotm_stewardship_final_visible_perk_count }
		if = { limit = { var:eotm_stewardship_final_visible_perk_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_final_visible_perk_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_final_visible_perk_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_final_visible_perk_count ?= 3 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_stewardship_parent_final_visible_count = {
	if = {
		limit = { exists = var:eotm_parent_stewardship_final_visible_perk_count }
		if = { limit = { var:eotm_parent_stewardship_final_visible_perk_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_final_visible_perk_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_final_visible_perk_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_parent_stewardship_final_visible_perk_count ?= 3 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_count_current_stewardship_perks_for_clear = {
	set_variable = { name = eotm_debug_stewardship_perks_removed_count value = 0 }
	if = { limit = { has_perk = golden_obligations_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = heregeld_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = detailed_ledgers_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = war_profiteer_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = fearful_troops_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = it_is_my_domain_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = golden_aplomb_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = at_any_cost_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = avaricious_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = tax_man_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = defensive_measures_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = organized_muster_rolls_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = cutting_corners_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = professional_workforce_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = centralization_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = popular_figurehead_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = divided_attention_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = architect_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = meritocracy_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = chains_of_loyalty_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = likable_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = positions_of_power_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = large_levies_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = soon_forgiven_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = toe_the_line_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = honored_to_serve_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
	if = { limit = { has_perk = administrator_perk } change_variable = { name = eotm_debug_stewardship_perks_removed_count add = 1 } }
}

eotm_debug_count_current_stewardship_final_perks_for_clear = {
	set_variable = { name = eotm_debug_stewardship_final_perks_removed_count value = 0 }
	if = { limit = { has_perk = avaricious_perk } change_variable = { name = eotm_debug_stewardship_final_perks_removed_count add = 1 } }
	if = { limit = { has_perk = architect_perk } change_variable = { name = eotm_debug_stewardship_final_perks_removed_count add = 1 } }
	if = { limit = { has_perk = administrator_perk } change_variable = { name = eotm_debug_stewardship_final_perks_removed_count add = 1 } }
}

eotm_debug_log_clear_stewardship_perks_removed_count = {
	if = {
		limit = { exists = var:eotm_debug_stewardship_perks_removed_count }
		if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_perks_removed_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_clear_stewardship_final_perks_removed_count = {
	if = {
		limit = { exists = var:eotm_debug_stewardship_final_perks_removed_count }
		if = { limit = { var:eotm_debug_stewardship_final_perks_removed_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_final_perks_removed_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_final_perks_removed_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_final_perks_removed_count ?= 3 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_clear_remaining_stewardship_perk_count = {
	if = {
		limit = { exists = var:eotm_stewardship_visible_perk_count }
		if = { limit = { var:eotm_stewardship_visible_perk_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_visible_perk_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = { hidden_effect = { } }
}

eotm_debug_log_stewardship_granted_count = {
	if = {
		limit = { exists = var:eotm_stewardship_granted_count }
		if = { limit = { var:eotm_stewardship_granted_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_stewardship_inheritance_granted_count = {
	if = {
		limit = { exists = var:eotm_stewardship_granted_count }
		if = { limit = { var:eotm_stewardship_granted_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_granted_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_stewardship_target_count = {
	if = {
		limit = { exists = var:eotm_stewardship_target_count }
		if = { limit = { var:eotm_stewardship_target_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_stewardship_target_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_mark_stewardship_grant_success = {
	if = { limit = { NOT = { exists = var:eotm_stewardship_granted_count } } set_variable = { name = eotm_stewardship_granted_count value = 0 } }
	if = { limit = { NOT = { exists = var:eotm_stewardship_granted_this_attempt } } set_variable = { name = eotm_stewardship_granted_this_attempt value = 0 } }
	change_variable = { name = eotm_stewardship_granted_count add = 1 }
	set_variable = { name = eotm_stewardship_granted_this_attempt value = 1 }
}

eotm_grant_stewardship_wealth_final_unlock = {
	add_perk = avaricious_perk
	if = { limit = { NOT = { has_trait = avaricious } } add_trait = avaricious }
	eotm_mark_stewardship_grant_success = yes
	eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_avaricious_perk_tt }
	hidden_effect = { }
}

eotm_grant_stewardship_inheritance_wealth_final_unlock = {
	add_perk = avaricious_perk
	if = { limit = { NOT = { has_trait = avaricious } } add_trait = avaricious }
	eotm_mark_stewardship_grant_success = yes
	hidden_effect = { }
}

eotm_grant_stewardship_domain_final_unlock = {
	add_perk = architect_perk
	if = { limit = { NOT = { has_trait = architect } } add_trait = architect }
	eotm_mark_stewardship_grant_success = yes
	eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_architect_perk_tt }
	hidden_effect = { }
}

eotm_grant_stewardship_inheritance_domain_final_unlock = {
	add_perk = architect_perk
	if = { limit = { NOT = { has_trait = architect } } add_trait = architect }
	eotm_mark_stewardship_grant_success = yes
	hidden_effect = { }
}

eotm_grant_stewardship_duty_final_unlock = {
	add_perk = administrator_perk
	if = { limit = { NOT = { has_trait = administrator } } add_trait = administrator }
	eotm_mark_stewardship_grant_success = yes
	eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_administrator_perk_tt }
	hidden_effect = { }
}

eotm_grant_stewardship_inheritance_duty_final_unlock = {
	add_perk = administrator_perk
	if = { limit = { NOT = { has_trait = administrator } } add_trait = administrator }
	eotm_mark_stewardship_grant_success = yes
	hidden_effect = { }
}

eotm_grant_stewardship_golden_obligations_perk = { add_perk = golden_obligations_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_golden_obligations_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_heregeld_perk = { add_perk = heregeld_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_heregeld_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_detailed_ledgers_perk = { add_perk = detailed_ledgers_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_detailed_ledgers_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_war_profiteer_perk = { add_perk = war_profiteer_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_war_profiteer_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_fearful_troops_perk = { add_perk = fearful_troops_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_fearful_troops_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_it_is_my_domain_perk = { add_perk = it_is_my_domain_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_it_is_my_domain_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_golden_aplomb_perk = { add_perk = golden_aplomb_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_golden_aplomb_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_at_any_cost_perk = { add_perk = at_any_cost_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_at_any_cost_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_tax_man_perk = { add_perk = tax_man_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_tax_man_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_defensive_measures_perk = { add_perk = defensive_measures_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_defensive_measures_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_organized_muster_rolls_perk = { add_perk = organized_muster_rolls_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_organized_muster_rolls_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_cutting_corners_perk = { add_perk = cutting_corners_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_cutting_corners_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_professional_workforce_perk = { add_perk = professional_workforce_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_professional_workforce_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_centralization_perk = { add_perk = centralization_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_centralization_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_popular_figurehead_perk = { add_perk = popular_figurehead_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_popular_figurehead_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_divided_attention_perk = { add_perk = divided_attention_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_divided_attention_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_meritocracy_perk = { add_perk = meritocracy_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_meritocracy_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_chains_of_loyalty_perk = { add_perk = chains_of_loyalty_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_chains_of_loyalty_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_likable_perk = { add_perk = likable_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_likable_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_positions_of_power_perk = { add_perk = positions_of_power_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_positions_of_power_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_large_levies_perk = { add_perk = large_levies_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_large_levies_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_soon_forgiven_perk = { add_perk = soon_forgiven_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_soon_forgiven_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_toe_the_line_perk = { add_perk = toe_the_line_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_toe_the_line_perk_tt } hidden_effect = { } }
eotm_grant_stewardship_honored_to_serve_perk = { add_perk = honored_to_serve_perk eotm_mark_stewardship_grant_success = yes eotm_lifestyle_auto_spend_send_perk_toast = { TOAST = eotm_lifestyle_auto_spend_toast_honored_to_serve_perk_tt } hidden_effect = { } }

eotm_grant_stewardship_inheritance_golden_obligations_perk = { add_perk = golden_obligations_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_heregeld_perk = { add_perk = heregeld_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_detailed_ledgers_perk = { add_perk = detailed_ledgers_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_war_profiteer_perk = { add_perk = war_profiteer_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_fearful_troops_perk = { add_perk = fearful_troops_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_it_is_my_domain_perk = { add_perk = it_is_my_domain_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_golden_aplomb_perk = { add_perk = golden_aplomb_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_at_any_cost_perk = { add_perk = at_any_cost_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_tax_man_perk = { add_perk = tax_man_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_defensive_measures_perk = { add_perk = defensive_measures_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_organized_muster_rolls_perk = { add_perk = organized_muster_rolls_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_cutting_corners_perk = { add_perk = cutting_corners_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_professional_workforce_perk = { add_perk = professional_workforce_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_centralization_perk = { add_perk = centralization_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_popular_figurehead_perk = { add_perk = popular_figurehead_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_divided_attention_perk = { add_perk = divided_attention_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_meritocracy_perk = { add_perk = meritocracy_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_chains_of_loyalty_perk = { add_perk = chains_of_loyalty_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_likable_perk = { add_perk = likable_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_positions_of_power_perk = { add_perk = positions_of_power_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_large_levies_perk = { add_perk = large_levies_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_soon_forgiven_perk = { add_perk = soon_forgiven_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_toe_the_line_perk = { add_perk = toe_the_line_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }
eotm_grant_stewardship_inheritance_honored_to_serve_perk = { add_perk = honored_to_serve_perk eotm_mark_stewardship_grant_success = yes hidden_effect = { } }

eotm_debug_try_grant_stewardship_final_unlock = {
	if = {
		limit = { eotm_any_debug_stewardship_final_unlock_available = yes }
		random_list = {
			pick = 1
			unique = yes
			1 = { trigger = { eotm_can_debug_grant_stewardship_wealth_final_unlock = yes } eotm_grant_stewardship_wealth_final_unlock = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_domain_final_unlock = yes } eotm_grant_stewardship_domain_final_unlock = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_duty_final_unlock = yes } eotm_grant_stewardship_duty_final_unlock = yes }
		}
	}
}

eotm_try_grant_stewardship_final_unlock = {
	if = {
		limit = { eotm_any_stewardship_final_unlock_available = yes }
		random_list = {
			pick = 1
			unique = yes
			1 = { trigger = { eotm_can_inherit_stewardship_wealth_final_unlock = yes } eotm_grant_stewardship_inheritance_wealth_final_unlock = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_domain_final_unlock = yes } eotm_grant_stewardship_inheritance_domain_final_unlock = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_duty_final_unlock = yes } eotm_grant_stewardship_inheritance_duty_final_unlock = yes }
		}
	}
}

eotm_debug_grant_curious_stewardship_perk = {
	if = {
		limit = { eotm_has_any_valid_debug_stewardship_normal_perk = yes }
		random_list = {
			pick = 1
			unique = yes
			1 = { trigger = { eotm_can_debug_grant_stewardship_golden_obligations_perk = yes } eotm_grant_stewardship_golden_obligations_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_heregeld_perk = yes } eotm_grant_stewardship_heregeld_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_detailed_ledgers_perk = yes } eotm_grant_stewardship_detailed_ledgers_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_war_profiteer_perk = yes } eotm_grant_stewardship_war_profiteer_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_fearful_troops_perk = yes } eotm_grant_stewardship_fearful_troops_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_it_is_my_domain_perk = yes } eotm_grant_stewardship_it_is_my_domain_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_golden_aplomb_perk = yes } eotm_grant_stewardship_golden_aplomb_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_at_any_cost_perk = yes } eotm_grant_stewardship_at_any_cost_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_tax_man_perk = yes } eotm_grant_stewardship_tax_man_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_defensive_measures_perk = yes } eotm_grant_stewardship_defensive_measures_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_organized_muster_rolls_perk = yes } eotm_grant_stewardship_organized_muster_rolls_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_cutting_corners_perk = yes } eotm_grant_stewardship_cutting_corners_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_professional_workforce_perk = yes } eotm_grant_stewardship_professional_workforce_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_centralization_perk = yes } eotm_grant_stewardship_centralization_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_popular_figurehead_perk = yes } eotm_grant_stewardship_popular_figurehead_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_divided_attention_perk = yes } eotm_grant_stewardship_divided_attention_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_meritocracy_perk = yes } eotm_grant_stewardship_meritocracy_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_chains_of_loyalty_perk = yes } eotm_grant_stewardship_chains_of_loyalty_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_likable_perk = yes } eotm_grant_stewardship_likable_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_positions_of_power_perk = yes } eotm_grant_stewardship_positions_of_power_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_large_levies_perk = yes } eotm_grant_stewardship_large_levies_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_soon_forgiven_perk = yes } eotm_grant_stewardship_soon_forgiven_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_toe_the_line_perk = yes } eotm_grant_stewardship_toe_the_line_perk = yes }
			1 = { trigger = { eotm_can_debug_grant_stewardship_honored_to_serve_perk = yes } eotm_grant_stewardship_honored_to_serve_perk = yes }
		}
	}
}

eotm_grant_curious_stewardship_normal_perk = {
	if = {
		limit = { eotm_has_any_valid_stewardship_normal_inheritance_perk = yes }
		random_list = {
			pick = 1
			unique = yes
			1 = { trigger = { eotm_can_inherit_stewardship_golden_obligations_perk = yes } eotm_grant_stewardship_inheritance_golden_obligations_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_heregeld_perk = yes } eotm_grant_stewardship_inheritance_heregeld_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_detailed_ledgers_perk = yes } eotm_grant_stewardship_inheritance_detailed_ledgers_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_war_profiteer_perk = yes } eotm_grant_stewardship_inheritance_war_profiteer_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_fearful_troops_perk = yes } eotm_grant_stewardship_inheritance_fearful_troops_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_it_is_my_domain_perk = yes } eotm_grant_stewardship_inheritance_it_is_my_domain_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_golden_aplomb_perk = yes } eotm_grant_stewardship_inheritance_golden_aplomb_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_at_any_cost_perk = yes } eotm_grant_stewardship_inheritance_at_any_cost_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_tax_man_perk = yes } eotm_grant_stewardship_inheritance_tax_man_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_defensive_measures_perk = yes } eotm_grant_stewardship_inheritance_defensive_measures_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_organized_muster_rolls_perk = yes } eotm_grant_stewardship_inheritance_organized_muster_rolls_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_cutting_corners_perk = yes } eotm_grant_stewardship_inheritance_cutting_corners_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_professional_workforce_perk = yes } eotm_grant_stewardship_inheritance_professional_workforce_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_centralization_perk = yes } eotm_grant_stewardship_inheritance_centralization_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_popular_figurehead_perk = yes } eotm_grant_stewardship_inheritance_popular_figurehead_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_divided_attention_perk = yes } eotm_grant_stewardship_inheritance_divided_attention_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_meritocracy_perk = yes } eotm_grant_stewardship_inheritance_meritocracy_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_chains_of_loyalty_perk = yes } eotm_grant_stewardship_inheritance_chains_of_loyalty_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_likable_perk = yes } eotm_grant_stewardship_inheritance_likable_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_positions_of_power_perk = yes } eotm_grant_stewardship_inheritance_positions_of_power_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_large_levies_perk = yes } eotm_grant_stewardship_inheritance_large_levies_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_soon_forgiven_perk = yes } eotm_grant_stewardship_inheritance_soon_forgiven_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_toe_the_line_perk = yes } eotm_grant_stewardship_inheritance_toe_the_line_perk = yes }
			1 = { trigger = { eotm_can_inherit_stewardship_honored_to_serve_perk = yes } eotm_grant_stewardship_inheritance_honored_to_serve_perk = yes }
		}
	}
}

eotm_grant_stewardship_wealth_normal_perk_in_order = {
	if = { limit = { eotm_can_inherit_stewardship_golden_obligations_perk = yes } eotm_grant_stewardship_inheritance_golden_obligations_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_heregeld_perk = yes } eotm_grant_stewardship_inheritance_heregeld_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_detailed_ledgers_perk = yes } eotm_grant_stewardship_inheritance_detailed_ledgers_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_war_profiteer_perk = yes } eotm_grant_stewardship_inheritance_war_profiteer_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_fearful_troops_perk = yes } eotm_grant_stewardship_inheritance_fearful_troops_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_it_is_my_domain_perk = yes } eotm_grant_stewardship_inheritance_it_is_my_domain_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_golden_aplomb_perk = yes } eotm_grant_stewardship_inheritance_golden_aplomb_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_at_any_cost_perk = yes } eotm_grant_stewardship_inheritance_at_any_cost_perk = yes }
}

eotm_grant_stewardship_domain_normal_perk_in_order = {
	if = { limit = { eotm_can_inherit_stewardship_tax_man_perk = yes } eotm_grant_stewardship_inheritance_tax_man_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_defensive_measures_perk = yes } eotm_grant_stewardship_inheritance_defensive_measures_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_organized_muster_rolls_perk = yes } eotm_grant_stewardship_inheritance_organized_muster_rolls_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_cutting_corners_perk = yes } eotm_grant_stewardship_inheritance_cutting_corners_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_professional_workforce_perk = yes } eotm_grant_stewardship_inheritance_professional_workforce_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_centralization_perk = yes } eotm_grant_stewardship_inheritance_centralization_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_popular_figurehead_perk = yes } eotm_grant_stewardship_inheritance_popular_figurehead_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_divided_attention_perk = yes } eotm_grant_stewardship_inheritance_divided_attention_perk = yes }
}

eotm_grant_stewardship_duty_normal_perk_in_order = {
	if = { limit = { eotm_can_inherit_stewardship_meritocracy_perk = yes } eotm_grant_stewardship_inheritance_meritocracy_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_chains_of_loyalty_perk = yes } eotm_grant_stewardship_inheritance_chains_of_loyalty_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_likable_perk = yes } eotm_grant_stewardship_inheritance_likable_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_positions_of_power_perk = yes } eotm_grant_stewardship_inheritance_positions_of_power_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_large_levies_perk = yes } eotm_grant_stewardship_inheritance_large_levies_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_soon_forgiven_perk = yes } eotm_grant_stewardship_inheritance_soon_forgiven_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_toe_the_line_perk = yes } eotm_grant_stewardship_inheritance_toe_the_line_perk = yes }
	else_if = { limit = { eotm_can_inherit_stewardship_honored_to_serve_perk = yes } eotm_grant_stewardship_inheritance_honored_to_serve_perk = yes }
}

eotm_ensure_focused_stewardship_focus = {
	if = {
		limit = { NOT = { eotm_one_way_stewardship_focus_can_continue = yes } }
		remove_variable = eotm_one_way_stewardship_focus
		random_list = {
			pick = 1
			unique = yes
			1 = {
				trigger = { eotm_has_valid_stewardship_wealth_normal_inheritance_perk = yes }
				set_variable = { name = eotm_one_way_stewardship_focus value = 1 }
				hidden_effect = { }
			}
			1 = {
				trigger = { eotm_has_valid_stewardship_domain_normal_inheritance_perk = yes }
				set_variable = { name = eotm_one_way_stewardship_focus value = 2 }
				hidden_effect = { }
			}
			1 = {
				trigger = { eotm_has_valid_stewardship_duty_normal_inheritance_perk = yes }
				set_variable = { name = eotm_one_way_stewardship_focus value = 3 }
				hidden_effect = { }
			}
		}
	}
}

eotm_grant_focused_stewardship_normal_perk = {
	eotm_ensure_focused_stewardship_focus = yes
	if = {
		limit = { eotm_one_way_stewardship_focus_is_wealth = yes }
		eotm_grant_stewardship_wealth_normal_perk_in_order = yes
	}
	else_if = {
		limit = { eotm_one_way_stewardship_focus_is_domain = yes }
		eotm_grant_stewardship_domain_normal_perk_in_order = yes
	}
	else_if = {
		limit = { eotm_one_way_stewardship_focus_is_duty = yes }
		eotm_grant_stewardship_duty_normal_perk_in_order = yes
	}
}

eotm_count_child_stewardship_branch_normal_perks = {
	set_variable = { name = eotm_balanced_stewardship_wealth_count value = 0 }
	set_variable = { name = eotm_balanced_stewardship_domain_count value = 0 }
	set_variable = { name = eotm_balanced_stewardship_duty_count value = 0 }
	if = { limit = { has_perk = golden_obligations_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = heregeld_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = detailed_ledgers_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = war_profiteer_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = fearful_troops_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = it_is_my_domain_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = golden_aplomb_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = at_any_cost_perk } change_variable = { name = eotm_balanced_stewardship_wealth_count add = 1 } }
	if = { limit = { has_perk = tax_man_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = defensive_measures_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = organized_muster_rolls_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = cutting_corners_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = professional_workforce_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = centralization_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = popular_figurehead_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = divided_attention_perk } change_variable = { name = eotm_balanced_stewardship_domain_count add = 1 } }
	if = { limit = { has_perk = meritocracy_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
	if = { limit = { has_perk = chains_of_loyalty_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
	if = { limit = { has_perk = likable_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
	if = { limit = { has_perk = positions_of_power_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
	if = { limit = { has_perk = large_levies_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
	if = { limit = { has_perk = soon_forgiven_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
	if = { limit = { has_perk = toe_the_line_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
	if = { limit = { has_perk = honored_to_serve_perk } change_variable = { name = eotm_balanced_stewardship_duty_count add = 1 } }
}

eotm_grant_harmonious_stewardship_normal_perk = {
	eotm_count_child_stewardship_branch_normal_perks = yes
	random_list = {
		pick = 1
		unique = yes
		1 = {
			trigger = { eotm_balanced_stewardship_wealth_is_lowest_valid_branch = yes }
			eotm_grant_stewardship_wealth_normal_perk_in_order = yes
		}
		1 = {
			trigger = { eotm_balanced_stewardship_domain_is_lowest_valid_branch = yes }
			eotm_grant_stewardship_domain_normal_perk_in_order = yes
		}
		1 = {
			trigger = { eotm_balanced_stewardship_duty_is_lowest_valid_branch = yes }
			eotm_grant_stewardship_duty_normal_perk_in_order = yes
		}
	}
}

eotm_grant_profile_selected_stewardship_normal_perk = {
	if = {
		limit = { eotm_child_has_one_way_profile = yes }
		eotm_grant_focused_stewardship_normal_perk = yes
	}
	else_if = {
		limit = { eotm_child_has_balanced_profile = yes }
		eotm_grant_harmonious_stewardship_normal_perk = yes
	}
	else_if = {
		limit = { eotm_child_has_random_profile = yes }
		eotm_grant_curious_stewardship_normal_perk = yes
	}
	else = { hidden_effect = { } }
}

eotm_debug_count_standalone_stewardship_candidates = {
	set_variable = { name = eotm_debug_stewardship_candidate_count value = 0 }
	if = { limit = { eotm_can_debug_grant_stewardship_wealth_final_unlock = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_domain_final_unlock = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_duty_final_unlock = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_golden_obligations_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_heregeld_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_detailed_ledgers_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_war_profiteer_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_fearful_troops_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_it_is_my_domain_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_golden_aplomb_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_at_any_cost_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_tax_man_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_defensive_measures_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_organized_muster_rolls_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_cutting_corners_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_professional_workforce_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_centralization_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_popular_figurehead_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_divided_attention_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_meritocracy_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_chains_of_loyalty_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_likable_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_positions_of_power_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_large_levies_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_soon_forgiven_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_toe_the_line_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
	if = { limit = { eotm_can_debug_grant_stewardship_honored_to_serve_perk = yes } change_variable = { name = eotm_debug_stewardship_candidate_count add = 1 } }
}

eotm_debug_log_standalone_stewardship_candidate_count = {
	if = {
		limit = { exists = var:eotm_debug_stewardship_candidate_count }
		if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 0 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 1 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 2 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 3 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 4 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 5 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 6 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 7 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 8 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 9 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 10 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 11 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 12 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 13 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 14 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 15 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 16 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 17 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 18 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 19 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 20 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 21 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 22 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 23 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 24 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 25 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 26 } hidden_effect = { } }
		else_if = { limit = { var:eotm_debug_stewardship_candidate_count ?= 27 } hidden_effect = { } }
		else = { hidden_effect = { } }
	}
	else = {
		hidden_effect = { }
	}
}

eotm_debug_log_standalone_stewardship_candidate_state = {
	if = { limit = { has_perk = avaricious_perk } hidden_effect = { } } else_if = { limit = { NOT = { eotm_child_has_stewardship_wealth_normal_branch_perks = yes } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = architect_perk } hidden_effect = { } } else_if = { limit = { NOT = { eotm_child_has_stewardship_domain_normal_branch_perks = yes } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = administrator_perk } hidden_effect = { } } else_if = { limit = { NOT = { eotm_child_has_stewardship_duty_normal_branch_perks = yes } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = golden_obligations_perk } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = heregeld_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = golden_obligations_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = detailed_ledgers_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = heregeld_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = war_profiteer_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = golden_obligations_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = fearful_troops_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = war_profiteer_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = it_is_my_domain_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = golden_obligations_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = golden_aplomb_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = it_is_my_domain_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = at_any_cost_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = detailed_ledgers_perk } } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = fearful_troops_perk } } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = golden_aplomb_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = tax_man_perk } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = defensive_measures_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = tax_man_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = organized_muster_rolls_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = defensive_measures_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = cutting_corners_perk } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = professional_workforce_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = cutting_corners_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = centralization_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = professional_workforce_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = popular_figurehead_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = organized_muster_rolls_perk } } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = centralization_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = divided_attention_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = popular_figurehead_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = meritocracy_perk } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = chains_of_loyalty_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = meritocracy_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = likable_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = chains_of_loyalty_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = positions_of_power_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = likable_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = large_levies_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = meritocracy_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = soon_forgiven_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = large_levies_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = toe_the_line_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = soon_forgiven_perk } } hidden_effect = { } } else = { hidden_effect = { } }
	if = { limit = { has_perk = honored_to_serve_perk } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = toe_the_line_perk } } hidden_effect = { } } else_if = { limit = { NOT = { has_perk = positions_of_power_perk } } hidden_effect = { } } else = { hidden_effect = { } }
}

eotm_debug_test_stewardship_randomizer_x10_effect = {
	if = {
		limit = { is_ai = no }
		hidden_effect = { }
		hidden_effect = { }
		hidden_effect = { }
		set_variable = { name = eotm_stewardship_granted_count value = 0 }
		set_variable = { name = eotm_debug_stewardship_randomizer_attempt_count value = 0 }
		eotm_count_stewardship_visible_perks = yes
		hidden_effect = { }
		eotm_debug_log_stewardship_visible_perk_count = yes
		remove_variable = eotm_stewardship_visible_perk_count
		eotm_count_stewardship_final_visible_perks = yes
		hidden_effect = { }
		eotm_debug_log_stewardship_final_visible_perk_count = yes
		remove_variable = eotm_stewardship_final_visible_perk_count

		while = {
			limit = {
				exists = var:eotm_debug_stewardship_randomizer_attempt_count
				var:eotm_debug_stewardship_randomizer_attempt_count < 10
				eotm_any_debug_stewardship_candidate_available = yes
			}
			change_variable = { name = eotm_debug_stewardship_randomizer_attempt_count add = 1 }
			hidden_effect = { }
			eotm_debug_count_standalone_stewardship_candidates = yes
			eotm_debug_log_standalone_stewardship_candidate_count = yes
			eotm_debug_log_standalone_stewardship_candidate_state = yes
			remove_variable = eotm_debug_stewardship_candidate_count
			set_variable = { name = eotm_stewardship_granted_this_attempt value = 0 }
			eotm_debug_try_grant_stewardship_final_unlock = yes
			if = { limit = { var:eotm_stewardship_granted_this_attempt ?= 0 } eotm_debug_grant_curious_stewardship_perk = yes }
			if = { limit = { var:eotm_stewardship_granted_this_attempt ?= 0 } hidden_effect = { } set_variable = { name = eotm_debug_stewardship_randomizer_attempt_count value = 10 } }
		}

		if = { limit = { NOT = { eotm_any_debug_stewardship_candidate_available = yes } } hidden_effect = { } }
		eotm_debug_log_stewardship_granted_count = yes
		eotm_count_stewardship_visible_perks = yes
		hidden_effect = { }
		eotm_debug_log_stewardship_visible_perk_count = yes
		eotm_count_stewardship_final_visible_perks = yes
		hidden_effect = { }
		eotm_debug_log_stewardship_final_visible_perk_count = yes
		hidden_effect = { }
		remove_variable = eotm_stewardship_visible_perk_count
		remove_variable = eotm_stewardship_final_visible_perk_count
		remove_variable = eotm_stewardship_granted_count
		remove_variable = eotm_stewardship_granted_this_attempt
		remove_variable = eotm_debug_stewardship_randomizer_attempt_count
		remove_variable = eotm_debug_stewardship_candidate_count
	}
	else = { hidden_effect = { } }
}

eotm_calculate_child_stewardship_target_count = {
	eotm_set_child_age_inheritance_percentage = yes
	if = {
		limit = {
			exists = scope:eotm_deceased_parent
			exists = scope:eotm_deceased_parent.var:eotm_parent_stewardship_visible_perk_count
			exists = var:eotm_child_age_inheritance_percentage
		}
		set_variable = {
			name = eotm_stewardship_target_count
			value = {
				value = scope:eotm_deceased_parent.var:eotm_parent_stewardship_visible_perk_count
				multiply = var:eotm_child_age_inheritance_percentage
				divide = 10000
				floor = yes
			}
		}
	}
	else = {
		set_variable = { name = eotm_stewardship_target_count value = 0 }
		hidden_effect = { }
	}
}

eotm_debug_log_stewardship_child_age_years = {
	if = { limit = { age < 1 } hidden_effect = { } }
	else_if = { limit = { age < 2 } hidden_effect = { } }
	else_if = { limit = { age < 3 } hidden_effect = { } }
	else_if = { limit = { age < 4 } hidden_effect = { } }
	else_if = { limit = { age < 5 } hidden_effect = { } }
	else_if = { limit = { age < 6 } hidden_effect = { } }
	else_if = { limit = { age < 7 } hidden_effect = { } }
	else_if = { limit = { age < 8 } hidden_effect = { } }
	else_if = { limit = { age < 9 } hidden_effect = { } }
	else_if = { limit = { age < 10 } hidden_effect = { } }
	else_if = { limit = { age < 11 } hidden_effect = { } }
	else_if = { limit = { age < 12 } hidden_effect = { } }
	else_if = { limit = { age < 13 } hidden_effect = { } }
	else_if = { limit = { age < 14 } hidden_effect = { } }
	else_if = { limit = { age < 15 } hidden_effect = { } }
	else_if = { limit = { age < 16 } hidden_effect = { } }
	else_if = { limit = { age <= 20 } hidden_effect = { } }
	else_if = { limit = { age <= 30 } hidden_effect = { } }
	else_if = { limit = { age <= 40 } hidden_effect = { } }
	else_if = { limit = { age <= 50 } hidden_effect = { } }
	else_if = { limit = { age <= 60 } hidden_effect = { } }
	else = { hidden_effect = { } }
}

eotm_debug_log_stewardship_age_bracket_and_percentage = {
	eotm_debug_log_inheritance_strength_profile = yes
	if = {
		limit = { age <= 5 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else_if = {
		limit = { age <= 10 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else_if = {
		limit = { age <= 15 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else_if = {
		limit = { age <= 20 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else_if = {
		limit = { age <= 30 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else_if = {
		limit = { age <= 40 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else_if = {
		limit = { age <= 50 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else_if = {
		limit = { age <= 60 }
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
	else = {
		hidden_effect = { }
		eotm_debug_log_child_age_inheritance_percentage = yes
	}
}

eotm_cleanup_stewardship_inheritance_child_temp_variables = {
	remove_variable = eotm_child_age_inheritance_percentage
	remove_variable = eotm_stewardship_target_count
	remove_variable = eotm_stewardship_granted_count
	remove_variable = eotm_stewardship_granted_this_attempt
	remove_variable = eotm_stewardship_attempt_count
	remove_variable = eotm_stewardship_visible_perk_count
	remove_variable = eotm_balanced_stewardship_wealth_count
	remove_variable = eotm_balanced_stewardship_domain_count
	remove_variable = eotm_balanced_stewardship_duty_count
}

eotm_process_stewardship_inheritance_child = {
	hidden_effect = { }
	hidden_effect = { }
	hidden_effect = { }
	hidden_effect = { }
	eotm_debug_log_stewardship_child_age_years = yes
	eotm_backfill_inheritance_profile_if_missing = yes
	if = { limit = { eotm_child_has_one_way_profile = yes } hidden_effect = { } }
	else_if = { limit = { eotm_child_has_balanced_profile = yes } hidden_effect = { } }
	else_if = { limit = { eotm_child_has_random_profile = yes } hidden_effect = { } }
	if = {
		limit = { has_variable = eotm_pending_stewardship_activation_active has_variable = eotm_pending_stewardship_target_count }
		set_variable = { name = eotm_stewardship_target_count value = { value = var:eotm_pending_stewardship_target_count } }
		hidden_effect = { }
		eotm_debug_log_stewardship_target_count = yes
	}
	else = {
		eotm_calculate_child_stewardship_target_count = yes
		eotm_debug_log_stewardship_age_bracket_and_percentage = yes
		scope:eotm_deceased_parent = { eotm_debug_log_stewardship_parent_visible_count = yes }
		hidden_effect = { }
		eotm_debug_log_stewardship_target_count = yes
		eotm_apply_advanced_inheritance_resolver_insertion_points = yes
	}
	set_variable = { name = eotm_stewardship_granted_count value = 0 }
	set_variable = { name = eotm_stewardship_attempt_count value = 0 }
	if = {
		limit = { exists = var:eotm_stewardship_granted_count exists = var:eotm_stewardship_target_count exists = var:eotm_stewardship_attempt_count var:eotm_stewardship_target_count ?= 0 }
		hidden_effect = { }
	}
	else = {
		while = {
			limit = { exists = var:eotm_stewardship_granted_count exists = var:eotm_stewardship_target_count exists = var:eotm_stewardship_attempt_count var:eotm_stewardship_granted_count < var:eotm_stewardship_target_count var:eotm_stewardship_attempt_count < 60 eotm_any_stewardship_inheritance_candidate_available = yes }
			change_variable = { name = eotm_stewardship_attempt_count add = 1 }
			set_variable = { name = eotm_stewardship_granted_this_attempt value = 0 }
			eotm_try_grant_stewardship_final_unlock = yes
			if = { limit = { var:eotm_stewardship_granted_this_attempt ?= 0 } eotm_grant_profile_selected_stewardship_normal_perk = yes }
			if = { limit = { var:eotm_stewardship_granted_this_attempt ?= 0 } hidden_effect = { } hidden_effect = { } set_variable = { name = eotm_stewardship_attempt_count value = 60 } }
		}
		if = { limit = { exists = var:eotm_stewardship_granted_count exists = var:eotm_stewardship_target_count var:eotm_stewardship_granted_count < var:eotm_stewardship_target_count NOT = { eotm_any_stewardship_inheritance_candidate_available = yes } } hidden_effect = { } hidden_effect = { } }
		if = { limit = { exists = var:eotm_stewardship_granted_count exists = var:eotm_stewardship_target_count exists = var:eotm_stewardship_attempt_count var:eotm_stewardship_granted_count < var:eotm_stewardship_target_count var:eotm_stewardship_attempt_count >= 60 eotm_any_stewardship_inheritance_candidate_available = yes } hidden_effect = { } }
	}
	eotm_debug_log_stewardship_inheritance_granted_count = yes
	eotm_count_stewardship_visible_perks = yes
	hidden_effect = { }
	eotm_debug_log_stewardship_visible_perk_count = yes
	eotm_show_player_inheritance_report_window_effect = yes
	hidden_effect = { }
	eotm_cleanup_stewardship_inheritance_child_temp_variables = yes
}

eotm_execute_stewardship_death_inheritance = {
	if = {
		limit = { is_ruler = yes is_ai = no }
		hidden_effect = { }
		save_scope_as = eotm_deceased_parent
		eotm_count_parent_stewardship_visible_perks = yes
		eotm_count_parent_stewardship_final_visible_perks = yes
		eotm_debug_log_stewardship_parent_visible_count = yes
		eotm_debug_log_stewardship_parent_final_visible_count = yes
		every_child = {
			limit = { eotm_is_valid_stewardship_death_inheritance_child = yes }
			eotm_prepare_pending_stewardship_inheritance_child = yes
		}
		remove_variable = eotm_parent_stewardship_visible_perk_count
		remove_variable = eotm_parent_stewardship_final_visible_perk_count
		hidden_effect = { }
	}
}
