﻿# Override of original trigger, adds ability for cultist adventurers to use female knights.
# Original file is common\scripted_triggers\00_religious_triggers.txt
can_be_combatant_based_on_gender_trigger = {
	custom_description = {
		text = "can_be_combatant_based_on_gender"
		object = this
		subject = $ARMY_OWNER$
		# Priests only fight if faith has war priests
		trigger_if = {
			limit = {
				OR = {
					has_trait = devoted
					is_clergy = yes
				}
			}
			OR = {
				faith = { has_doctrine_parameter = clergy_can_fight }
				culture = { has_cultural_parameter = culture_clergy_can_fight }
				AND = {
					$ARMY_OWNER$.culture = {
						has_cultural_parameter = high_prowess_ignores_knight_restrictions
					}
					prowess >= 10
				}
			}
		}
		OR = {
			trigger_if = { # Has the Royal Court and thus can modify pillars
				limit = {
					has_dlc_feature = diverge_culture # Can modify pillars
				}
				OR = {
					$ARMY_OWNER$ = { culture = { has_cultural_parameter = martial_custom_equal_combatant } }
					AND = {
						$ARMY_OWNER$ = { culture = { has_cultural_parameter = martial_custom_male_only_combatant } }
						is_male = yes
					}
					AND = {
						$ARMY_OWNER$ = { culture = { has_cultural_parameter = martial_custom_female_only_combatant } }
						is_female = yes
					}
				}
				
			}
			trigger_else = { # Does not have the Royal Court and thus combatant is governed by faith
				OR = {
					$ARMY_OWNER$ = { faith = { has_doctrine_parameter = combatant_can_be_either_gender_if_no_roco } }
					AND = {
						$ARMY_OWNER$ = { faith = { has_doctrine_parameter = combatant_must_be_male_if_no_roco } }
						is_male = yes
					}
					AND = {
						$ARMY_OWNER$ = { faith = { has_doctrine_parameter = combatant_must_be_female_if_no_roco } }
						is_female = yes
					}
				}
			}
			AND = {
				$ARMY_OWNER$ = {
					culture = { has_cultural_parameter = has_access_to_shieldmaidens }
				}
				# No need to gender diversify this: if they're a right-gender shieldperson of the culture, then they've already got permission to fight from the previous AND conditions.
				has_trait = shieldmaiden
			}
			# Event-based special exceptions
			OR = {
				has_character_modifier = ignores_gender_army_rules
				has_character_modifier = mpo_destined_leader_modifier
			}
			AND = {
				$ARMY_OWNER$ = { culture = { has_cultural_parameter = high_prowess_ignores_knight_restrictions } }
				NOT = { $ARMY_OWNER$ = { culture = { has_cultural_parameter = minimum_prowess_for_knights } } }
				prowess >= 10
			}
			AND = {
				$ARMY_OWNER$ = {
					culture = {
						has_cultural_parameter = high_prowess_ignores_knight_restrictions
						has_cultural_parameter = minimum_prowess_for_knights
					}
				}
				prowess >= 12
			}
			# Regula cultists can always field female combatants
			trigger_if = {
				limit = {
					$ARMY_OWNER$ = {
						is_landless_adventurer = yes
						has_realm_law = camp_purpose_regula_magistri_cult
					}
					is_female = yes
				}
			}
		}
	}
}