﻿
terrible_devaraja_quality_trigger = {
	has_mandala_capital_trigger = no
}

poor_devaraja_quality_trigger = {
	capital_province = { has_building_or_higher = mandala_capital_01 }
	mandala_radiance_value >= 1
}

middling_devaraja_quality_trigger = {
	capital_province = { has_building_or_higher = mandala_capital_02 }
	mandala_radiance_value >= 10
}

good_devaraja_quality_trigger = {
	capital_province = { has_building_or_higher = mandala_capital_03 }
	mandala_radiance_value >= 30
}

great_devaraja_quality_trigger = {
	capital_province = { has_building_or_higher = mandala_capital_04 }
	mandala_radiance_value >= 50
}

exalted_devaraja_quality_trigger = {
	capital_province = { has_building_or_higher = mandala_capital_05 }
	mandala_radiance_value >= 80
}


house_has_peaceful_rule_3_year_trigger = {
	OR = {
		has_house_head_parameter = peaceful_rule_3_year_modifier
		has_house_head_parameter = peaceful_rule_3_year_interim_modifier
	}
}

house_has_creator_20_years_trigger = {
	OR = {
		has_house_head_parameter = creator_20_year_modifier
		has_house_head_parameter = creator_20_year_interim_modifier
	}
}

house_has_creator_10_years_trigger = {
	OR = {
		has_house_head_parameter = creator_10_year_modifier
		has_house_head_parameter = creator_10_year_interim_modifier
	}
}

house_has_unlock_agent_piety_bribe_trigger = {
	OR = {
		has_house_head_parameter = unlock_agent_piety_bribe
		has_house_power_parameter = aspect_of_trickery_03
		has_house_power_parameter = aspect_of_trickery_04
		has_house_power_parameter = aspect_of_trickery_05
	}
}


same_mandala_aspect_trigger = {
	OR = {
		AND = {
			$FIRST_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_creation }
			}
			$SECOND_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_creation }
			}
		}
		AND = {
			$FIRST_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_serenity }
			}
			$SECOND_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_serenity }
			}
		}
		AND = {
			$FIRST_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_destruction }
			}
			$SECOND_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_destruction }
			}
		}
		AND = {
			$FIRST_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_trickery }
			}
			$SECOND_CHAR$ = {
				house = { has_house_power_parameter = aspect_of_trickery }
			}
		}
	}
}

has_mandala_aspect_trigger = {
	house ?= {
		OR = {
			has_house_power_parameter = aspect_of_creation
			has_house_power_parameter = aspect_of_serenity
			has_house_power_parameter = aspect_of_destruction
			has_house_power_parameter = aspect_of_trickery
		}
	}
}

has_no_mandala_aspect_trigger = {
	house ?= {
		NOR = {
			has_house_power_parameter = aspect_of_creation
			has_house_power_parameter = aspect_of_serenity
			has_house_power_parameter = aspect_of_destruction
			has_house_power_parameter = aspect_of_trickery
		}
	}
}


has_mandala_aspect_level_1_trigger = {
	house ?= {
		OR = {
			has_house_power_parameter = aspect_of_creation_01
			has_house_power_parameter = aspect_of_serenity_01
			has_house_power_parameter = aspect_of_destruction_01
			has_house_power_parameter = aspect_of_trickery_01
		}
	}
}

has_mandala_aspect_level_2_trigger = {
	house ?= {
		OR = {
			has_house_power_parameter = aspect_of_creation_02
			has_house_power_parameter = aspect_of_serenity_02
			has_house_power_parameter = aspect_of_destruction_02
			has_house_power_parameter = aspect_of_trickery_02
		}
	}
}

has_mandala_aspect_level_3_trigger = {
	house ?= {
		OR = {
			has_house_power_parameter = aspect_of_creation_03
			has_house_power_parameter = aspect_of_serenity_03
			has_house_power_parameter = aspect_of_destruction_03
			has_house_power_parameter = aspect_of_trickery_03
		}
	}
}

