﻿# EOTM Stewardship inheritance/progression triggers.
#
# Base CK3 Stewardship lifestyle only. Wanderer/DLC lifestyle support is intentionally separate.

eotm_is_valid_stewardship_death_inheritance_child = {
	exists = scope:eotm_deceased_parent
	exists = scope:eotm_deceased_parent.dynasty
	exists = dynasty
	is_alive = yes
	NOT = { this = scope:eotm_deceased_parent }
	any_parent = { this = scope:eotm_deceased_parent }
	dynasty = scope:eotm_deceased_parent.dynasty
}

eotm_parent_has_stewardship_wealth_final_unlock = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = avaricious_perk }
		has_variable = eotm_pending_parent_had_stewardship_avaricious_perk
	}
}

eotm_child_has_stewardship_wealth_normal_branch_perks = {
	has_perk = golden_obligations_perk
	has_perk = heregeld_perk
	has_perk = detailed_ledgers_perk
	has_perk = war_profiteer_perk
	has_perk = fearful_troops_perk
	has_perk = it_is_my_domain_perk
	has_perk = golden_aplomb_perk
	has_perk = at_any_cost_perk
}

eotm_can_inherit_stewardship_wealth_final_unlock = {
	eotm_parent_has_stewardship_wealth_final_unlock = yes
	eotm_child_has_stewardship_wealth_normal_branch_perks = yes
	NOT = { has_perk = avaricious_perk }
}

eotm_parent_has_stewardship_domain_final_unlock = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = architect_perk }
		has_variable = eotm_pending_parent_had_stewardship_architect_perk
	}
}

eotm_child_has_stewardship_domain_normal_branch_perks = {
	has_perk = tax_man_perk
	has_perk = defensive_measures_perk
	has_perk = organized_muster_rolls_perk
	has_perk = cutting_corners_perk
	has_perk = professional_workforce_perk
	has_perk = centralization_perk
	has_perk = popular_figurehead_perk
	has_perk = divided_attention_perk
}

eotm_can_inherit_stewardship_domain_final_unlock = {
	eotm_parent_has_stewardship_domain_final_unlock = yes
	eotm_child_has_stewardship_domain_normal_branch_perks = yes
	NOT = { has_perk = architect_perk }
}

eotm_parent_has_stewardship_duty_final_unlock = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = administrator_perk }
		has_variable = eotm_pending_parent_had_stewardship_administrator_perk
	}
}

eotm_child_has_stewardship_duty_normal_branch_perks = {
	has_perk = meritocracy_perk
	has_perk = chains_of_loyalty_perk
	has_perk = likable_perk
	has_perk = positions_of_power_perk
	has_perk = large_levies_perk
	has_perk = soon_forgiven_perk
	has_perk = toe_the_line_perk
	has_perk = honored_to_serve_perk
}

eotm_can_inherit_stewardship_duty_final_unlock = {
	eotm_parent_has_stewardship_duty_final_unlock = yes
	eotm_child_has_stewardship_duty_normal_branch_perks = yes
	NOT = { has_perk = administrator_perk }
}

eotm_any_stewardship_final_unlock_available = {
	OR = {
		eotm_can_inherit_stewardship_wealth_final_unlock = yes
		eotm_can_inherit_stewardship_domain_final_unlock = yes
		eotm_can_inherit_stewardship_duty_final_unlock = yes
	}
}

eotm_can_inherit_stewardship_golden_obligations_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = golden_obligations_perk }
		has_variable = eotm_pending_parent_had_stewardship_golden_obligations_perk
	}
	NOT = { has_perk = golden_obligations_perk }
}

eotm_can_inherit_stewardship_heregeld_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = heregeld_perk }
		has_variable = eotm_pending_parent_had_stewardship_heregeld_perk
	}
	NOT = { has_perk = heregeld_perk }
	has_perk = golden_obligations_perk
}

