# clear_unbinding_effect
# clear_nile_flooding_effect
# banish_to_monastery_effect

# random_province_conversion_from_colonists_effect

# create_diplomacy_mystic_effect
# create_martial_mystic_effect
# create_intrigue_mystic_effect
# create_learning_mystic_effect

# set_flag_for_holy_order_modifiers_effect
# set_character_modifier_for_holy_order_flags_effect
# clear_borrowed_from_holy_order_modifier_effect
# clear_expelled_holy_order_modifier_effect

# lower_temple_tax_obligation_effect
# lower_temple_levy_obligation_effect
# move_temple_obligations_toward_balanced_effect

# give_random_tier_5_artifact_to_prev_effect
# give_random_tier_4_artifact_to_prev_effect
# give_random_tier_3_artifact_to_prev_effect
# give_random_tier_2_artifact_to_prev_effect
# give_random_tier_1_artifact_to_prev_effect

# add_foreign_influence_minor_effect
# add_foreign_influence_moderate_effect
# add_foreign_influence_major_effect
# subtract_foreign_influence_minor_effect
# subtract_foreign_influence_moderate_effect
# subtract_foreign_influence_major_effect

# spawn_good_scholar_effect
# spawn_good_steward_effect

# prev_takes_this_head_as_trophy_effect
# other_combatant_takes_this_head_as_trophy_effect
# k_acr_pagan_branch_trait_effect
# k_acr_force_convert_back
# k_acr_maybe_severely_wounded_effect
# k_acr_promethean_prosperity_effect_01
# k_acr_promethean_prosperity_effect_02
# k_acr_promethean_settlement_effect_01
# k_acr_promethean_settlement_effect_02
# acr_investiture_antipope_flags_effect
# acr_set_pagan_papal_laws_effect
# acr_set_pagan_papal_scopes_effect
# acr_druid_dryad_investiture_effect


clear_unbinding_effect = {
	clr_character_flag = unbinding_cheap_open
	clr_character_flag = unbinding_middle_open
	clr_character_flag = unbinding_grand_open
	clr_character_flag = unbinding_cheap_festivities
	clr_character_flag = unbinding_middle_festivities
	clr_character_flag = unbinding_grand_festivities
	clr_character_flag = unbinding_festival_open
	clr_character_flag = festival_event_happened
	clr_character_flag = ancrel_remove_firedancers
	clr_character_flag = unbinding_festival
	clr_character_flag = do_not_disturb
	remove_character_modifier = holding_unbinding_festival
}

clear_nile_flooding_effect = {
	remove_province_modifier = VIET_nile_flood_good
	remove_province_modifier = VIET_nile_flood_great
	remove_province_modifier = VIET_nile_flood_overflow
	remove_province_modifier = VIET_nile_flood_poor
}

banish_to_monastery_effect = {
	# expand this to allow banishing to a random holy order
	# should one exist for the (liege's?) religion
	add_ascetic_trait_effect = yes
	liege = {
		random_realm_lord = {
			limit = { is_theocracy = yes }

			move_character = PREVPREV
		}
	}
}

# requires event targets donor_province and receiver_province
# receiver_province must have province flag received_<one/two/three>_prosperity
random_province_conversion_from_colonists_effect = {
	event_target:receiver_province = {
		random_list = {
			15 = { # both religion and culture
				modifier = {
					factor = 1.2
					any_neighbor_province = {
						culture = event_target:donor_province
					}
				}
				modifier = {
					factor = 1.2
					any_neighbor_province = {
						religion = event_target:donor_province
					}
				}
				modifier = {
					factor = 2
					has_province_flag = received_two_prosperity
				}
				modifier = {
					factor = 5
					has_province_flag = received_three_prosperity
				}

				culture = event_target:donor_province
				religion = event_target:donor_province
			}
			20 = { # culture
				modifier = {
					factor = 1.2
					any_neighbor_province = {
						culture = event_target:donor_province
					}
				}
				modifier = {
					factor = 1.5
					has_province_flag = received_two_prosperity
				}
				modifier = {
					factor = 2
					has_province_flag = received_three_prosperity
				}

				culture = event_target:donor_province
			}
			25 = { # religion
				modifier = {
					factor = 1.2
					any_neighbor_province = {
						religion = event_target:donor_province
					}
				}
				modifier = {
					factor = 1.5
					has_province_flag = received_two_prosperity
				}
				modifier = {
					factor = 2
					has_province_flag = received_three_prosperity
				}

				religion = event_target:donor_province
			}
			50 = { # nothing!
			}
		}

		clr_province_flag = received_one_prosperity
		clr_province_flag = received_two_prosperity
		clr_province_flag = received_three_prosperity
	}
}

