﻿#Controls the can_raid rule.
can_raid_trigger = {
	OR = {

		#gpt
		has_character_flag = gpt_can_raid
		AND = {
			is_ai = no
			OR = {
				highest_held_title_tier <= 3
				AND = {
					highest_held_title_tier = 4
					culture = { has_cultural_pillar = ethos_bellicose }
				}
			}
			OR = {
				government_has_flag = government_is_feudal
				government_has_flag = government_is_clan
				government_has_flag = government_is_japan_feudal
			}
		}
		AND = {
			OR = {
				AND = {
					highest_held_title_tier < 4
					highest_held_title_tier > 1
				}
				AND = {
					highest_held_title_tier = 4
					culture = { has_cultural_pillar = ethos_bellicose }
				}
			}
			OR = {
				government_has_flag = government_is_feudal
				government_has_flag = government_is_clan
				government_has_flag = government_is_japan_feudal
			}
			faith = { NOT = { has_doctrine_parameter = unreformed } }
			any_character_to_title_neighboring_county = {
				exists = root.faith
				exists = holder.faith
				NOT = { holder.liege = root.liege }
				NOT = { holder.top_liege = root.top_liege }
				holder = { 
					NOR = { government_has_flag = government_is_tribal government_has_flag = government_is_nomadic }
					OR = {
						AND = {
							OR = {
								has_relation_rival = root
								has_relation_nemesis = root
								reverse_opinion = {
									target = root
									value < -40
								}
							}
						}
						OR = {
							AND = {
								culture = { has_cultural_pillar = ethos_bellicose }
								faith = {
									faith_hostility_level = {
										target = root.faith
										value >= faith_astray_level
									}
								}
							}
							faith = {
								faith_hostility_level = {
									target = root.faith
									value >= faith_hostile_level
								}
							}
						}
					}
				}
			}
		}

		
		# Government logic.
		government_has_flag = government_can_raid_rule
		## Admin - Frontier themes
		vassal_contract_has_flag = admin_theme_can_raid
		## Clan - Ghazi
		vassal_contract_has_flag = vassal_contract_allow_raiding
		# Faith Logic.
		faith = { has_doctrine_parameter = faith_can_raid }
		# Dynasty logic.
		dynasty ?= {
			OR = {
				can_raid_dynasty_modifiers_that_enable_raiding_overseas_list_trigger = yes
				can_raid_dynasty_modifiers_that_enable_raiding_overland_list_trigger = yes
			}
		}
		# House logic.
		house ?= {
			OR = {
				can_raid_house_modifiers_that_enable_raiding_overseas_list_trigger = yes
				can_raid_house_modifiers_that_enable_raiding_overland_list_trigger = yes
			}
		}
		# Cultural logic.
		## With restrictions.
		AND = {
			can_raid_cultural_parameter_requirements_for_non_tribals_trigger = yes
			culture = {
				OR = {
					has_cultural_parameter = culture_can_raid_at_sea_even_if_feudal
					has_cultural_parameter = culture_can_raid_over_land_even_if_feudal
				}
			}
		}
		## Without restrictions.
		culture = {
			OR = {
				has_cultural_parameter = culture_can_raid_at_sea_even_if_feudal_no_restrictions
				has_cultural_parameter = culture_can_raid_over_land_even_if_feudal_no_restrictions
			}
		}
		# Trait logics.
		## With restrictions.
		AND = {
			can_raid_trait_flag_standard_requirements_trigger = yes
			has_trait_with_flag = trait_enable_raiding_per_standard_restrictions
		}
		## Without restrictions.
		has_trait_with_flag = trait_enable_raiding_without_restrictions
	}
	# Some faiths prohibit this.
	OR = {
		NOR = {
			faith = { has_doctrine_parameter = holy_wars_forbidden }
			government_has_flag = government_is_landless_adventurer
		}
		# But not for Nomads or Wanua
		government_has_flag = government_is_nomadic
		government_has_flag = government_is_wanua
	}
}