has_mandala_aspect_level_4_trigger = {
	house ?= {
		OR = {
			has_house_power_parameter = aspect_of_creation_04
			has_house_power_parameter = aspect_of_serenity_04
			has_house_power_parameter = aspect_of_destruction_04
			has_house_power_parameter = aspect_of_trickery_04
		}
	}
}

has_mandala_aspect_level_5_trigger = {
	house ?= {
		OR = {
			has_house_power_parameter = aspect_of_creation_05
			has_house_power_parameter = aspect_of_serenity_05
			has_house_power_parameter = aspect_of_destruction_05
			has_house_power_parameter = aspect_of_trickery_05
		}
	}
}

has_mandala_aspect_2_or_higher_trigger = {
	OR = {
		has_mandala_aspect_level_2_trigger = yes
		has_mandala_aspect_level_3_trigger = yes
		has_mandala_aspect_level_4_trigger = yes
		has_mandala_aspect_level_5_trigger = yes
	}
}

has_mandala_capital_trigger = {
	capital_province ?= { has_building_with_flag = mandala_capital_building }
}

has_unruined_mandala_capital_trigger = {
	capital_province ?= {
		has_building_with_flag = mandala_capital_building
		has_ruined_great_building = no
	}
}

has_ruined_mandala_capital_trigger = {
	capital_province = {
		has_building_with_flag = mandala_capital_building
		has_ruined_great_building = yes
	}
}


can_afford_mandala_aspect_change_trigger = { piety >= mandala_aspect_piety_cost_first_level }

can_afford_mandala_aspect_level_2_trigger = {
	prestige >= mandala_aspect_prestige_cost_second_level
	piety >= mandala_aspect_piety_cost_second_level
}

can_afford_mandala_aspect_level_3_trigger = {
	prestige >= mandala_aspect_prestige_cost_third_level
	piety >= mandala_aspect_piety_cost_third_level
}

can_afford_mandala_aspect_level_4_trigger = {
	prestige >= mandala_aspect_prestige_cost_fourth_level
	piety >= mandala_aspect_piety_cost_fourth_level
}

can_afford_mandala_aspect_level_5_trigger = {
	prestige >= mandala_aspect_prestige_cost_fifth_level
	piety >= mandala_aspect_piety_cost_fifth_level
}


#Only 2 Mandala Capitals per De Jure Kingdom
less_than_max_amount_of_mandala_capitals_trigger = {
	save_temporary_scope_as = root_scope
	capital_county.kingdom = {
		any_in_de_jure_hierarchy = {
			count < mandala_capitals_per_dejure_kingdom
			tier = tier_barony
			title_province = { 
				NOT = { this.county = scope:root_scope.capital_county } #We don't count our own great project since it needs to be upgradeable.
				OR = {
					AND = {
						has_building_with_flag = mandala_capital_building
						has_ruined_great_building = no
						is_ruined_building_being_reconstructed = no
					}
					any_great_project_in_province = {
						OR = {
							great_project_type = mandala_capital_01
							great_project_type = mandala_capital_02
							great_project_type = mandala_capital_03
							great_project_type = mandala_capital_04
							great_project_type = mandala_capital_05
						}
						OR = {
							great_project_construction_phase_is = in_progress
							great_project_construction_phase_is = completed
						}	
					}
				}						
			}
		}
	}
}

has_unfunded_contribution_in_planned_mandala_capital_trigger = {
	save_temporary_scope_as = owner_check
	any_great_project = {
		great_project_owner = scope:owner_check
		OR = {
			great_project_type = mandala_capital_01
			great_project_type = mandala_capital_02
			great_project_type = mandala_capital_03
			great_project_type = mandala_capital_04
			great_project_type = mandala_capital_05
		}
		great_project_construction_phase_is = planned
		any_contribution = {
			is_owner_only_contribution_trigger = no
			contribution_is_funded = no
		}
	}
}