create_diplomacy_mystic_effect = {
	random_list = {
		25 = {
			create_character = {
				random_traits = no
				name = "Idunn"
				dna = chaehghfacw
				dynasty = none
				religion = norse_pagan
				culture = norse
				female = yes
				age = 17
				health = 15
				add_trait = grey_eminence
				add_trait = gregarious
				add_trait = mystic
				add_trait = lustful
				add_trait = charitable
				add_trait = attractive
				add_trait = trusting
				add_trait = poet
			}
		}
		25 = {
			create_character = {
				name = "Elphame"
				random_traits = no
				dynasty = none
				religion = celtic_pagan
				culture = pictish
				female = yes
				age = 17
				health = 15
				add_trait = grey_eminence
				add_trait = gregarious
				add_trait = mystic
				add_trait = changeling
				add_trait = lustful
				add_trait = patient
				add_trait = attractive
				add_trait = paranoid
				add_trait = poet
			}
		}
		25 = {
			create_character = {
				random_traits = no
				name = "Nestor"
				dynasty = none
				religion = hellenic_pagan
				culture = greek
				female = no
				age = 62
				health = 15
				add_trait = grey_eminence
				add_trait = gregarious
				add_trait = mystic
				add_trait = charitable
				add_trait = attractive
				add_trait = trusting
				add_trait = poet
			}
		}
	}
	new_character = {
		set_character_flag = eternal_life_mystic
		if = {
			limit = {
				is_female = yes
			}
			give_nickname = nick_the_youthful
			set_character_flag = immortal_mystic_idunn
		} 
		else = {
			give_nickname = nick_the_wise
			set_character_flag = immortal_mystic_nestor
		}
		save_event_target_as = eternal_life_mystic
		will_not_marry_effect = yes
		set_character_flag = no_court_invites
		random_list = {
			90 = { set_character_flag = mystic_is_fraud }

			10 = {
				mult_modifier = {
					factor = 1.4
					ROOT = { diplomacy >= 10 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { diplomacy >= 13 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { diplomacy >= 16 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { diplomacy >= 19 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { diplomacy >= 22 }
				}

				change_diplomacy = 6
			}
		}
	}
}

create_martial_mystic_effect = {
	random_list = {
		25 = {
			create_character = {
				random_traits = no
				dynasty = none
				religion = west_african_pagan
				culture = mande
				female = yes
				age = 36
				health = 15
				add_trait = brilliant_strategist
				add_trait = mystic
				add_trait = brawny
				add_trait = wroth
				add_trait = diligent
				add_trait = proud
				add_trait = brave
				add_trait = aggressive_leader
			}
		}
		25 = {
			create_character = {
				random_traits = no
				name = "Atalanta"
				dna = chaehghfacw
				dynasty = none
				religion = hellenic_pagan
				culture = greek
				female = yes
				age = 36
				health = 15
				add_trait = brilliant_strategist
				add_trait = mystic
				add_trait = brawny
				add_trait = wroth
				add_trait = diligent
				add_trait = proud
				add_trait = brave
				add_trait = unyielding_leader
			}
		}
		25 = {
			create_character = {
				random_traits = no
				name = "Boudicca"
				dna = chaehghfacw
				dynasty = none
				religion = celtic_pagan
				culture = welsh
				female = yes
				age = 36
				health = 15
				add_trait = brilliant_strategist
				add_trait = mystic
				add_trait = brawny
				add_trait = wroth
				add_trait = diligent
				add_trait = proud
				add_trait = brave
				add_trait = inspiring_leader
			}
		}
		25 = {
			create_character = {
				random_traits = no
				name = "Obelix"
				religion = celtic_pagan
				culture = gaulish
				female = no
				age = 36
				health = 15
				add_trait = brilliant_strategist
				add_trait = mystic
				add_trait = giant
				add_trait = strong
				add_trait = brawny
				add_trait = wroth
				add_trait = kind
				add_trait = trusting
				add_trait = diligent
				add_trait = proud
				add_trait = brave
				add_trait = light_foot_leader
			}
		}
		25 = {
			create_character = {
				random_traits = no
				dynasty = none
				religion = hellenic_pagan
				culture = greek
				female = no
				age = 31
				health = 15
				add_trait = brilliant_strategist
				add_trait = mystic
				add_trait = brawny
				add_trait = wroth
				add_trait = diligent
				add_trait = proud
				add_trait = brave
				add_trait = heavy_infantry_leader
			}
		}
	}
	new_character = {
		set_character_flag = eternal_life_mystic 

		will_not_marry_effect = yes

		if = {
			limit = {
				culture = greek
				is_female = no
			}
			give_nickname = nick_the_spartan
			set_character_flag = immortal_mystic_spartan
		} 
		else = {
			give_nickname = nick_the_fearless
			if = {
				limit = { is_female = no }
				set_character_flag = immortal_mystic_gaul
			}
			else = {
				set_character_flag = immortal_mystic_amina
			}
		}
		if = {
			limit = { religion = celtic_pagan }
			set_character_flag = immortal_mystic_no_bloodline
		}
		if = {
			limit = { trait = giant }
			gain_weight_large_effect = yes
			gain_weight_large_effect = yes
			gain_weight_large_effect = yes
			add_trait = fat
			character_event = { id = HFP.20600 } # Notification: I am fat
			set_character_flag = str_AA
			set_character_flag = str_BB
			set_character_flag = str_CC
			clr_character_flag = str_Aa
			clr_character_flag = str_Bb
			clr_character_flag = str_Cc
			clr_character_flag = str_aa
			clr_character_flag = str_bb
			clr_character_flag = str_cc
			set_character_flag = hgt_AA
			set_character_flag = hgt_BB
			set_character_flag = hgt_CC
			clr_character_flag = hgt_Aa
			clr_character_flag = hgt_Bb
			clr_character_flag = hgt_Cc
			clr_character_flag = hgt_aa
			clr_character_flag = hgt_bb
			clr_character_flag = hgt_cc
			set_character_flag = dwarf_AA
			set_character_flag = dwarf_BB
			set_character_flag = dwarf_CC
			clr_character_flag = dwarf_Aa
			clr_character_flag = dwarf_Bb
			clr_character_flag = dwarf_Cc
			clr_character_flag = dwarf_aa
			clr_character_flag = dwarf_bb
			clr_character_flag = dwarf_cc
		}
		save_event_target_as = eternal_life_mystic
		will_not_marry_effect = yes
		set_character_flag = no_court_invites

		random_list = {
			50 = { add_scarred_high_effect = yes }
			50 = { add_maimed_trait_effect = yes }
		}

		random_list = {
			90 = { set_character_flag = mystic_is_fraud }

			10 = {
				mult_modifier = {
					factor = 1.4
					ROOT = { martial >= 10 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { martial >= 13 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { martial >= 16 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { martial >= 19 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { martial >= 22 }
				}

				change_martial = 6
			}
		}
	}
}

create_intrigue_mystic_effect = {
	random_list = {
		25 = {
			create_character = {
				name = "Cleopatra"
				random_traits = no
				dynasty = none
				religion = egyptian_pagan
				culture = coptic
				race = greek
				female = yes
				age = 34
				health = 15
				add_trait = elusive_shadow
				add_trait = mystic
				add_trait = attractive
				add_trait = proud
				add_trait = paranoid
				add_trait = ambitious
				add_trait = deceitful
				add_trait = erudite		
			}
		}
		25 = {
			create_character = {
				random_traits = no
				name = "Morgana"
				dna = aefccojcgbd
				dynasty = none
				religion = celtic_pagan
				culture = welsh
				female = yes
				age = 27
				health = 15
				add_trait = elusive_shadow
				add_trait = changeling
				add_trait = mystic
				add_trait = ambitious
				add_trait = cruel
				add_trait = lustful
				add_trait = envious
				add_trait = genius
				add_trait = deceitful
				add_trait = attractive
				add_trait = poet
			}
		}
		25 = {
			create_character = {
				name = "Cassandra"
				random_traits = no
				dynasty = none
				religion = titan_pagan
				culture = greek
				female = yes
				age = 72
				health = 15
				add_trait = elusive_shadow
				add_trait = mystic
				add_trait = hunchback
				add_trait = shrewd
				add_trait = proud
				add_trait = paranoid
				add_trait = ambitious
				add_trait = honest
				add_trait = erudite
			}
		}
		25 = {
			create_character = {
				random_traits = no
				dynasty = none
				religion = hurufi
				culture = bedouin_arabic
				female = yes
				age = 72
				health = 15
				add_trait = elusive_shadow
				add_trait = mystic
				add_trait = hunchback
				add_trait = slothful
				add_trait = proud
				add_trait = paranoid
				add_trait = ambitious
				add_trait = deceitful
				add_trait = erudite		
			}
		}
	}
	new_character = {
		set_character_flag = eternal_life_mystic
		give_nickname = nick_the_alchemist
		save_event_target_as = eternal_life_mystic
		will_not_marry_effect = yes
		set_character_flag = no_court_invites
		if = {
			limit = { NOT = { age = 50 } }
			set_character_flag = immortal_mystic_cleopatra
		}
		else = {
			set_character_flag = immortal_mystic_hunchback
		}

		random_list = {
			90 = { set_character_flag = mystic_is_fraud }

			10 = {
				mult_modifier = {
					factor = 1.4
					ROOT = { intrigue >= 10 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { intrigue >= 13 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { intrigue >= 16 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { intrigue >= 19 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { intrigue >= 22 }
				}

				change_intrigue = 6
			}
		}
	}
}

create_learning_mystic_effect = {
	random_list = {
		25 = {
			create_character = {
				random_traits = no
				dynasty = none
				religion = buddhist
				culture = sinhala
				female = yes
				age = 9
				health = 15
				add_trait = mystic
				add_trait = brahmin
				add_trait = theravada_buddhist
				add_trait = quick
				add_trait = fussy
				add_trait = conscientious
			}
		}
		25 = {
			create_character = {
				random_traits = no
				name = "Seneca"
				dynasty = none
				religion = promethean_pagan
				culture = roman
				female = no
				age = 72
				health = 15
				add_trait = mystic
				add_trait = genius
				add_trait = stoic
				add_trait = mastermind_theologian
				add_trait = chaste
				add_trait = diligent
			}
		}
		25 = {
			create_character = {
				random_traits = no
				name = "Lucan"
				dynasty = none
				religion = hellenic_pagan
				culture = roman
				female = no
				age = 25
				health = 15
				add_trait = poet
				add_trait = genius
				add_trait = mastermind_theologian
				add_trait = attractive
				add_trait = stoic
				add_trait = diligent
				add_trait = proud
			}
		}
	}

	new_character = {
		set_character_flag = eternal_life_mystic
		remove_trait = kshatriya
		remove_trait = vaishya
		remove_trait = vajrayana_buddhist
		remove_trait = mahayana_buddhist
		trigger_switch = {
			on_trigger = religion
			promethean_pagan = { give_nickname = nick_the_younger set_character_flag = immortal_mystic_lucan }
			hellenic_pagan = { give_nickname = nick_the_elder set_character_flag = immortal_mystic_seneca }
			buddhist = { give_nickname = nick_the_gentle set_character_flag = immortal_mystic_achala }
		}
		change_diplomacy = 2
		change_stewardship = 2
		change_intrigue = -1
		save_event_target_as = eternal_life_mystic
		will_not_marry_effect = yes
		set_character_flag = no_court_invites

		random_list = {
			90 = { set_character_flag = mystic_is_fraud }

			10 = {
				mult_modifier = {
					factor = 1.4
					ROOT = { learning >= 10 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { learning >= 13 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { learning >= 16 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { learning >= 19 }
				}

				mult_modifier = {
					factor = 1.4
					ROOT = { learning >= 22 }
				}

				change_learning = 15
			}
		}
	}
}

# will set appropriate character flags
# if the target character has a
# "Borrowed from $holy_order" or "Expelled $holy_order" 
# character modifier. This makes generic holy order
# events actually work, without even uglier hacks
set_flag_for_holy_order_modifiers_effect = {
	# Extant Loan
	if = {
		limit = { has_character_modifier = borrowed_from_d_fianna }
		set_character_flag = borrowed_from_d_fianna
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_red_dragons }
		set_character_flag = borrowed_from_d_red_dragons
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_anubis }
		set_character_flag = borrowed_from_d_anubis
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_horus }
		set_character_flag = borrowed_from_d_horus
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_legio_hellenica }
		set_character_flag = borrowed_from_d_legio_hellenica
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_sacred_band }
		set_character_flag = borrowed_from_d_sacred_band
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_sickles }
		set_character_flag = borrowed_from_d_sickles
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_burning_blades }
		set_character_flag = borrowed_from_d_burning_blades
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_men_of_steel }
		set_character_flag = borrowed_from_d_men_of_steel
	}
	if = {
		limit = { has_character_modifier = borrowed_from_d_saint_boudicca }
		set_character_flag = borrowed_from_d_saint_boudicca
	}

	# Expelled from the Realm
	if = {
		limit = { has_character_modifier = expelled_d_fianna }
		set_character_flag = expelled_d_fianna
	}
	if = {
		limit = { has_character_modifier = expelled_d_red_dragons }
		set_character_flag = expelled_d_red_dragons
	}
	if = {
		limit = { has_character_modifier = expelled_d_anubis }
		set_character_flag = expelled_d_anubis
	}
	if = {
		limit = { has_character_modifier = expelled_d_horus }
		set_character_flag = expelled_d_horus
	}
	if = {
		limit = { has_character_modifier = expelled_d_legio_hellenica }
		set_character_flag = expelled_d_legio_hellenica
	}
	if = {
		limit = { has_character_modifier = expelled_d_sacred_band }
		set_character_flag = expelled_d_sacred_band
	}
	if = {
		limit = { has_character_modifier = expelled_d_sickles }
		set_character_flag = expelled_d_sickles
	}
	if = {
		limit = { has_character_modifier = expelled_d_burning_blades }
		set_character_flag = expelled_d_burning_blades
	}
	if = {
		limit = { has_character_modifier = expelled_d_men_of_steel }
		set_character_flag = expelled_d_men_of_steel
	}
	if = {
		limit = { has_character_modifier = expelled_d_saint_boudicca }
		set_character_flag = expelled_d_saint_boudicca
	}
}

# opposite of set_flag, this will check for the right
# flags and apply the corresponding modifier, if the
# character doesn't already have that modifier
set_character_modifier_for_holy_order_flags_effect = {
	# Extant Loan
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_fianna }
			has_character_flag = borrowed_from_d_fianna
		}
		add_character_modifier = { 
			name = borrowed_from_d_fianna
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_red_dragons }
			has_character_flag = borrowed_from_d_red_dragons
		}
		add_character_modifier = { 
			name = borrowed_from_d_red_dragons
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_anubis }
			has_character_flag = borrowed_from_d_anubis
		}
		add_character_modifier = { 
			name = borrowed_from_d_anubis
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_horus }
			has_character_flag = borrowed_from_d_horus
		}
		add_character_modifier = { 
			name = borrowed_from_d_horus
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_legio_hellenica }
			has_character_flag = borrowed_from_d_legio_hellenica
		}
		add_character_modifier = { 
			name = borrowed_from_d_legio_hellenica
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_sacred_band }
			has_character_flag = borrowed_from_d_sacred_band
		}
		add_character_modifier = { 
			name = borrowed_from_d_sacred_band
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_sickles }
			has_character_flag = borrowed_from_d_sickles
		}
		add_character_modifier = { 
			name = borrowed_from_d_sickles
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_burning_blades }
			has_character_flag = borrowed_from_d_burning_blades
		}
		add_character_modifier = { 
			name = borrowed_from_d_burning_blades
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_men_of_steel }
			has_character_flag = borrowed_from_d_men_of_steel
		}
		add_character_modifier = { 
			name = borrowed_from_d_men_of_steel
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = borrowed_from_d_saint_boudicca }
			has_character_flag = borrowed_from_d_saint_boudicca
		}
		add_character_modifier = { 
			name = borrowed_from_d_saint_boudicca
			duration = -1
			inherit = yes
		}
	}

	# Expelled from the Realm
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_fianna }
			has_character_flag = expelled_d_fianna
		}
		add_character_modifier = { 
			name = expelled_d_fianna
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_red_dragons }
			has_character_flag = expelled_d_red_dragons
		}
		add_character_modifier = { 
			name = expelled_d_red_dragons
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_anubis }
			has_character_flag = expelled_d_anubis
		}
		add_character_modifier = { 
			name = expelled_d_anubis
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_horus }
			has_character_flag = expelled_d_horus
		}
		add_character_modifier = { 
			name = expelled_d_horus
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_legio_hellenica }
			has_character_flag = expelled_d_legio_hellenica
		}
		add_character_modifier = { 
			name = expelled_d_legio_hellenica
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_sacred_band }
			has_character_flag = expelled_d_sacred_band
		}
		add_character_modifier = { 
			name = expelled_d_sacred_band
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_sickles }
			has_character_flag = expelled_d_sickles
		}
		add_character_modifier = { 
			name = expelled_d_sickles
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_burning_blades }
			has_character_flag = expelled_d_burning_blades
		}
		add_character_modifier = { 
			name = expelled_d_burning_blades
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_men_of_steel }
			has_character_flag = expelled_d_men_of_steel
		}
		add_character_modifier = { 
			name = expelled_d_men_of_steel
			duration = -1
			inherit = yes
		}
	}
	if = {
		limit = {
			NOT = { has_character_modifier = expelled_d_saint_boudicca }
			has_character_flag = expelled_d_saint_boudicca
		}
		add_character_modifier = { 
			name = expelled_d_saint_boudicca
			duration = -1
			inherit = yes
		}
	}	
}