eotm_can_inherit_stewardship_detailed_ledgers_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = detailed_ledgers_perk }
		has_variable = eotm_pending_parent_had_stewardship_detailed_ledgers_perk
	}
	NOT = { has_perk = detailed_ledgers_perk }
	has_perk = heregeld_perk
}

eotm_can_inherit_stewardship_war_profiteer_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = war_profiteer_perk }
		has_variable = eotm_pending_parent_had_stewardship_war_profiteer_perk
	}
	NOT = { has_perk = war_profiteer_perk }
	has_perk = golden_obligations_perk
}

eotm_can_inherit_stewardship_fearful_troops_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = fearful_troops_perk }
		has_variable = eotm_pending_parent_had_stewardship_fearful_troops_perk
	}
	NOT = { has_perk = fearful_troops_perk }
	has_perk = war_profiteer_perk
}

eotm_can_inherit_stewardship_it_is_my_domain_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = it_is_my_domain_perk }
		has_variable = eotm_pending_parent_had_stewardship_it_is_my_domain_perk
	}
	NOT = { has_perk = it_is_my_domain_perk }
	has_perk = golden_obligations_perk
}

eotm_can_inherit_stewardship_golden_aplomb_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = golden_aplomb_perk }
		has_variable = eotm_pending_parent_had_stewardship_golden_aplomb_perk
	}
	NOT = { has_perk = golden_aplomb_perk }
	has_perk = it_is_my_domain_perk
}

eotm_can_inherit_stewardship_at_any_cost_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = at_any_cost_perk }
		has_variable = eotm_pending_parent_had_stewardship_at_any_cost_perk
	}
	NOT = { has_perk = at_any_cost_perk }
	has_perk = detailed_ledgers_perk
	has_perk = fearful_troops_perk
	has_perk = golden_aplomb_perk
}

eotm_can_inherit_stewardship_tax_man_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = tax_man_perk }
		has_variable = eotm_pending_parent_had_stewardship_tax_man_perk
	}
	NOT = { has_perk = tax_man_perk }
}

eotm_can_inherit_stewardship_defensive_measures_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = defensive_measures_perk }
		has_variable = eotm_pending_parent_had_stewardship_defensive_measures_perk
	}
	NOT = { has_perk = defensive_measures_perk }
	has_perk = tax_man_perk
}

eotm_can_inherit_stewardship_organized_muster_rolls_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = organized_muster_rolls_perk }
		has_variable = eotm_pending_parent_had_stewardship_organized_muster_rolls_perk
	}
	NOT = { has_perk = organized_muster_rolls_perk }
	has_perk = defensive_measures_perk
}

eotm_can_inherit_stewardship_cutting_corners_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = cutting_corners_perk }
		has_variable = eotm_pending_parent_had_stewardship_cutting_corners_perk
	}
	NOT = { has_perk = cutting_corners_perk }
}

eotm_can_inherit_stewardship_professional_workforce_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = professional_workforce_perk }
		has_variable = eotm_pending_parent_had_stewardship_professional_workforce_perk
	}
	NOT = { has_perk = professional_workforce_perk }
	has_perk = cutting_corners_perk
}

eotm_can_inherit_stewardship_centralization_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = centralization_perk }
		has_variable = eotm_pending_parent_had_stewardship_centralization_perk
	}
	NOT = { has_perk = centralization_perk }
	has_perk = professional_workforce_perk
}

eotm_can_inherit_stewardship_popular_figurehead_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = popular_figurehead_perk }
		has_variable = eotm_pending_parent_had_stewardship_popular_figurehead_perk
	}
	NOT = { has_perk = popular_figurehead_perk }
	has_perk = organized_muster_rolls_perk
	has_perk = centralization_perk
}

eotm_can_inherit_stewardship_divided_attention_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = divided_attention_perk }
		has_variable = eotm_pending_parent_had_stewardship_divided_attention_perk
	}
	NOT = { has_perk = divided_attention_perk }
	has_perk = popular_figurehead_perk
}