#Mandala Worthiness Triggers — applied from second tier Aspect and first tier Capital Temple Complex

has_pilgrimage_trait_level_trigger = {
	trigger_if = {
		limit = { $TIER$ = 05 }
		custom_tooltip = {
			text = rite_of_worthiness_tier_5_pilgrim
			has_trait_xp = {
				trait = pilgrim
				value >= mandala_pilgrim_xp_last_tier_value
			}
		}
	}
	trigger_else_if = {
		limit = { $TIER$ = 04 }
		custom_tooltip = {
			text = rite_of_worthiness_tier_4_pilgrim
			has_trait_xp = {
				trait = pilgrim
				value >= mandala_pilgrim_xp_third_tier_value
			}
		}	
	}
	trigger_else_if = {
		limit = { $TIER$ = 03 }
		custom_tooltip = {
			text = rite_of_worthiness_tier_3_pilgrim
			has_trait_xp = {
				trait = pilgrim
				value >= mandala_pilgrim_xp_second_tier_value
			}
		}	
	}
	trigger_else_if = {
		limit = { $TIER$ = 02 }
		custom_tooltip = {
			text = rite_of_worthiness_tier_2_pilgrim
			has_trait_xp = {
				trait = pilgrim
				value >= mandala_pilgrim_xp_first_tier_value
			}
		}	
	}
	trigger_else = {
		custom_tooltip = {
			text = rite_of_worthiness_tier_1_pilgrim
			has_trait = pilgrim
		}
	}
}

#CREATION
creation_children_trigger = {
	trigger_if = {
		limit = { is_female = yes }
		custom_tooltip = {
			text = rite_of_worthiness_creation_female
			mandala_creation_child_counter >= num_female_creation_mandala_children_born
		}
	}
	trigger_if = {
		limit = { is_male = yes }
		custom_tooltip = {
			text = rite_of_worthiness_creation_male
			mandala_creation_child_counter >= num_male_creation_mandala_children_born
		}
	}	
}

creation_first_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 01 }
	creation_children_trigger = yes
}

creation_second_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 02 }
	creation_children_trigger = yes
	custom_tooltip = {
		text = rite_of_worthiness_creation_buildings_t2
		house = {
			has_variable = num_buildings_built
			var:num_buildings_built >= num_creation_mandala_buildings_built_t2
		}
	}
	trigger_if = {
		limit = { is_ai = no }
		gold >= creation_mandala_stashed_gold_t2
	}	
}

creation_third_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 03 }
	creation_children_trigger = yes
	custom_tooltip = {
		text = rite_of_worthiness_creation_buildings_t3
		house = {
			has_variable = num_buildings_built
			var:num_buildings_built >= num_creation_mandala_buildings_built_t3
		}
	}
	custom_tooltip = {
		text = rite_of_worthiness_creation_artifacts_t3
		has_variable = num_commissioned_artifacts
		var:num_commissioned_artifacts >= num_creation_mandala_commissioned_artifacts_t3
	}
	trigger_if = {
		limit = { is_ai = no }
		gold >= creation_mandala_stashed_gold_t3
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_creation_house_size_t3
			house = {
				any_house_member = { count >= num_creation_mandala_house_size_t3 }
			}
		}
	}
}

creation_fourth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 04 }
	creation_children_trigger = yes
	custom_tooltip = {
		text = rite_of_worthiness_creation_buildings_t4
		house = {
			has_variable = num_buildings_built
			var:num_buildings_built >= num_creation_mandala_buildings_built_t4
		}
	}
	custom_tooltip = {
		text = rite_of_worthiness_creation_artifacts_t4
		has_variable = num_commissioned_artifacts
		var:num_commissioned_artifacts >= num_creation_mandala_commissioned_artifacts_t4
	}
	trigger_if = {
		limit = { is_ai = no }
		gold >= creation_mandala_stashed_gold_t4
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_creation_house_size_t4
			house = {
				any_house_member = { count >= num_creation_mandala_house_size_t4 }
			}
		}
	}
}