# requires event_target:holy_order to be defined
clear_borrowed_from_holy_order_modifier_effect = {
	clr_character_flag = borrowed_from_@event_target:holy_order
	
	event_target:holy_order = {
		holder_scope = {
			trigger_switch = { 
				on_trigger = title
				d_fianna = { PREVPREV = { remove_character_modifier = borrowed_from_d_fianna } }
				d_red_dragons = { PREVPREV = { remove_character_modifier = borrowed_from_d_red_dragons } }
				d_anubis = { PREVPREV = { remove_character_modifier = borrowed_from_d_anubis } }
				d_horus = {	PREVPREV = { remove_character_modifier = borrowed_from_d_horus } }
				d_legio_hellenica = { PREVPREV = { remove_character_modifier = borrowed_from_d_legio_hellenica } }
				d_sacred_band = { PREVPREV = { remove_character_modifier = borrowed_from_d_sacred_band } }
				d_sickles = { PREVPREV = { remove_character_modifier = borrowed_from_d_sickles } }
				d_burning_blades = { PREVPREV = { remove_character_modifier = borrowed_from_d_burning_blades } }
				d_men_of_steel = { PREVPREV = { remove_character_modifier = borrowed_from_d_men_of_steel } }
				d_saint_boudicca = { PREVPREV = { remove_character_modifier = borrowed_from_d_saint_boudicca }}
			}
		}
	}
}

# requires event_target:holy_order to be defined
clear_expelled_holy_order_modifier_effect = {
	clr_character_flag = expelled_@event_target:holy_order
	
	event_target:holy_order = {
		holder_scope = {
			trigger_switch = { 
				on_trigger = title
				d_fianna = { PREVPREV = { remove_character_modifier = expelled_d_fianna } }
				d_red_dragons = { PREVPREV = { remove_character_modifier = expelled_d_red_dragons } }
				d_anubis = { PREVPREV = { remove_character_modifier = expelled_d_anubis } }
				d_horus = { PREVPREV = { remove_character_modifier = expelled_d_horus } }
				d_legio_hellenica = { PREVPREV = { remove_character_modifier = expelled_d_legio_hellenica } }
				d_sacred_band = { PREVPREV = { remove_character_modifier = expelled_d_sacred_band } }
				d_sickles = { PREVPREV = { remove_character_modifier = expelled_d_sickles } }
				d_burning_blades = { PREVPREV = { remove_character_modifier = expelled_d_burning_blades } }
				d_men_of_steel = { PREVPREV = { remove_character_modifier = expelled_d_men_of_steel } }
				d_saint_boudicca = { PREVPREV = { remove_character_modifier = expelled_d_saint_boudicca }}
			}
		}
	}
}

lower_temple_tax_obligation_effect = {
	if = {
		limit = { has_law = temple_tax_1 }
		add_law = temple_tax_0
	}
	if = {
		limit = { has_law = temple_tax_2 }
		add_law = temple_tax_1
	}
	if = {
		limit = { has_law = temple_tax_3 }
		add_law = temple_tax_2
	}
}