eotm_can_inherit_stewardship_meritocracy_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = meritocracy_perk }
		has_variable = eotm_pending_parent_had_stewardship_meritocracy_perk
	}
	NOT = { has_perk = meritocracy_perk }
}

eotm_can_inherit_stewardship_chains_of_loyalty_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = chains_of_loyalty_perk }
		has_variable = eotm_pending_parent_had_stewardship_chains_of_loyalty_perk
	}
	NOT = { has_perk = chains_of_loyalty_perk }
	has_perk = meritocracy_perk
}

eotm_can_inherit_stewardship_likable_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = likable_perk }
		has_variable = eotm_pending_parent_had_stewardship_likable_perk
	}
	NOT = { has_perk = likable_perk }
	has_perk = chains_of_loyalty_perk
}

eotm_can_inherit_stewardship_positions_of_power_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = positions_of_power_perk }
		has_variable = eotm_pending_parent_had_stewardship_positions_of_power_perk
	}
	NOT = { has_perk = positions_of_power_perk }
	has_perk = likable_perk
}

eotm_can_inherit_stewardship_large_levies_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = large_levies_perk }
		has_variable = eotm_pending_parent_had_stewardship_large_levies_perk
	}
	NOT = { has_perk = large_levies_perk }
	has_perk = meritocracy_perk
}

eotm_can_inherit_stewardship_soon_forgiven_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = soon_forgiven_perk }
		has_variable = eotm_pending_parent_had_stewardship_soon_forgiven_perk
	}
	NOT = { has_perk = soon_forgiven_perk }
	has_perk = large_levies_perk
}

eotm_can_inherit_stewardship_toe_the_line_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = toe_the_line_perk }
		has_variable = eotm_pending_parent_had_stewardship_toe_the_line_perk
	}
	NOT = { has_perk = toe_the_line_perk }
	has_perk = soon_forgiven_perk
}

eotm_can_inherit_stewardship_honored_to_serve_perk = {
	OR = {
		scope:eotm_deceased_parent ?= { has_perk = honored_to_serve_perk }
		has_variable = eotm_pending_parent_had_stewardship_honored_to_serve_perk
	}
	NOT = { has_perk = honored_to_serve_perk }
	has_perk = toe_the_line_perk
	has_perk = positions_of_power_perk
}

eotm_has_valid_stewardship_wealth_normal_inheritance_perk = {
	OR = {
		eotm_can_inherit_stewardship_golden_obligations_perk = yes
		eotm_can_inherit_stewardship_heregeld_perk = yes
		eotm_can_inherit_stewardship_detailed_ledgers_perk = yes
		eotm_can_inherit_stewardship_war_profiteer_perk = yes
		eotm_can_inherit_stewardship_fearful_troops_perk = yes
		eotm_can_inherit_stewardship_it_is_my_domain_perk = yes
		eotm_can_inherit_stewardship_golden_aplomb_perk = yes
		eotm_can_inherit_stewardship_at_any_cost_perk = yes
	}
}

eotm_has_valid_stewardship_domain_normal_inheritance_perk = {
	OR = {
		eotm_can_inherit_stewardship_tax_man_perk = yes
		eotm_can_inherit_stewardship_defensive_measures_perk = yes
		eotm_can_inherit_stewardship_organized_muster_rolls_perk = yes
		eotm_can_inherit_stewardship_cutting_corners_perk = yes
		eotm_can_inherit_stewardship_professional_workforce_perk = yes
		eotm_can_inherit_stewardship_centralization_perk = yes
		eotm_can_inherit_stewardship_popular_figurehead_perk = yes
		eotm_can_inherit_stewardship_divided_attention_perk = yes
	}
}