creation_fifth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 05 }
	creation_children_trigger = yes
	custom_tooltip = {
		text = rite_of_worthiness_creation_buildings_t5
		house = {
			has_variable = num_buildings_built
			var:num_buildings_built >= num_creation_mandala_buildings_built_t5
		}
	}
	custom_tooltip = {
		text = rite_of_worthiness_creation_artifacts_t5
		has_variable = num_commissioned_artifacts
		var:num_commissioned_artifacts >= num_creation_mandala_commissioned_artifacts_t5
	}
	trigger_if = {
		limit = { is_ai = no }
		gold >= creation_mandala_stashed_gold_t5
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_creation_house_size_t5
			house = {
				any_house_member = { count >= num_creation_mandala_house_size_t5 }
			}
		}
	}
}


#SERENITY
serenity_high_end_alliances_trigger = {
	custom_tooltip = {
		text = rite_of_worthiness_serenity
		any_ally = {
			primary_title.tier >= $MANDALA$.primary_title.tier
			NOR = {
				is_tributary_of = $MANDALA$
				is_vassal_of = $MANDALA$
			}
			count >= num_serenity_mandala_highend_alliances_had
		}
	}
}

serenity_first_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 01 }
	trigger_if = {
		limit = { is_ai = no }
		serenity_high_end_alliances_trigger = { MANDALA = $MANDALA$ }
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_years_of_peace_t1
		has_variable = serenity_mandala_years_of_non_aggression_war
		var:serenity_mandala_years_of_non_aggression_war >= num_serenity_mandala_years_of_peace_t1
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_friends_t1
		num_of_relation_friend >= num_serenity_mandala_friends_t1
	}
}

serenity_second_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 02 }
	trigger_if = {
		limit = { is_ai = no }
		serenity_high_end_alliances_trigger = { MANDALA = $MANDALA$ }
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_years_of_peace_t2
		has_variable = serenity_mandala_years_of_non_aggression_war
		var:serenity_mandala_years_of_non_aggression_war >= num_serenity_mandala_years_of_peace_t2
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_friends_t2
		num_of_relation_friend >= num_serenity_mandala_friends_t2
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_serenity_feasts_hosted_t2
			has_variable = num_exorbitant_feasts_hosted
			var:num_exorbitant_feasts_hosted >= num_serenity_mandala_feasts_hosted_t2
		}
	}
}

serenity_third_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 03 }
	trigger_if = {
		limit = { is_ai = no }
		serenity_high_end_alliances_trigger = { MANDALA = $MANDALA$ }
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_years_of_peace_t3
		has_variable = serenity_mandala_years_of_non_aggression_war
		var:serenity_mandala_years_of_non_aggression_war >= num_serenity_mandala_years_of_peace_t3
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_friends_t3
		num_of_relation_friend >= num_serenity_mandala_friends_t3
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_serenity_feasts_hosted_t3
			has_variable = num_exorbitant_feasts_hosted
			var:num_exorbitant_feasts_hosted >= num_serenity_mandala_feasts_hosted_t3
		}
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_capital_development_t3
		capital_province = {
			OR = {
				has_building_or_higher = castle_02
				has_building_or_higher = temple_02
				has_building_or_higher = city_02
				has_building_or_higher = temple_citadel_02
			}
		}
	}
}

serenity_fourth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 04 }
	trigger_if = {
		limit = { is_ai = no }
		serenity_high_end_alliances_trigger = { MANDALA = $MANDALA$ }
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_years_of_peace_t4
		has_variable = serenity_mandala_years_of_non_aggression_war
		var:serenity_mandala_years_of_non_aggression_war >= num_serenity_mandala_years_of_peace_t4
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_friends_t4
		num_of_relation_friend >= num_serenity_mandala_friends_t4
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_serenity_feasts_hosted_t4
			has_variable = num_exorbitant_feasts_hosted
			var:num_exorbitant_feasts_hosted >= num_serenity_mandala_feasts_hosted_t4
		}
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_capital_development_t4
		capital_province = {
			OR = {
				has_building_or_higher = castle_03
				has_building_or_higher = temple_03
				has_building_or_higher = city_03
				has_building_or_higher = temple_citadel_03
			}
		}
	}
}