lower_temple_levy_obligation_effect = {
	if = {
		limit = { has_law = temple_contract_1 }
		add_law = temple_contract_0
	}
	if = {
		limit = { has_law = temple_contract_2 }
		add_law = temple_contract_1
	}
	if = {
		limit = { has_law = temple_contract_3 }
		add_law = temple_contract_2
	}
}

move_temple_obligations_toward_balanced_effect = {
	if = {
		limit = { has_law = tax_levy_law_theocracy_3 }
		add_law = tax_levy_law_theocracy_4
	}
	if = {
		limit = { has_law = tax_levy_law_theocracy_2 }
		add_law = tax_levy_law_theocracy_3
	}
	if = {
		limit = { has_law = tax_levy_law_theocracy_1 }
		add_law = tax_levy_law_theocracy_2
	}
	if = {
		limit = { has_law = tax_levy_law_theocracy_0 }
		add_law = tax_levy_law_theocracy_1
	}

	if = {
		limit = { has_law = tax_levy_law_theocracy_5 }
		add_law = tax_levy_law_theocracy_4
	}
	if = {
		limit = { has_law = tax_levy_law_theocracy_6 }
		add_law = tax_levy_law_theocracy_5
	}
	if = {
		limit = { has_law = tax_levy_law_theocracy_7 }
		add_law = tax_levy_law_theocracy_6
	}
	if = {
		limit = { has_law = tax_levy_law_theocracy_8 }
		add_law = tax_levy_law_theocracy_7
	}
}

give_random_tier_5_artifact_to_prev_effect = {
	random_list = {
		25 = {
			add_artifact = silver_hand_of_nuada
		}
		25 = {
			add_artifact = trident_of_britannia
		}
		25 = {
			add_artifact = helm_of_britannia
		}
		25 = {
			add_artifact = shield_of_britannia
		}
	}

	new_artifact = {
		set_creation_date = 1.1.1
		transfer_artifact = {
			from = PREV
			to = PREVPREV
		}
	}
}

give_random_tier_4_artifact_to_prev_effect = {
	random_list = {
		50 = {
			add_artifact = skull_of_brigid
		}
		50 = {
			add_artifact = horn_of_bran_galed
		}
	}

	new_artifact = {
		set_creation_date = 1.1.1
		transfer_artifact = {
			from = PREV
			to = PREVPREV
		}
	}
}

give_random_tier_3_artifact_to_prev_effect = {
	random_list = {
		25 = {
			add_artifact = tusk_of_torc_triath
		}
	}
	
	new_artifact = {
		set_creation_date = 1.1.1
		transfer_artifact = {
			from = PREV
			to = PREVPREV
		}
	}
}

give_random_tier_2_artifact_to_prev_effect = {
	random_list = {
		25 = {
			add_artifact = torque_of_boudicca
		}
		25 = {
			add_artifact = old_carnyx
		}
		25 = {
			add_artifact = horned_helm
		}
		25 = {
			add_artifact = battersea_shield
		}
	}
	
	new_artifact = {
		set_creation_date = 1.1.1
		transfer_artifact = {
			from = PREV
			to = PREVPREV
		}
	}
}

give_random_tier_1_artifact_to_prev_effect = {
	random_list = {
		10 = {
			add_artifact = famous_tongue
		}
		10 = {
			add_artifact = famous_head
		}
		10 = {
			add_artifact = infamous_tongue
		}
		10 = {
			add_artifact = famous_hand
		}
		10 = {
			add_artifact = famous_arm
		}
		10 = {
			add_artifact = famous_foot
		}
		10 = {
			add_artifact = famous_ancient_weapon
		}
	}

	new_artifact = {
		set_creation_date = 1.1.1
		transfer_artifact = {
			from = PREV
			to = PREVPREV
		}
	}
}

add_foreign_influence_minor_effect = {
	custom_tooltip = {
		text = foreign_influence_grows_minor_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = foreign_influence value = 5 }
			if = {
				limit = {
					NOT = {
						has_province_modifier = acr_foreign_influence
					}
				}
				add_province_modifier = { name = acr_foreign_influence duration = -1 }
			}
		}
	}
}

add_foreign_influence_moderate_effect = {
	custom_tooltip = {
		text = foreign_influence_grows_moderate_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = foreign_influence value = 10 }
			if = {
				limit = {
					NOT = {
						has_province_modifier = acr_foreign_influence
					}
				}
				add_province_modifier = { name = acr_foreign_influence duration = -1 }
			}
		}
	}
}

add_foreign_influence_major_effect = {
	custom_tooltip = {
		text = foreign_influence_grows_major_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = foreign_influence value = 20 }
			if = {
				limit = {
					NOT = {
						has_province_modifier = acr_foreign_influence
					}
				}
				add_province_modifier = { name = acr_foreign_influence duration = -1 }
			}
		}
	}
}

subtract_foreign_influence_minor_effect = {
	custom_tooltip = {
		text = foreign_influence_declines_minor_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = foreign_influence value = -5 }
			if = {
				limit = {
					NOT = { check_variable = { which = foreign_influence value = 1 } }
				}
				remove_province_modifier = acr_foreign_influence
				set_variable = { which = foreign_influence value = 0 }
			}
		}
	}
}

subtract_foreign_influence_moderate_effect = {
	custom_tooltip = {
		text = foreign_influence_declines_moderate_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = foreign_influence value = -10 }
			if = {
				limit = {
					NOT = { check_variable = { which = foreign_influence value = 1 } }
				}
				remove_province_modifier = acr_foreign_influence
				set_variable = { which = foreign_influence value = 0 }
			}
		}
	}
}

subtract_foreign_influence_major_effect = {
	custom_tooltip = {
		text = foreign_influence_declines_major_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = foreign_influence value = -20 }
			if = {
				limit = {
					NOT = { check_variable = { which = foreign_influence value = 1 } }
				}
				remove_province_modifier = acr_foreign_influence
				set_variable = { which = foreign_influence value = 0 }
			}
		}
	}
}