eotm_has_valid_stewardship_duty_normal_inheritance_perk = {
	OR = {
		eotm_can_inherit_stewardship_meritocracy_perk = yes
		eotm_can_inherit_stewardship_chains_of_loyalty_perk = yes
		eotm_can_inherit_stewardship_likable_perk = yes
		eotm_can_inherit_stewardship_positions_of_power_perk = yes
		eotm_can_inherit_stewardship_large_levies_perk = yes
		eotm_can_inherit_stewardship_soon_forgiven_perk = yes
		eotm_can_inherit_stewardship_toe_the_line_perk = yes
		eotm_can_inherit_stewardship_honored_to_serve_perk = yes
	}
}

eotm_has_any_valid_stewardship_normal_inheritance_perk = {
	OR = {
		eotm_has_valid_stewardship_wealth_normal_inheritance_perk = yes
		eotm_has_valid_stewardship_domain_normal_inheritance_perk = yes
		eotm_has_valid_stewardship_duty_normal_inheritance_perk = yes
	}
}

eotm_any_stewardship_inheritance_candidate_available = {
	OR = {
		eotm_any_stewardship_final_unlock_available = yes
		eotm_has_any_valid_stewardship_normal_inheritance_perk = yes
	}
}

eotm_can_debug_grant_stewardship_wealth_final_unlock = {
	eotm_child_has_stewardship_wealth_normal_branch_perks = yes
	NOT = { has_perk = avaricious_perk }
}

eotm_can_debug_grant_stewardship_domain_final_unlock = {
	eotm_child_has_stewardship_domain_normal_branch_perks = yes
	NOT = { has_perk = architect_perk }
}

eotm_can_debug_grant_stewardship_duty_final_unlock = {
	eotm_child_has_stewardship_duty_normal_branch_perks = yes
	NOT = { has_perk = administrator_perk }
}

eotm_any_debug_stewardship_final_unlock_available = {
	OR = {
		eotm_can_debug_grant_stewardship_wealth_final_unlock = yes
		eotm_can_debug_grant_stewardship_domain_final_unlock = yes
		eotm_can_debug_grant_stewardship_duty_final_unlock = yes
	}
}

eotm_can_debug_grant_stewardship_golden_obligations_perk = {
	NOT = { has_perk = golden_obligations_perk }
}

eotm_can_debug_grant_stewardship_heregeld_perk = {
	NOT = { has_perk = heregeld_perk }
	has_perk = golden_obligations_perk
}

eotm_can_debug_grant_stewardship_detailed_ledgers_perk = {
	NOT = { has_perk = detailed_ledgers_perk }
	has_perk = heregeld_perk
}

eotm_can_debug_grant_stewardship_war_profiteer_perk = {
	NOT = { has_perk = war_profiteer_perk }
	has_perk = golden_obligations_perk
}

eotm_can_debug_grant_stewardship_fearful_troops_perk = {
	NOT = { has_perk = fearful_troops_perk }
	has_perk = war_profiteer_perk
}

eotm_can_debug_grant_stewardship_it_is_my_domain_perk = {
	NOT = { has_perk = it_is_my_domain_perk }
	has_perk = golden_obligations_perk
}

eotm_can_debug_grant_stewardship_golden_aplomb_perk = {
	NOT = { has_perk = golden_aplomb_perk }
	has_perk = it_is_my_domain_perk
}

eotm_can_debug_grant_stewardship_at_any_cost_perk = {
	NOT = { has_perk = at_any_cost_perk }
	has_perk = detailed_ledgers_perk
	has_perk = fearful_troops_perk
	has_perk = golden_aplomb_perk
}

eotm_can_debug_grant_stewardship_tax_man_perk = {
	NOT = { has_perk = tax_man_perk }
}

eotm_can_debug_grant_stewardship_defensive_measures_perk = {
	NOT = { has_perk = defensive_measures_perk }
	has_perk = tax_man_perk
}

eotm_can_debug_grant_stewardship_organized_muster_rolls_perk = {
	NOT = { has_perk = organized_muster_rolls_perk }
	has_perk = defensive_measures_perk
}