serenity_fifth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 05 }
	trigger_if = {
		limit = { is_ai = no }
		serenity_high_end_alliances_trigger = { MANDALA = $MANDALA$ }
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_years_of_peace_t5
		has_variable = serenity_mandala_years_of_non_aggression_war
		var:serenity_mandala_years_of_non_aggression_war >= num_serenity_mandala_years_of_peace_t5
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_friends_t5
		num_of_relation_friend >= num_serenity_mandala_friends_t5
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_serenity_feasts_hosted_t5
			has_variable = num_exorbitant_feasts_hosted
			var:num_exorbitant_feasts_hosted >= num_serenity_mandala_feasts_hosted_t5
		}
	}
	custom_tooltip = {
		text = rite_of_worthiness_serenity_capital_development_t5
		capital_province = {
			OR = {
				has_building_or_higher = castle_04
				has_building_or_higher = temple_04
				has_building_or_higher = city_04
				has_building_or_higher = temple_citadel_04
			}
		}
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_serenity_soulmate
			num_of_relation_soulmate = 1
		}
	}
}


#DESTRUCTION
destruction_won_more_than_lost_trigger = {
	custom_tooltip = {
		text = rite_of_worthiness_destruction_won_more_than_lost
		num_wars_won > num_wars_lost
	}
}

destruction_first_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 01 }
	trigger_if = {
		limit = { is_ai = no }
		destruction_won_more_than_lost_trigger = yes
	}
	custom_tooltip = {
		text = rite_of_worthiness_destruction_wars_t1
		any_memory = {
			memory_type = war_won
			count >= num_destruction_mandala_wars_won_t1
		}
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_battles_t1
			any_memory = {
				memory_type = battle_won_memory
				count >= num_destruction_mandala_battles_won_t1
			}
		}
	}
	martial >= num_destruction_martial_skill_t1
	prowess >= num_destruction_prowess_skill_t1
}

destruction_second_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 02 }
	trigger_if = {
		limit = { is_ai = no }
		destruction_won_more_than_lost_trigger = yes
	}
	custom_tooltip = {
		text = rite_of_worthiness_destruction_wars_t2
		any_memory = {
			memory_type = war_won
			count >= num_destruction_mandala_wars_won_t2
		}
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_battles_t2
			any_memory = {
				memory_type = battle_won_memory
				count >= num_destruction_mandala_battles_won_t2
			}
		}
	}
	martial >= num_destruction_martial_skill_t2
	prowess >= num_destruction_prowess_skill_t2
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_prowess_knights_t2
			any_knight = {
				count >= num_prowess_knights_t2
				prowess >= num_prowess_knights_t5
			}
		}
	}
}

destruction_third_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 03 }
	trigger_if = {
		limit = { is_ai = no }
		destruction_won_more_than_lost_trigger = yes
	}
	custom_tooltip = {
		text = rite_of_worthiness_destruction_wars_t3
		any_memory = {
			memory_type = war_won
			count >= num_destruction_mandala_wars_won_t3
		}
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_battles_t3
			any_memory = {
				memory_type = battle_won_memory
				count >= num_destruction_mandala_battles_won_t3
			}
		}
	}
	martial >= num_destruction_martial_skill_t3
	prowess >= num_destruction_prowess_skill_t3
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_prowess_knights_t3
			any_knight = {
				count >= num_prowess_knights_t3
				prowess >= num_prowess_knights_t5
			}
		}
	}
}

