﻿interactive_liege_vassal_check_trigger = {
	custom_description = {
		text = "basic_ally_can_join_because_liege_or_vassals"
		subject = scope:recipient
		trigger_if = {
			limit = {
				scope:actor = {
					is_defender_in_war = scope:target
				}
			}
			scope:recipient = {
				NOR = {
					any_liege_or_above = {
						is_attacker_in_war = scope:target
					}
					any_vassal = {
						is_attacker_in_war = scope:target
					}
					AND = {
						any_vassal_or_below = {
							is_attacker_in_war = scope:target
						}
						NOT = {
							scope:actor = {
								target_is_liege_or_above = scope:recipient
							}
						}
					}
				}
			}
		}
		trigger_else_if = {
			limit = {
				scope:actor = {
					is_attacker_in_war = scope:target
				}
			}
			scope:recipient = {
				NOR = {
					any_liege_or_above = {
						is_defender_in_war = scope:target
					}
					any_vassal_or_below = {
						is_defender_in_war = scope:target
					}
				}
			}
		}
		trigger_else = {
			always = yes
		}
	}
}

can_potentially_call_ally_trigger = {
	# Can never call vassals to your own wars (their obligations are met via taxes and levies!)
	custom_description = {
		text = cannot_call_vassal_to_war
		OR = {
			$JOINER$ = {
				NOT = {
					is_vassal_or_below_of = $WARRIOR$
				}
			}
			has_game_rule = call_allied_vassals_enabled
		}
	}
}

# faction
interactive_common_can_character_join_trigger = {
	common_character_validity_trigger = {
		FACTION_TARGET = $FACTION_TARGET$
	}
	is_adult = yes
	NOT = {
		has_truce = $FACTION_TARGET$
	}
	$FACTION_TARGET$ = {
		NOT = {
			has_strong_hook = root
		}
	}
	OR = {
		is_ai = no
		NOR = {
			has_relation_lover = $FACTION_TARGET$
			has_relation_friend = $FACTION_TARGET$
		}
	}
	$FACTION_TARGET$.highest_held_title_tier > tier_county
	custom_description = {
		text = character_has_faction_disabling_modifier
		character_has_faction_disabling_modifier_trigger = yes
	}
}

# MIV: disable crusades for shattered world settings
suitable_faith_for_any_ghw_trigger = {
	NOR = {
		has_game_rule = shattered_world_miv_enabled
		has_game_rule = diverse_world_miv_enabled
		has_game_rule = tribal_world_miv_enabled
	}
	NOT = {
		has_game_rule = miv_great_holy_wars_miv_restricted		# MIV: disable crusades rule
	}
	OR = {
		has_doctrine = tenet_armed_pilgrimages		#Catholics
		has_doctrine = tenet_struggle_submission		#Islam (though, the default Faiths have Temporal Heads, so still do not qualify)
		has_doctrine = tenet_warmonger		#Germanic (though, starting as Unreformed, it still doesn't qualify by default)
		has_doctrine = divine_destiny_doctrine		#SPECIAL: Has become the Chakravarti
		has_game_rule = miv_great_holy_wars_miv_unrestricted		# MIV: allow crusades for all faiths rule
	}
	OR = {
		has_doctrine = doctrine_temporal_head
		has_doctrine = doctrine_spiritual_head
	}
	NOR = {
		has_doctrine_parameter = unreformed
		AND = {
			has_doctrine = tenet_dharmic_pacifism
			NOT = {
				has_doctrine = divine_destiny_doctrine
			}
		}
		has_doctrine = tenet_pacifism
	}
	fervor >= 65
}

# MIV: rules to disable holy site requirement
can_create_temporal_head_of_faith_title_trigger = {
	trigger_if = {
		limit = {
			has_game_rule = miv_head_of_faith_miv_disabled
		}
		num_realm_holy_sites_faithful_holders = {
			COUNT = holy_sites_to_create_temporal_head_of_faith
			CHARACTER = ROOT
		}
	}
	root = {
		piety_level >= high_piety_level
	}
	trigger_if = {
		limit = {
			root = {
				is_independent_ruler = no
			}
		}
		custom_description = {
			text = cannot_create_hof_title_at_or_above_liege_tier
			root.liege.primary_title.tier > tier_duchy
		}
	}
}

can_create_spiritual_head_of_faith_title_trigger = {
	trigger_if = {
		limit = {
			has_game_rule = miv_head_of_faith_miv_disabled
		}
		num_realm_holy_sites_faithful_holders = {
			COUNT = holy_sites_to_create_spiritual_head_of_faith
			CHARACTER = ROOT
		}
	}
	root = {
		piety_level >= medium_piety_level
	}
	trigger_if = {
		limit = {
			has_doctrine = special_doctrine_not_allowed_to_hof
		}
		NOT = {
			has_doctrine = special_doctrine_not_allowed_to_hof
		}
	}
	NAND = {
		exists = religious_head
		has_doctrine_parameter = maintains_head_of_faith_on_creation
	}
}