eotm_can_debug_grant_stewardship_cutting_corners_perk = {
	NOT = { has_perk = cutting_corners_perk }
}

eotm_can_debug_grant_stewardship_professional_workforce_perk = {
	NOT = { has_perk = professional_workforce_perk }
	has_perk = cutting_corners_perk
}

eotm_can_debug_grant_stewardship_centralization_perk = {
	NOT = { has_perk = centralization_perk }
	has_perk = professional_workforce_perk
}

eotm_can_debug_grant_stewardship_popular_figurehead_perk = {
	NOT = { has_perk = popular_figurehead_perk }
	has_perk = organized_muster_rolls_perk
	has_perk = centralization_perk
}

eotm_can_debug_grant_stewardship_divided_attention_perk = {
	NOT = { has_perk = divided_attention_perk }
	has_perk = popular_figurehead_perk
}

eotm_can_debug_grant_stewardship_meritocracy_perk = {
	NOT = { has_perk = meritocracy_perk }
}

eotm_can_debug_grant_stewardship_chains_of_loyalty_perk = {
	NOT = { has_perk = chains_of_loyalty_perk }
	has_perk = meritocracy_perk
}

eotm_can_debug_grant_stewardship_likable_perk = {
	NOT = { has_perk = likable_perk }
	has_perk = chains_of_loyalty_perk
}

eotm_can_debug_grant_stewardship_positions_of_power_perk = {
	NOT = { has_perk = positions_of_power_perk }
	has_perk = likable_perk
}

eotm_can_debug_grant_stewardship_large_levies_perk = {
	NOT = { has_perk = large_levies_perk }
	has_perk = meritocracy_perk
}

eotm_can_debug_grant_stewardship_soon_forgiven_perk = {
	NOT = { has_perk = soon_forgiven_perk }
	has_perk = large_levies_perk
}

eotm_can_debug_grant_stewardship_toe_the_line_perk = {
	NOT = { has_perk = toe_the_line_perk }
	has_perk = soon_forgiven_perk
}

eotm_can_debug_grant_stewardship_honored_to_serve_perk = {
	NOT = { has_perk = honored_to_serve_perk }
	has_perk = toe_the_line_perk
	has_perk = positions_of_power_perk
}

eotm_has_valid_debug_stewardship_wealth_normal_perk = {
	OR = {
		eotm_can_debug_grant_stewardship_golden_obligations_perk = yes
		eotm_can_debug_grant_stewardship_heregeld_perk = yes
		eotm_can_debug_grant_stewardship_detailed_ledgers_perk = yes
		eotm_can_debug_grant_stewardship_war_profiteer_perk = yes
		eotm_can_debug_grant_stewardship_fearful_troops_perk = yes
		eotm_can_debug_grant_stewardship_it_is_my_domain_perk = yes
		eotm_can_debug_grant_stewardship_golden_aplomb_perk = yes
		eotm_can_debug_grant_stewardship_at_any_cost_perk = yes
	}
}

eotm_has_valid_debug_stewardship_domain_normal_perk = {
	OR = {
		eotm_can_debug_grant_stewardship_tax_man_perk = yes
		eotm_can_debug_grant_stewardship_defensive_measures_perk = yes
		eotm_can_debug_grant_stewardship_organized_muster_rolls_perk = yes
		eotm_can_debug_grant_stewardship_cutting_corners_perk = yes
		eotm_can_debug_grant_stewardship_professional_workforce_perk = yes
		eotm_can_debug_grant_stewardship_centralization_perk = yes
		eotm_can_debug_grant_stewardship_popular_figurehead_perk = yes
		eotm_can_debug_grant_stewardship_divided_attention_perk = yes
	}
}