destruction_fourth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 04 }
	trigger_if = {
		limit = { is_ai = no }
		destruction_won_more_than_lost_trigger = yes
	}
	custom_tooltip = {
		text = rite_of_worthiness_destruction_wars_t4
		any_memory = {
			memory_type = war_won
			count >= num_destruction_mandala_wars_won_t4
		}
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_battles_t4
			any_memory = {
				memory_type = battle_won_memory
				count >= num_destruction_mandala_battles_won_t4
			}
		}
	}
	martial >= num_destruction_martial_skill_t4
	prowess >= num_destruction_prowess_skill_t4
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_prowess_knights_t4
			any_knight = {
				count >= num_prowess_knights_t4
				prowess >= num_prowess_knights_t5
			}
		}
	}
}

destruction_fifth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 05 }
	trigger_if = {
		limit = { is_ai = no }
		destruction_won_more_than_lost_trigger = yes
	}
	custom_tooltip = {
		text = rite_of_worthiness_destruction_wars_t5
		any_memory = {
			memory_type = war_won
			count >= num_destruction_mandala_wars_won_t5
		}
	}
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_battles_t5
			any_memory = {
				memory_type = battle_won_memory
				count >= num_destruction_mandala_battles_won_t5
			}
		}
	}
	martial >= num_destruction_martial_skill_t5
	prowess >= num_destruction_prowess_skill_t5
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_destruction_prowess_knights_t5
			any_knight = {
				count >= num_prowess_knights_t5
				prowess >= num_prowess_knights_t5
			}
		}
	}
}


#TRICKERY
trickery_first_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 01 }
	NOT = { has_character_modifier = disbelieved_mandala_modifier }
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_trickery_schemes_t1
			exists = var:num_successful_schemes
			var:num_successful_schemes >= num_trickster_mandala_successful_schemes_t1
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_secrets_t1
			any_known_secret = {
				count >= num_trickster_mandala_secrets_known_t1
				trigger_if = {
					limit = { exists = secret_target }
					NOT = { secret_target = scope:owner }
				}
				NOT = { secret_owner = scope:owner }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_house_married_to_rulers_t1
			save_temporary_scope_as = root_scope
			house = {
				any_house_member = {
					count >= num_trickster_mandala_house_married_to_rulers_t1
					any_spouse = {
						is_landed = yes
						top_overlord != scope:root_scope
						this != scope:root_scope
						primary_title.tier >= tier_duchy
					}
				}
			}
		}
	}	
}

trickery_second_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 02 }
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_trickery_schemes_t2
			exists = var:num_successful_schemes
			var:num_successful_schemes >= num_trickster_mandala_successful_schemes_t2
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_secrets_t2
			any_known_secret = {
				count >= num_trickster_mandala_secrets_known_t2
				trigger_if = {
					limit = { exists = secret_target }
					NOT = { secret_target = scope:owner }
				}
				NOT = { secret_owner = scope:owner }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_house_married_to_rulers_t2
			save_temporary_scope_as = root_scope
			house = {
				any_house_member = {
					count >= num_trickster_mandala_house_married_to_rulers_t2
					any_spouse = {
						is_landed = yes
						top_overlord != scope:root_scope
						this != scope:root_scope
						primary_title.tier >= tier_duchy
					}
				}
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_strong_hooks_t2
			any_hooked_character = {
				count >= num_trickster_mandala_strong_hooks_t2
				scope:owner = { has_strong_hook = prev }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_gold_ransomed_t2
			exists = var:amount_of_gold_ransomed
			var:amount_of_gold_ransomed >= trickster_mandala_gold_ransomed_t2
		}
	}
}