spawn_good_scholar_effect = {

	if = { 
		limit = { has_religion_feature = religion_matriarchal }
		create_random_priest = {
			random_traits = yes
			dynasty = actually_culture
			female = yes
			attributes = {
				diplomacy = 2
				learning = 8
				stewardship = 2
				intrigue = 2
				martial = 2
			}
		}
	}
	if = { 
		limit = { NOT = { has_religion_feature = religion_matriarchal } }
		create_random_priest = {
			random_traits = yes
			dynasty = actually_culture
			female = no
			attributes = {
				diplomacy = 2
				learning = 8
				stewardship = 2
				intrigue = 2
				martial = 2
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		remove_trait = dwarf
		remove_trait = giant
		remove_trait = hunchback
		remove_trait = clubfooted
		remove_trait = craven
		remove_trait = paranoid
		
		remove_lifestyle_trait_effect = yes
		clear_education_trait = yes
		
		random_list = {
			 5 = { add_trait = dutiful_cleric }
			20 = { add_trait = scholarly_theologian }
			75 = { add_trait = mastermind_theologian }
		}

		random_list = {
			27 = {
				add_trait = shrewd
			}
			3 = {
				add_trait = quick
			}
			70 = {
				change_diplomacy = 1
			}
		}
		
		hidden_tooltip = {
			if = {
				limit = {
					has_dharmic_religion_trigger = yes
				}
				add_trait = brahmin
				character_event = { id = RoI.30121 }
			}
			if = {
				limit = {
					OR = {
						religion_openly_in_hellenic_subgroup_trigger = yes
						has_religion_feature = religion_astrology
					}
				}

				add_western_zodiac_trait_effect = yes
			}
			if = {
				limit = {
					has_religion_feature = religion_no_leader
					religion_group = pagan_group
				}
				if = {
					limit = { has_global_flag = acr_mpb }
					random_list = {
						 5 = { add_trait = pagan_branch_1 }
						25 = { add_trait = pagan_branch_2 }
						25 = { add_trait = pagan_branch_3 }
						25 = { add_trait = pagan_branch_4 }
						25 = { add_trait = pagan_branch_5_animist }
						25 = { add_trait = pagan_branch_6_theist }
						25 = { add_trait = pagan_branch_7_intellect }
						25 = { add_trait = pagan_branch_8_might }
						 5 = { add_trait = pagan_branch_9_egoist }
						 5 = { add_trait = pagan_branch_10_altruist }
					}
				}
				else = {
					random_list = {
						 5 = { add_trait = pagan_branch_1 }
						25 = { add_trait = pagan_branch_2 }
						25 = { add_trait = pagan_branch_3 }
						25 = { add_trait = pagan_branch_4 }
					}
				}
			}
		}
		set_character_flag = invited_soldier
		save_event_target_as = invited_character
	}
}

spawn_good_steward_effect = {

	if = { 
		limit = { has_religion_feature = religion_matriarchal }
		create_random_steward = {
			random_traits = yes
			dynasty = actually_culture
			female = yes
			attributes = {
				diplomacy = 2
				learning = 2
				stewardship = 8
				intrigue = 2
				martial = 2
			}
		}
	}
	if = { 
		limit = { NOT = { has_religion_feature = religion_matriarchal } }
		create_random_steward = {
			random_traits = yes
			dynasty = actually_culture
			female = no
			attributes = {
				diplomacy = 2
				learning = 4
				stewardship = 8
				intrigue = 2
				martial = 2
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		remove_trait = dwarf
		remove_trait = giant
		remove_trait = hunchback
		remove_trait = clubfooted
		remove_trait = craven
		remove_trait = paranoid
		
		remove_lifestyle_trait_effect = yes
		clear_education_trait = yes
		
		random_list = {
			 5 = { add_trait = thrifty_clerk }
			20 = { add_trait = fortune_builder }
			75 = { add_trait = midas_touched }
		}

		random_list = {
			27 = {
				add_trait = shrewd
			}
			3 = {
				add_trait = quick
			}
			70 = {
				change_diplomacy = 1
			}
		}
		
		hidden_tooltip = {
			if = {
				limit = {
					has_dharmic_religion_trigger = yes
				}
				add_trait = vaishya
				character_event = { id = RoI.30121 }
			}
			if = {
				limit = {
					OR = {
						religion_openly_in_hellenic_subgroup_trigger = yes
						has_religion_feature = religion_astrology
					}
				}

				add_western_zodiac_trait_effect = yes
			}
			if = {
				limit = {
					has_religion_feature = religion_no_leader
					religion_group = pagan_group
				}
				if = {
					limit = { has_global_flag = acr_mpb }
					random_list = {
						 5 = { add_trait = pagan_branch_1 }
						25 = { add_trait = pagan_branch_2 }
						25 = { add_trait = pagan_branch_3 }
						25 = { add_trait = pagan_branch_4 }
						25 = { add_trait = pagan_branch_5_animist }
						25 = { add_trait = pagan_branch_6_theist }
						25 = { add_trait = pagan_branch_7_intellect }
						25 = { add_trait = pagan_branch_8_might }
						 5 = { add_trait = pagan_branch_9_egoist }
						 5 = { add_trait = pagan_branch_10_altruist }
					}
				}
				else = {
					random_list = {
						 5 = { add_trait = pagan_branch_1 }
						25 = { add_trait = pagan_branch_2 }
						25 = { add_trait = pagan_branch_3 }
						25 = { add_trait = pagan_branch_4 }
					}
				}
			}
		}
		set_character_flag = invited_soldier
		save_event_target_as = invited_character
	}
}

prev_takes_this_head_as_trophy_effect = {
	if = { # an honest-to-gods immortal person
		limit = { immortal = yes }
		PREV = { add_artifact = immortal_skull }
		new_artifact = {
			set_name = immortal_head_name
			set_description = immortal_head_desc
		}
	}
	else_if = { # the reborn alexander the great
		limit = {
			any_owned_bloodline = {
				has_bloodline_flag = bloodline_alexander
				founder = { character = PREVPREV }
			}
		}
		PREV = { add_artifact = alexanders_skull }
		new_artifact = {
			set_name = alexander_head_name
			set_description = alexander_head_desc
		}
	}
	else_if = { # Charlemagne, post-HRE
		limit = {
			character = 6392
			has_landed_title = e_hre
		}
		PREV = { add_artifact = karl_skull2 }
	}
	else_if = { # a religious head
		limit = { controls_religion = yes }
		PREV = { add_artifact = great_priest_skull }
		new_artifact = {
			set_name = great_priest_head_name
			set_description = great_priest_head_desc
		}
	}
	else_if = { # restored roman emperor
		limit = { has_landed_title = e_roman_empire }
		PREV = { add_artifact = true_roman_skull }
		new_artifact = {
			set_name = roman_head_name
			set_description = roman_head_desc
		}
	}
	else_if = { # roman successor emperor
		limit = {
			OR = {
				has_landed_title = e_hre
				has_landed_title = e_latin_empire
				has_landed_title = e_byzantium
			}
		}
		PREV = { add_artifact = roman_pretender_skull }
		new_artifact = {
			set_name = roman_pretender_head_name
			set_description = roman_pretender_head_desc
		}
	}
	else_if = { # William the Conqueror, so long as he's a king
		limit = {
			character = 140
			higher_real_tier_than = DUKE
		}
		PREV = { add_artifact = williams_skull }
		new_artifact = {
			set_name = williams_head_name
			set_description = williams_head_desc
		}
	}
	else_if = { # super famous, Exalted
		limit = { prestige > 5000 }
		PREV = { add_artifact = prestige_skull2 }
		new_artifact = {
			set_name = prestige_head2_name
			set_description = prestige_head2_desc
		}
	}
	else_if = { # super pious, Sanctified
		limit = { piety > 5000 }
		PREV = { add_artifact = piety_skull2 }
		new_artifact = {
			set_name = piety_head2_name
			set_description = piety_head2_desc
		}
	}
	else_if = { # porphyrogenitos
		limit = { trait = born_in_the_purple }
		PREV = { add_artifact = purple_skull }
		new_artifact = {
			set_name = purple_head_name
			set_description = purple_head_desc
		}
	}
	else_if = { # pretty famous
		limit = { prestige > 1000 }
		PREV = { add_artifact = prestige_skull1 }
		new_artifact = {
			set_name = prestige_head1_name
			set_description = prestige_head1_desc
		}
	}
	else_if = { # pretty pious
		limit = { piety > 1000 }
		PREV = { add_artifact = piety_skull1 }
		new_artifact ={
			set_name = piety_head1_name
			set_description = piety_head1_desc
		}
	}
	else = { # schmuck
		PREV = { add_artifact = schmuck_skull }
		new_artifact = {
			set_name = schmuck_head_name
		}
	}
}

other_combatant_takes_this_head_as_trophy_effect = {
	if = { # an honest-to-gods immortal person
		limit = { immortal = yes }
		event_target:other_combatant = { add_artifact = immortal_skull }
		new_artifact = {
			set_name = immortal_head_name
			set_description = immortal_head_desc
		}
	}
	else_if = { # the reborn alexander the great
		limit = {
			any_owned_bloodline = {
				has_bloodline_flag = bloodline_alexander
				founder = { character = ROOT }
			}
		}
		event_target:other_combatant = { add_artifact = alexanders_skull }
		new_artifact = {
			set_name = alexander_head_name
			set_description = alexander_head_desc
		}
	}
	else_if = { # Charlemagne, post-HRE
		limit = {
			character = 6392
			has_landed_title = e_hre
		}
		event_target:other_combatant = { add_artifact = karl_skull2 }
	}
	else_if = { # a religious head
		limit = { controls_religion = yes }
		event_target:other_combatant = { add_artifact = great_priest_skull }
		new_artifact = {
			set_name = great_priest_head_name
			set_description = great_priest_head_desc
		}
	}
	else_if = { # restored roman emperor
		limit = { has_landed_title = e_roman_empire }
		event_target:other_combatant = { add_artifact = true_roman_skull }
		new_artifact = {
			set_name = roman_head_name
			set_description = roman_head_desc
		}
	}
	else_if = { # roman successor emperor
		limit = {
			OR = {
				has_landed_title = e_hre
				has_landed_title = e_latin_empire
				has_landed_title = e_byzantium
			}
		}
		event_target:other_combatant = { add_artifact = roman_pretender_skull }
		new_artifact = {
			set_name = roman_pretender_head_name
			set_description = roman_pretender_head_desc
		}
	}
	else_if = { # William the Conqueror, so long as he's a king
		limit = {
			character = 140
			higher_real_tier_than = DUKE
		}
		event_target:other_combatant = { add_artifact = williams_skull }
		new_artifact = {
			set_name = williams_head_name
			set_description = williams_head_desc
		}
	}
	else_if = { # super famous, Exalted
		limit = { prestige > 5000 }
		event_target:other_combatant = { add_artifact = prestige_skull2 }
		new_artifact = {
			set_name = prestige_head2_name
			set_description = prestige_head2_desc
		}
	}
	else_if = { # super pious, Sanctified
		limit = { piety > 5000 }
		event_target:other_combatant = { add_artifact = piety_skull2 }
		new_artifact = {
			set_name = piety_head2_name
			set_description = piety_head2_desc
		}
	}
	else_if = { # porphyrogenitos
		limit = { trait = born_in_the_purple }
		event_target:other_combatant = { add_artifact = purple_skull }
		new_artifact = {
			set_name = purple_head_name
			set_description = purple_head_desc
		}
	}
	else_if = { # pretty famous
		limit = { prestige > 1000 }
		event_target:other_combatant = { add_artifact = prestige_skull1 }
		new_artifact = {
			set_name = prestige_head1_name
			set_description = prestige_head1_desc
		}
	}
	else_if = { # pretty pious
		limit = { piety > 1000 }
		event_target:other_combatant = { add_artifact = piety_skull1 }
		new_artifact ={
			set_name = piety_head1_name
			set_description = piety_head1_desc
		}
	}
	else = { # schmuck
		event_target:other_combatant = { add_artifact = schmuck_skull }
		new_artifact = {
			set_name = schmuck_head_name
		}
	}
}

#k_acr_pagan_branch_trait_effect = {
#	if = {
#		limit = { has_global_flag = acr_mpb }
#		random_list = {
#			 5 = { add_trait = pagan_branch_1 }
#			25 = { add_trait = pagan_branch_2 }
#			25 = { add_trait = pagan_branch_3 }
#			25 = { add_trait = pagan_branch_4 }
#			25 = { add_trait = pagan_branch_5_animist }
#			25 = { add_trait = pagan_branch_6_theist }
#			25 = { add_trait = pagan_branch_7_intellect }
#			25 = { add_trait = pagan_branch_8_might }
#			 5 = { add_trait = pagan_branch_9_egoist }
#			 5 = { add_trait = pagan_branch_10_altruist }
#		}
#	}
#	else = {
#		random_list = {
#			 5 = { add_trait = pagan_branch_1 }
#			25 = { add_trait = pagan_branch_2 }
#			25 = { add_trait = pagan_branch_3 }
#			25 = { add_trait = pagan_branch_4 }
#		}
#	}
#}

k_acr_force_convert_back = {
	if = {
		limit = {
			is_reformed_religion = attacker
			controls_religion = no
		}
		religion = attacker
	}
	else_if = {
		limit = {
			attacker = { religion = celtic_pagan }
			religion = britannic_pagan
			controls_religion = no
		}
		religion = attacker
	}
	else_if = {
		limit = {
			attacker = { religion = titan_pagan }
			religion_openly_in_hellenic_subgroup_trigger = yes
			controls_religion = no
		}
		religion = attacker
	}
	else_if = {
		limit = {
			attacker = { religion = egyptian_pagan }
			religion = aten_pagan
			controls_religion = no
		}
		religion = attacker
	}
}

#k_acr_maybe_severely_wounded_effect = {
#	if = {
#		limit = { has_dlc = "Reapers" }
#		add_trait_severely_injured_effect = yes
#	}
#	else = { add_trait_wounded_effect = yes }
#	#random_list = {
#	#	80 = { add_trait_wounded_effect = yes }
#	#	20 = {
#	#		trigger = { has_dlc = "Reapers" }
#	#		add_trait_severely_injured_effect = yes
#	#	}
#	#}
#}

k_acr_promethean_prosperity_effect_01 = {
	random_demesne_province = {
		limit = {
			has_province_modifier = acr_infrastructure_investment
			OR = {
				had_province_flag = { flag = acr_infrastructure_event days = 45 }
				NOT = { has_province_flag = acr_infrastructure_investment }
			}
		}
		save_event_target_as = acr_promethean_prosperity
	}
}

k_acr_promethean_prosperity_effect_02 = {
	custom_tooltip = {
		text = province_prospers_custom_tooltip
		event_target:acr_promethean_prosperity = {
			change_variable = { which = prosperity_value value = 10 }
			set_province_flag = acr_infrastructure_investment
		}
	}
}

k_acr_promethean_settlement_effect_01 = {
	custom_tooltip = {
		text = province_prospers_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = prosperity_value value = 10 }
		}
	}
}

k_acr_promethean_settlement_effect_02 = {
	custom_tooltip = {
		text = province_declines_custom_tooltip
		event_target:acr_promethean_destination = {
			change_variable = { which = prosperity_value value = -10 }
		}
	}
}

acr_investiture_antipope_flags_effect = {
	religion_scope = {
		persistent_event_target:religion_title = {
			if = {
				limit = { NOT = { has_title_flag = acr_has_set_religion_flags } }
				set_title_flag = acr_has_set_religion_flags
			}
			if = {
				limit = {
					PREV = {
						trigger_if = {
							limit = { has_dlc = "Holy Fury" }
							OR = {
								has_religion_feature = religion_theocratic_head
								religion = britannic_pagan
								religion = promethean_pagan
								religion = jewish
								religion = zoroastrian
								religion = manichaean
							}
						}
						trigger_else = {
							OR = {
								religion = britannic_pagan
								religion = promethean_pagan
								religion = jewish
								religion = zoroastrian
								religion = manichaean
								religion = celtic_pagan_reformed
								religion = hellenic_pagan_reformed
								religion = egyptian_pagan_reformed
								religion = baltic_pagan_reformed
								religion = tengri_pagan_reformed
								religion = finnish_pagan_reformed
								religion = aztec_pagan_reformed
								religion = slavic_pagan_reformed
								religion = west_african_pagan_reformed
								religion = zun_pagan_reformed
								religion = bon_pagan_reformed
							}
						}
					}
					has_global_flag = acr_pagan_papal
					NOT = { has_title_flag = acr_uses_college_of_cardinals }
				}
				set_title_flag = acr_uses_college_of_cardinals
				add_law = {
					law = succ_papal_succession
					cooldown = no
					opinion_effect = no
				}
			}
			if = {
				limit = {
					PREV = {
						trigger_if = {
							limit = { has_dlc = "Holy Fury" }
							OR = {
								has_religion_feature = religion_theocratic_head
								religion = britannic_pagan
								religion = promethean_pagan
								religion = jewish
								religion = zoroastrian
								religion = manichaean
							}
						}
						trigger_else = {
							OR = {
								religion = britannic_pagan
								religion = promethean_pagan
								religion = jewish
								religion = zoroastrian
								religion = manichaean
								religion = celtic_pagan_reformed
								religion = hellenic_pagan_reformed
								religion = egyptian_pagan_reformed
								religion = baltic_pagan_reformed
								religion = tengri_pagan_reformed
								religion = finnish_pagan_reformed
								religion = aztec_pagan_reformed
								religion = slavic_pagan_reformed
								religion = west_african_pagan_reformed
								religion = zun_pagan_reformed
								religion = bon_pagan_reformed
							}
						}
					}
					has_global_flag = acr_pagan_antipopes
					NOT = { has_title_flag = acr_uses_antipopes }
				}
				set_title_flag = acr_uses_antipopes
				PREV = { set_can_have_antipopes = yes }
			}
			if = {
				limit = {
					PREV = {
						trigger_if = {
							limit = { has_dlc = "Holy Fury" }
							OR = {
								has_religion_feature = religion_theocratic_head
								religion = britannic_pagan
								religion = promethean_pagan
								religion = jewish
								religion = zoroastrian
								religion = manichaean
							}
						}
						trigger_else = {
							OR = {
								religion = britannic_pagan
								religion = promethean_pagan
								religion = jewish
								religion = zoroastrian
								religion = manichaean
								religion = celtic_pagan_reformed
								religion = hellenic_pagan_reformed
								religion = egyptian_pagan_reformed
								religion = baltic_pagan_reformed
								religion = tengri_pagan_reformed
								religion = finnish_pagan_reformed
								religion = aztec_pagan_reformed
								religion = slavic_pagan_reformed
								religion = west_african_pagan_reformed
								religion = zun_pagan_reformed
								religion = bon_pagan_reformed
							}
						}
					}
					OR = {
						has_global_flag = acr_pagan_papal
						has_global_flag = acr_pagan_antipopes
					}
					NOT = { has_title_flag = acr_uses_investiture }
				}
				set_title_flag = acr_uses_investiture
			}
			if = {
				limit = {
					PREV = { has_religion_feature = religion_defensive }
				}
				set_title_flag = acr_is_religion_feature_defensive
			}
			if = {
				limit = {
					PREV = {
						NOR = {
							has_religion_feature = religion_defensive
							has_religion_feature = religion_warlike
						}
						OR = {
							religion_openly_baltic_or_reformed_trigger = yes
							religion_openly_finnish_or_reformed_trigger = yes
							religion_openly_slavic_or_reformed_trigger = yes
							religion_openly_bon_or_reformed_trigger = yes
							religion_openly_west_african_or_reformed_trigger = yes
							religion_openly_egyptian_or_reformed_trigger = yes
						}
					}
				}
				set_title_flag = acr_is_religion_feature_partial_defensive
			}
			if = {
				limit = {
					PREV = {
						OR = {
							has_religion_feature = religion_relentless
							has_religion_feature = religion_feature_tengri
							has_religion_feature = religion_feature_aztec
						}
					}
				}
				set_title_flag = acr_is_religion_feature_relentless
			}
			if = {
				limit = {
					PREV = {
						OR = {
							has_religion_feature = religion_animistic
							has_religion_feature = religion_feature_celtic
							has_religion_feature = religion_feature_baltic
						}
					}
				}
				set_title_flag = acr_is_religion_feature_animistic
			}
			#if = {
			#	limit = { NOT = { has_title_flag = acr_has_set_religion_modifiers } }
			#	set_title_flag = acr_has_set_religion_modifiers
			#}
			if = {
				limit = {
					has_title_flag = acr_is_religion_feature_defensive
					has_title_flag = acr_is_religion_feature_relentless
					has_title_flag = acr_is_religion_feature_animistic
				}
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.4
							light_cavalry_defensive = 0.3
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = TENGRI_RELENTLESS_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							heavy_infantry_offensive = 0.3
							heavy_infantry_defensive = 0.2
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = RELENTLESS_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else = {
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = RELENTLESS_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
				}
			}
			else_if = {
				limit = {
					has_title_flag = acr_is_religion_feature_defensive
					has_title_flag = acr_is_religion_feature_relentless
				}
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.4
							light_cavalry_defensive = 0.3
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = TENGRI_RELENTLESS_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							heavy_infantry_offensive = 0.3
							heavy_infantry_defensive = 0.2
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = RELENTLESS_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else = {
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = RELENTLESS_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
				}
			}
			else_if = {
				limit = {
					has_title_flag = acr_is_religion_feature_defensive
					has_title_flag = acr_is_religion_feature_animistic
				}
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							light_cavalry_offensive = 0.3
							light_cavalry_defensive = 0.3
							land_morale = 0.05

							key = ANIMISTIC_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							heavy_infantry_offensive = 0.2
							heavy_infantry_defensive = 0.2
							land_morale = 0.05

							key = ANIMISTIC_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else = {
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							land_morale = 0.05

							key = ANIMISTIC_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
				}
			}
			else_if = {
				limit = { has_title_flag = acr_is_religion_feature_defensive }
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							light_cavalry_offensive = 0.3
							light_cavalry_defensive = 0.3

							key = DEF_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2
							heavy_infantry_offensive = 0.2
							heavy_infantry_defensive = 0.2

							key = DEF_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
					else = {
						set_unit_modifier = {
							garrison_size = 0.3
							levy_size = 0.2

							key = DEF_RELIGION
						}

						set_unit_home_modifier = {
							land_morale = 0.8
							light_infantry_defensive = 0.8
							heavy_infantry_defensive = 0.8
							pikemen_defensive = 0.8
							light_cavalry_defensive = 0.8
							knights_defensive = 0.8
							archers_defensive = 0.8
							horse_archers_defensive = 0.8
							camel_cavalry_defensive = 0.8
							war_elephants_defensive = 0.8

							garrison_size = 0.4

							key = DEF_RELIGION_HOME_TERRITORY
						}
					}
				}
			}
			else_if = {
				limit = {
					has_title_flag = acr_is_religion_feature_partial_defensive
					has_title_flag = acr_is_religion_feature_relentless
					has_title_flag = acr_is_religion_feature_animistic
				}
				PREV = {
					set_unit_modifier = {
						garrison_size = 0.1
						levy_size = 0.1
						light_infantry_offensive = 0.1
						heavy_infantry_offensive = 0.1
						light_cavalry_offensive = 0.1 
						knights_offensive = 0.1 
						pikemen_offensive = 0.1 
						archers_offensive = 0.1
						horse_archers_offensive = 0.1
						camel_cavalry_offensive = 0.1
						war_elephants_offensive = 0.1
						land_morale = 0.05

						key = RELENTLESS_RELIGION
					}

					set_unit_home_modifier = {
						land_morale = 0.2
						light_infantry_defensive = 0.2
						heavy_infantry_defensive = 0.2
						pikemen_defensive = 0.2
						light_cavalry_defensive = 0.2
						knights_defensive = 0.2
						archers_defensive = 0.2
						horse_archers_defensive = 0.2
						camel_cavalry_defensive = 0.2
						war_elephants_defensive = 0.2
						
						garrison_size = 0.2

						key = DEF_RELIGION_HOME_TERRITORY
					}
				}
			}
			else_if = {
				limit = {
					has_title_flag = acr_is_religion_feature_partial_defensive
					has_title_flag = acr_is_religion_feature_relentless
				}
				PREV = {
					set_unit_modifier = {
						garrison_size = 0.1
						levy_size = 0.1
						light_infantry_offensive = 0.1
						heavy_infantry_offensive = 0.1
						light_cavalry_offensive = 0.1 
						knights_offensive = 0.1 
						pikemen_offensive = 0.1 
						archers_offensive = 0.1
						horse_archers_offensive = 0.1
						camel_cavalry_offensive = 0.1
						war_elephants_offensive = 0.1

						key = RELENTLESS_RELIGION
					}

					set_unit_home_modifier = {
						land_morale = 0.2
						light_infantry_defensive = 0.2
						heavy_infantry_defensive = 0.2
						pikemen_defensive = 0.2
						light_cavalry_defensive = 0.2
						knights_defensive = 0.2
						archers_defensive = 0.2
						horse_archers_defensive = 0.2
						camel_cavalry_defensive = 0.2
						war_elephants_defensive = 0.2
						
						garrison_size = 0.2

						key = DEF_RELIGION_HOME_TERRITORY
					}
				}
			}
			else_if = {
				limit = {
					has_title_flag = acr_is_religion_feature_partial_defensive
					has_title_flag = acr_is_religion_feature_animistic
				}
				PREV = {
					set_unit_modifier = {
						garrison_size = 0.1
						levy_size = 0.1
						land_morale = 0.05

						key = ANIMISTIC_RELIGION
					}

					set_unit_home_modifier = {
						land_morale = 0.2
						light_infantry_defensive = 0.2
						heavy_infantry_defensive = 0.2
						pikemen_defensive = 0.2
						light_cavalry_defensive = 0.2
						knights_defensive = 0.2
						archers_defensive = 0.2
						horse_archers_defensive = 0.2
						camel_cavalry_defensive = 0.2
						war_elephants_defensive = 0.2
						
						garrison_size = 0.2

						key = DEF_RELIGION_HOME_TERRITORY
					}
				}
			}
			else_if = {
				limit = { has_title_flag = acr_is_religion_feature_partial_defensive }
				PREV = {
					set_unit_modifier = {
						garrison_size = 0.1
						levy_size = 0.1

						key = DEF_RELIGION
					}

					set_unit_home_modifier = {
						land_morale = 0.2
						light_infantry_defensive = 0.2
						heavy_infantry_defensive = 0.2
						pikemen_defensive = 0.2
						light_cavalry_defensive = 0.2
						knights_defensive = 0.2
						archers_defensive = 0.2
						horse_archers_defensive = 0.2
						camel_cavalry_defensive = 0.2
						war_elephants_defensive = 0.2
						
						garrison_size = 0.2

						key = DEF_RELIGION_HOME_TERRITORY
					}
				}
			}
			else_if = {
				limit = {
					has_title_flag = acr_is_religion_feature_relentless
					has_title_flag = acr_is_religion_feature_animistic
				}
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.4
							light_cavalry_defensive = 0.3
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = TENGRI_RELENTLESS_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.3
							heavy_infantry_defensive = 0.2
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = RELENTLESS_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_celtic_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.15
							garrison_size = 0.2
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = RELENTLESS_RELIGION
						}
						
						if = {
							limit = {
								NOR = {
									has_religion_feature = religion_defensive
									has_religion_feature = religion_warlike
								}
							}
							set_unit_home_modifier = {
								land_morale = 0.15
								light_infantry_defensive = 0.15
								heavy_infantry_defensive = 0.15
								pikemen_defensive = 0.15
								light_cavalry_defensive = 0.15
								knights_defensive = 0.15
								archers_defensive = 0.15
								horse_archers_defensive = 0.15
								camel_cavalry_defensive = 0.15
								war_elephants_defensive = 0.15

								garrison_size = 0.1

								key = HERO_RELIGION_HOME_TERRITORY
							}
						}
					}
					else_if = {
						limit = { religion_openly_aztec_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = AZTEC_RELENTLESS_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_norse_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = RELENTLESS_RELIGION
						}
					}
					else = {
						set_unit_modifier = {
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1
							land_morale = 0.05

							key = RELENTLESS_RELIGION
						}
					}
				}
			}
			else_if = {
				limit = { has_title_flag = acr_is_religion_feature_relentless }
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.4
							light_cavalry_defensive = 0.3
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = TENGRI_RELENTLESS_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.3
							heavy_infantry_defensive = 0.2
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = RELENTLESS_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_celtic_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.15
							garrison_size = 0.2
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = RELENTLESS_RELIGION
						}
						
						if = {
							limit = {
								NOR = {
									has_religion_feature = religion_defensive
									has_religion_feature = religion_warlike
								}
							}
							set_unit_home_modifier = {
								land_morale = 0.15
								light_infantry_defensive = 0.15
								heavy_infantry_defensive = 0.15
								pikemen_defensive = 0.15
								light_cavalry_defensive = 0.15
								knights_defensive = 0.15
								archers_defensive = 0.15
								horse_archers_defensive = 0.15
								camel_cavalry_defensive = 0.15
								war_elephants_defensive = 0.15

								garrison_size = 0.1

								key = HERO_RELIGION_HOME_TERRITORY
							}
						}
					}
					else_if = {
						limit = { religion_openly_aztec_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = AZTEC_RELENTLESS_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_norse_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = RELENTLESS_RELIGION
						}
					}
					else = {
						set_unit_modifier = {
							light_infantry_offensive = 0.1
							heavy_infantry_offensive = 0.1
							light_cavalry_offensive = 0.1 
							knights_offensive = 0.1 
							pikemen_offensive = 0.1 
							archers_offensive = 0.1
							horse_archers_offensive = 0.1
							camel_cavalry_offensive = 0.1
							war_elephants_offensive = 0.1

							key = RELENTLESS_RELIGION
						}
					}
				}
			}
			else_if = {
				limit = { has_title_flag = acr_is_religion_feature_animistic }
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_cavalry_offensive = 0.3
							light_cavalry_defensive = 0.3
							land_morale = 0.05

							key = ANIMISTIC_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							heavy_infantry_offensive = 0.2
							heavy_infantry_defensive = 0.2
							land_morale = 0.05

							key = ANIMISTIC_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_celtic_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.15
							garrison_size = 0.2
							land_morale = 0.05

							key = HERO_RELIGION
						}
						
						if = {
							limit = {
								NOR = {
									has_religion_feature = religion_defensive
									has_religion_feature = religion_warlike
								}
							}
							set_unit_home_modifier = {
								land_morale = 0.15
								light_infantry_defensive = 0.15
								heavy_infantry_defensive = 0.15
								pikemen_defensive = 0.15
								light_cavalry_defensive = 0.15
								knights_defensive = 0.15
								archers_defensive = 0.15
								horse_archers_defensive = 0.15
								camel_cavalry_defensive = 0.15
								war_elephants_defensive = 0.15

								garrison_size = 0.1

								key = HERO_RELIGION_HOME_TERRITORY
							}
						}
					}
					else_if = {
						limit = {
							OR = {
								religion_openly_norse_or_reformed_trigger = yes
								religion_openly_aztec_or_reformed_trigger = yes
							}
						}
						set_unit_modifier = {
							levy_size = 0.3
							land_morale = 0.05

							key = ANIMISTIC_RELIGION
						}
					}
					else = {
						set_unit_modifier = {
							land_morale = 0.05

							key = ANIMISTIC_RELIGION
						}
					}
				}
			}
			else = {
				PREV = {
					if = {
						limit = { religion_openly_tengri_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							light_cavalry_offensive = 0.3
							light_cavalry_defensive = 0.3

							key = OFF_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_zun_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.3
							heavy_infantry_offensive = 0.2
							heavy_infantry_defensive = 0.2

							key = OFF_RELIGION
						}
					}
					else_if = {
						limit = { religion_openly_celtic_or_reformed_trigger = yes }
						set_unit_modifier = {
							levy_size = 0.15
							garrison_size = 0.2

							key = HERO_RELIGION
						}
						
						if = {
							limit = {
								NOR = {
									has_religion_feature = religion_defensive
									has_religion_feature = religion_warlike
								}
							}
							set_unit_home_modifier = {
								land_morale = 0.15
								light_infantry_defensive = 0.15
								heavy_infantry_defensive = 0.15
								pikemen_defensive = 0.15
								light_cavalry_defensive = 0.15
								knights_defensive = 0.15
								archers_defensive = 0.15
								horse_archers_defensive = 0.15
								camel_cavalry_defensive = 0.15
								war_elephants_defensive = 0.15

								garrison_size = 0.1

								key = HERO_RELIGION_HOME_TERRITORY
							}
						}
					}
					else_if = {
						limit = {
							OR = {
								religion_openly_norse_or_reformed_trigger = yes
								religion_openly_aztec_or_reformed_trigger = yes
							}
						}
						set_unit_modifier = {
							levy_size = 0.3

							key = OFF_RELIGION
						}
					}
				}
			}
		}
	}
}