eotm_has_valid_debug_stewardship_duty_normal_perk = {
	OR = {
		eotm_can_debug_grant_stewardship_meritocracy_perk = yes
		eotm_can_debug_grant_stewardship_chains_of_loyalty_perk = yes
		eotm_can_debug_grant_stewardship_likable_perk = yes
		eotm_can_debug_grant_stewardship_positions_of_power_perk = yes
		eotm_can_debug_grant_stewardship_large_levies_perk = yes
		eotm_can_debug_grant_stewardship_soon_forgiven_perk = yes
		eotm_can_debug_grant_stewardship_toe_the_line_perk = yes
		eotm_can_debug_grant_stewardship_honored_to_serve_perk = yes
	}
}

eotm_has_any_valid_debug_stewardship_normal_perk = {
	OR = {
		eotm_has_valid_debug_stewardship_wealth_normal_perk = yes
		eotm_has_valid_debug_stewardship_domain_normal_perk = yes
		eotm_has_valid_debug_stewardship_duty_normal_perk = yes
	}
}

eotm_any_debug_stewardship_candidate_available = {
	OR = {
		eotm_any_debug_stewardship_final_unlock_available = yes
		eotm_has_any_valid_debug_stewardship_normal_perk = yes
	}
}

eotm_one_way_stewardship_focus_is_wealth = {
	has_variable = eotm_one_way_stewardship_focus
	var:eotm_one_way_stewardship_focus ?= 1
}

eotm_one_way_stewardship_focus_is_domain = {
	has_variable = eotm_one_way_stewardship_focus
	var:eotm_one_way_stewardship_focus ?= 2
}

eotm_one_way_stewardship_focus_is_duty = {
	has_variable = eotm_one_way_stewardship_focus
	var:eotm_one_way_stewardship_focus ?= 3
}

eotm_one_way_stewardship_focus_can_continue = {
	OR = {
		AND = {
			eotm_one_way_stewardship_focus_is_wealth = yes
			eotm_has_valid_stewardship_wealth_normal_inheritance_perk = yes
		}
		AND = {
			eotm_one_way_stewardship_focus_is_domain = yes
			eotm_has_valid_stewardship_domain_normal_inheritance_perk = yes
		}
		AND = {
			eotm_one_way_stewardship_focus_is_duty = yes
			eotm_has_valid_stewardship_duty_normal_inheritance_perk = yes
		}
	}
}

eotm_balanced_stewardship_wealth_is_lowest_valid_branch = {
	eotm_has_valid_stewardship_wealth_normal_inheritance_perk = yes
	exists = var:eotm_balanced_stewardship_wealth_count
	exists = var:eotm_balanced_stewardship_domain_count
	exists = var:eotm_balanced_stewardship_duty_count
	var:eotm_balanced_stewardship_wealth_count <= var:eotm_balanced_stewardship_domain_count
	var:eotm_balanced_stewardship_wealth_count <= var:eotm_balanced_stewardship_duty_count
}

eotm_balanced_stewardship_domain_is_lowest_valid_branch = {
	eotm_has_valid_stewardship_domain_normal_inheritance_perk = yes
	exists = var:eotm_balanced_stewardship_wealth_count
	exists = var:eotm_balanced_stewardship_domain_count
	exists = var:eotm_balanced_stewardship_duty_count
	var:eotm_balanced_stewardship_domain_count <= var:eotm_balanced_stewardship_wealth_count
	var:eotm_balanced_stewardship_domain_count <= var:eotm_balanced_stewardship_duty_count
}

eotm_balanced_stewardship_duty_is_lowest_valid_branch = {
	eotm_has_valid_stewardship_duty_normal_inheritance_perk = yes
	exists = var:eotm_balanced_stewardship_wealth_count
	exists = var:eotm_balanced_stewardship_domain_count
	exists = var:eotm_balanced_stewardship_duty_count
	var:eotm_balanced_stewardship_duty_count <= var:eotm_balanced_stewardship_wealth_count
	var:eotm_balanced_stewardship_duty_count <= var:eotm_balanced_stewardship_domain_count
}