trickery_third_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 03 }
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_trickery_schemes_t3
			exists = var:num_successful_schemes
			var:num_successful_schemes >= num_trickster_mandala_successful_schemes_t3
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_secrets_t3
			any_known_secret = {
				count >= num_trickster_mandala_secrets_known_t3
				trigger_if = {
					limit = { exists = secret_target }
					NOT = { secret_target = scope:owner }
				}
				NOT = { secret_owner = scope:owner }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_house_married_to_rulers_t3
			save_temporary_scope_as = root_scope
			house = {
				any_house_member = {
					count >= num_trickster_mandala_house_married_to_rulers_t3
					any_spouse = {
						is_landed = yes
						top_overlord != scope:root_scope
						this != scope:root_scope
						primary_title.tier >= tier_duchy
					}
				}
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_strong_hooks_t3
			any_hooked_character = {
				count >= num_trickster_mandala_strong_hooks_t3
				scope:owner = { has_strong_hook = prev }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_gold_ransomed_t3
			exists = var:amount_of_gold_ransomed
			var:amount_of_gold_ransomed >= trickster_mandala_gold_ransomed_t3
		}
	}
}

trickery_fourth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 04 }
	NOT = { has_character_modifier = disbelieved_mandala_modifier }
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_trickery_schemes_t4
			exists = var:num_successful_schemes
			var:num_successful_schemes >= num_trickster_mandala_successful_schemes_t4
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_secrets_t4
			any_known_secret = {
				count >= num_trickster_mandala_secrets_known_t4
				trigger_if = {
					limit = { exists = secret_target }
					NOT = { secret_target = scope:owner }
				}
				NOT = { secret_owner = scope:owner }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_house_married_to_rulers_t4
			save_temporary_scope_as = root_scope
			house = {
				any_house_member = {
					count >= num_trickster_mandala_house_married_to_rulers_t4
					any_spouse = {
						is_landed = yes
						top_overlord != scope:root_scope
						this != scope:root_scope
						primary_title.tier >= tier_duchy
					}
				}
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_strong_hooks_t4
			any_hooked_character = {
				count >= num_trickster_mandala_strong_hooks_t4
				scope:owner = { has_strong_hook = prev }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_gold_ransomed_t4
			exists = var:amount_of_gold_ransomed
			var:amount_of_gold_ransomed >= trickster_mandala_gold_ransomed_t4
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_house_rulers_t4
			house = {
				any_house_member = {
					count >= num_trickster_mandala_house_rulers_t4
					primary_title.tier >= tier_duchy
					is_landed = yes
					is_independent_ruler = yes
					top_overlord != scope:owner
				}
			}
		}
	}
}

