﻿# Holy Conquest - Sanctify and Exile Holy Sites 1.1.0
# Adds to vanilla on_actions (does not replace them).

# A player gains a county that holds a holy site their faith does not venerate
on_title_gain = {
	on_actions = {
		hcq_on_title_gain
	}
}

hcq_on_title_gain = {
	trigger = {
		is_ai = no
		has_game_rule = hcq_conquest_event_on
		exists = faith
		# Not for titles inherited from our own dynasty
		NOT = { scope:previous_holder ?= { dynasty ?= root.dynasty } }
		scope:title = {
			tier = tier_county
			any_county_holy_site = {
				OR = {
					root.faith = { NOT = { is_faith_holy_site = prev } }
					any_holy_site_faith = { NOT = { this = root.faith } }
				}
			}
		}
	}
	events = {
		delay = { days = 1 }
		hcq.0001
	}
}

# AI rulers sometimes sanctify or exile holy sites (game rule)
yearly_playable_pulse = {
	on_actions = {
		hcq_ai_pulse
	}
}

hcq_ai_pulse = {
	trigger = {
		is_ai = yes
		NOT = { has_game_rule = hcq_ai_off }
		is_independent_ruler = yes
		exists = faith
		NOT = { has_character_flag = hcq_ai_cooldown }
		piety >= hcq_sanctify_piety_cost
		hcq_authority_trigger = yes
	}
	effect = {
		if = {
			limit = { has_game_rule = hcq_ai_normal }
			random = {
				chance = 15
				hcq_ai_act_effect = yes
			}
		}
		else = {
			random = {
				chance = 5
				hcq_ai_act_effect = yes
			}
		}
	}
}