acr_set_pagan_papal_laws_effect = {
	if = {
		limit = { has_global_flag = acr_pagan_papal }
		any_character = {
			limit = {
				religion = ROOT
				is_landed = yes
				is_theocracy = yes
				NOR = {
					is_law_potential = succ_papal_succession
					has_law = succ_catholic_bishopric
				}
			}
			character_event = { id = ke_ancrel_m.1 }
		}
	}
	if = {
		limit = {
			OR = {
				has_global_flag = acr_pagan_papal
				has_global_flag = acr_pagan_antipopes
			}
		}
		any_character = {
			limit = {
				religion = ROOT
				controls_religion = no
				is_landed = yes
				is_tribal = no
				is_nomadic = no
				NOR = {
					has_law = investiture_law_0
					has_law = investiture_law_1
				}
			}
			character_event = { id = ke_ancrel_m.2 }
		}
	}
}

acr_set_pagan_papal_scopes_effect = {
	britannic_pagan = {
		save_persistent_event_target = {
			name = religion_title
			scope = k_britannic_pagan
		}
		persistent_event_target:religion_title = {
			save_persistent_event_target = {
				name = religion_scope
				scope = PREV
			}
		}
	}
	promethean_pagan = {
		save_persistent_event_target = {
			name = religion_title
			scope = d_promethean_pagan
		}
		persistent_event_target:religion_title = {
			save_persistent_event_target = {
				name = religion_scope
				scope = PREV
			}
		}
	}
	jewish = {
		save_persistent_event_target = {
			name = religion_title
			scope = d_jewish
		}
		persistent_event_target:religion_title = {
			save_persistent_event_target = {
				name = religion_scope
				scope = PREV
			}
		}
	}
	zoroastrian = {
		save_persistent_event_target = {
			name = religion_title
			scope = d_zoroastrian
		}
		persistent_event_target:religion_title = {
			save_persistent_event_target = {
				name = religion_scope
				scope = PREV
			}
		}
	}
	manichaean = {
		save_persistent_event_target = {
			name = religion_title
			scope = d_manichaean
		}
		persistent_event_target:religion_title = {
			save_persistent_event_target = {
				name = religion_scope
				scope = PREV
			}
		}
	}
}

acr_druid_dryad_investiture_effect = {
	if = {
		limit = {
			religion_openly_celtic_or_reformed_trigger = yes
			NOR = {
				trait = druid
				trait = bad_druid
			}
		}
		add_trait = druid
		if = {
			limit = { trait = learning_druidic_arts }
			remove_trait = learning_druidic_arts
		}
		if = {
			limit = { has_character_flag = wants_druidic_training }
			clr_character_flag = wants_druidic_training
		}
		if = {
			limit = { has_character_flag = druidic_training }
			clr_character_flag = druidic_training
		}
	}
	else_if = {
		limit = {
			religion = britannic_pagan
			NOR = {
				trait = dryad
				trait = bad_dryad
			}
		}
		add_trait = dryad
	}
}