trickery_fifth_tier_trigger = {
	is_house_head = yes
	has_pilgrimage_trait_level_trigger = { TIER = 05 }
	NOT = { has_character_modifier = disbelieved_mandala_modifier }
	trigger_if = {
		limit = { is_ai = no }
		custom_tooltip = {
			text = rite_of_worthiness_trickery_schemes_t5
			exists = var:num_successful_schemes
			var:num_successful_schemes >= num_trickster_mandala_successful_schemes_t5
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_secrets_t5
			any_known_secret = {
				count >= num_trickster_mandala_secrets_known_t5
				trigger_if = {
					limit = { exists = secret_target }
					NOT = { secret_target = scope:owner }
				}
				NOT = { secret_owner = scope:owner }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_house_married_to_rulers_t5
			save_temporary_scope_as = root_scope
			house = {
				any_house_member = {
					count >= num_trickster_mandala_house_married_to_rulers_t5
					any_spouse = {
						is_landed = yes
						top_overlord != scope:root_scope
						this != scope:root_scope
						primary_title.tier >= tier_duchy
					}
				}
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_strong_hooks_t5
			any_hooked_character = {
				count >= num_trickster_mandala_strong_hooks_t5
				scope:owner = { has_strong_hook = prev }
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_gold_ransomed_t5
			exists = var:amount_of_gold_ransomed
			var:amount_of_gold_ransomed >= trickster_mandala_gold_ransomed_t5
		}	
		custom_tooltip = {
			text = rite_of_worthiness_trickery_house_rulers_t5
			house = {
				any_house_member = {
					count >= num_trickster_mandala_house_rulers_t5
					primary_title.tier >= tier_duchy
					is_landed = yes
					is_independent_ruler = yes
					top_overlord != scope:owner
				}
			}
		}
		custom_tooltip = {
			text = rite_of_worthiness_trickery_only_one
			NOT = {
				any_ruler = {		
					is_landed = yes
					government_has_flag = government_is_mandala
					has_mandala_capital_trigger = yes
					mandala_radiance_value >= define:NMandala|MAX_RADIANCE
					this != scope:owner
				}
			}		
		}
	}
}

there_is_any_valid_mandala_contract_spot_trigger = {
	OR = {
		any_sub_realm_county = {
			any_county_province = {
				has_holding = yes
				is_occupied = no
				NOR = {
					this = scope:mandala_ruler.capital_province
					has_variable = requested_mandala_ritual
					has_variable = mandala_ritual_cooldown
				}
			}
		}
		any_tributary = {
			any_sub_realm_county = {
				any_county_province = {
					has_holding = yes
					is_occupied = no
					NOR = {
						this = scope:mandala_ruler.capital_province
						has_variable = requested_mandala_ritual
						has_variable = mandala_ritual_cooldown
					}
				}
			}
		}
	}
}

there_is_any_valid_mandala_contract_spot_with_crocodiles_trigger = {
	OR = {
		any_sub_realm_county = {
			any_county_province = {
				has_holding = yes
				is_occupied = no
				hunt_animal_crocodile_trigger = yes
				NOR = {
					this = scope:mandala_ruler.capital_province
					has_variable = requested_mandala_ritual
					has_variable = mandala_ritual_cooldown
				}
			}
		}
		any_tributary = {
			any_sub_realm_county = {
				any_county_province = {
					has_holding = yes
					is_occupied = no
					hunt_animal_crocodile_trigger = yes
					NOR = {
						this = scope:mandala_ruler.capital_province
						has_variable = requested_mandala_ritual
						has_variable = mandala_ritual_cooldown
					}
				}
			}
		}
	}
}

there_is_any_valid_mandala_contract_spot_with_neighbor_trigger = {
	OR = {
		any_sub_realm_county = {
			any_neighboring_county = {
				holder = {
					is_ai = yes
				}
				title_province = {
					has_holding = yes
				}
			}
			any_county_province = {
				has_holding = yes
				is_occupied = no
				NOR = {
					this = scope:mandala_ruler.capital_province
					has_variable = requested_mandala_ritual
					has_variable = mandala_ritual_cooldown
				}
			}
		}
		any_tributary = {
			any_sub_realm_county = {
				any_neighboring_county = {
					holder = {
						is_ai = yes
					}
					title_province = {
						has_holding = yes
					}
				}
				any_county_province = {
					has_holding = yes
					is_occupied = no
					NOR = {
						this = scope:mandala_ruler.capital_province
						has_variable = requested_mandala_ritual
						has_variable = mandala_ritual_cooldown
					}
				}
			}
		}
	}
}

there_is_any_valid_mandala_contract_spot_no_holding_trigger = {
	OR = {
		any_sub_realm_county = {
			any_county_province = {
				has_holding = no
				is_occupied = no
				NOR = {
					this = scope:mandala_ruler.capital_province
					has_variable = requested_mandala_ritual
					has_variable = mandala_ritual_cooldown
				}
			}
		}
		any_tributary = {
			any_sub_realm_county = {
				any_county_province = {
					has_holding = no
					is_occupied = no
					NOR = {
						this = scope:mandala_ruler.capital_province
						has_variable = requested_mandala_ritual
						has_variable = mandala_ritual_cooldown
					}
				}
			}
		}
	}
}



#MANDALA STORY TRIGGERS
would_contribute_to_mandala_capital_trigger = {
	NOR = { 
		has_relation_rival = scope:root_scope
		has_variable = recently_contributed_via_request
	}
	has_mandala_capital_trigger = no
}

is_story_godking_trigger = {
	has_variable = mandala_godking
	is_ai = yes
}
