﻿namespace = ppr_preaching

# Events fired at the end of a sermon by a Pilgrims missionary army
# (ppr_on_preaching_completion, common/on_action/ppr_preaching_on_actions.txt).
# The roll and the per-county cooldown live in ppr_preaching_roll_event_effect
# (common/scripted_effects/ppr_preaching_event_effects.txt).
#
# Saved scopes: scope:preacher, scope:preach_county, scope:preach_barony, scope:preach_holder (optional)
#
# Positive / choice:  0001 The Lord Listens (0002 letter to a player holder), 0010 The Crowd Converts,
#                     0020 Our Fathers' Rite, 0030 Spreading the Tenets, 0040 A Vocation,
#                     0050 Blessing of the Land
# Risk:               0100 Unrest in the Square, 0110 Trampled Fields, 0120 Fever among the Crowd
# Hostile land:       0200 Stones and Insults, 0210 A Secret Flock

######################################################################
# 0001: The Lord Listens
######################################################################
ppr_preaching.0001 = {
	type = character_event
	title = ppr_preaching.0001.t
	desc = ppr_preaching.0001.desc
	theme = faith
	left_portrait = {
		character = root
		animation = preaching
	}
	right_portrait = {
		character = scope:preach_holder
		animation = thinking
	}
	override_background = { reference = throne_room }

	trigger = {
		ppr_preaching_lord_listens_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
		scope:preach_holder.faith = { save_scope_as = preach_holder_faith }
	}

	# Dispute the scriptures with them.
	option = {
		name = ppr_preaching.0001.a
		skill = learning
		duel = {
			skill = learning
			target = scope:preach_holder
			25 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = -15
					scope:preach_holder = { has_trait = zealous }
				}
				modifier = {
					add = 10
					scope:preach_holder = { has_trait = cynical }
				}
				modifier = {
					add = 10
					scope:preach_holder = {
						opinion = {
							target = root
							value >= 25
						}
					}
				}
				min = 5
				desc = ppr_preaching.0001.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0001.success
					left_icon = root
					right_icon = scope:preach_holder
					ppr_preaching_lord_listens_success_effect = yes
				}
			}
			75 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0001.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0001.failure
					left_icon = root
					right_icon = scope:preach_holder
					ppr_preaching_lord_listens_failure_effect = yes
				}
			}
		}
		stress_impact = {
			shy = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_zeal = 0.5 }
		}
	}

	# Speak to their heart, not their head.
	option = {
		name = ppr_preaching.0001.b
		skill = diplomacy
		duel = {
			skill = diplomacy
			target = scope:preach_holder
			25 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = -15
					scope:preach_holder = { has_trait = zealous }
				}
				modifier = {
					add = 10
					scope:preach_holder = { has_trait = trusting }
				}
				modifier = {
					add = 10
					scope:preach_holder = {
						opinion = {
							target = root
							value >= 25
						}
					}
				}
				min = 5
				desc = ppr_preaching.0001.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0001.success
					left_icon = root
					right_icon = scope:preach_holder
					ppr_preaching_lord_listens_success_effect = yes
				}
			}
			75 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0001.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0001.failure
					left_icon = root
					right_icon = scope:preach_holder
					ppr_preaching_lord_listens_failure_effect = yes
				}
			}
		}
		stress_impact = {
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_sociability = 0.5 }
		}
	}

	# Leave them with a blessing, and let the seed grow.
	option = {
		name = ppr_preaching.0001.c
		add_piety = minor_piety_gain
		scope:preach_holder = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 15
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_gain
			patient = minor_stress_impact_loss
		}
		ai_chance = {
			base = 25
			ai_value_modifier = { ai_zeal = -0.5 }
		}
	}
}

######################################################################
# 0002: The Lord Listens - letter to a player holder (root = the holder)
######################################################################
ppr_preaching.0002 = {
	type = letter_event
	opening = {
		desc = ppr_preaching.0002.opening
	}
	desc = ppr_preaching.0002.desc
	sender = {
		character = scope:preacher
		animation = preaching
	}

	trigger = {
		ppr_preaching_event_base_trigger = yes
		ppr_preaching_holder_can_convert_trigger = yes
		this = scope:preach_holder
	}

	# Accept the true faith.
	option = {
		name = ppr_preaching.0002.a
		hidden_effect = {
			faith = { save_scope_as = old_faith }
			rite = { save_scope_as = old_rite }
		}
		set_character_faith = scope:preacher.faith
		set_character_rite = scope:preacher.rite
		trigger_event = {
			on_action = on_faith_conversion
		}
		scope:preacher.faith = {
			change_fervor = {
				value = ppr_preaching_fervor_lord_value
				desc = ppr_fervor_gain_preaching_lord
			}
		}
		add_opinion = {
			modifier = showed_me_the_light_opinion
			target = scope:preacher
			opinion = 40
		}
		scope:preacher = {
			send_interface_toast = {
				type = event_toast_effect_good
				title = ppr_preaching.0002.accepted_toast
				left_icon = scope:preacher
				right_icon = root
				add_piety = major_piety_gain
				add_prestige = medium_prestige_gain
			}
		}
		stress_impact = {
			zealous = major_stress_impact_gain
			stubborn = medium_stress_impact_gain
		}
		ai_chance = { base = 0 }
	}

	# Refuse politely.
	option = {
		name = ppr_preaching.0002.b
		scope:preacher = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = ppr_preaching.0002.refused_toast
				left_icon = scope:preacher
				right_icon = root
				custom_tooltip = ppr_preaching.0002.refused_tt
			}
		}
		ai_chance = { base = 100 }
	}
}

######################################################################
# 0010: The Crowd Converts
######################################################################
ppr_preaching.0010 = {
	type = character_event
	title = ppr_preaching.0010.t
	desc = ppr_preaching.0010.desc
	theme = faith
	left_portrait = {
		character = root
		animation = preaching
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = disapproval
	}
	override_background = { reference = market }

	trigger = {
		ppr_preaching_crowd_converts_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
	}

	# Preach to them patiently, in their own words.
	option = {
		name = ppr_preaching.0010.a
		skill = learning
		duel = {
			skill = learning
			value = ppr_preaching_crowd_difficulty_value
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0010.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0010.success
					left_icon = root
					right_icon = scope:preach_county
					ppr_preaching_crowd_success_effect = yes
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0010.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0010.failure
					left_icon = root
					right_icon = scope:preach_county
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			impatient = minor_stress_impact_gain
		}
		ai_chance = { base = 50 }
	}

	# Stir them up: tear down their idols with words of fire!
	option = {
		name = ppr_preaching.0010.b
		skill = diplomacy
		save_scope_value_as = {
			name = ppr_stirred_crowd
			value = yes
		}
		duel = {
			skill = diplomacy
			value = ppr_preaching_crowd_difficulty_value
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -39
				}
				min = 5
				desc = ppr_preaching.0010.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0010.success
					left_icon = root
					right_icon = scope:preach_county
					ppr_preaching_crowd_success_effect = yes
					add_prestige = minor_prestige_gain
				}
			}
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -59
				}
				min = 15
				desc = ppr_preaching.0010.riot
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0010.riot
					left_icon = root
					right_icon = scope:preach_county
					add_prestige = minor_prestige_loss
					ppr_preaching_county_control_loss_effect = { VALUE = minor_county_control_loss }
					ppr_preaching_annoy_holder_effect = { OPINION = -15 }
				}
			}
		}
		stress_impact = {
			calm = minor_stress_impact_gain
			wrathful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = 0.5
				ai_boldness = 0.5
			}
		}
	}

	# Share the bread, say a prayer, and move on.
	option = {
		name = ppr_preaching.0010.c
		add_piety = minor_piety_gain
		stress_impact = {
			zealous = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
		}
		ai_chance = { base = 25 }
	}
}

######################################################################
# 0020: Our Fathers' Rite
######################################################################
ppr_preaching.0020 = {
	type = character_event
	title = ppr_preaching.0020.t
	desc = {
		desc = ppr_preaching.0020.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { ppr_preaching_county_other_rite_trigger = yes }
				desc = ppr_preaching.0020.desc.county
			}
			desc = ppr_preaching.0020.desc.holder
		}
	}
	theme = faith
	left_portrait = {
		character = root
		animation = debating
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = interested
	}
	override_background = { reference = temple }

	trigger = {
		ppr_preaching_fathers_rite_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
		scope:preach_holder ?= {
			rite = { save_scope_as = preach_holder_rite }
		}
	}

	# Teach our rite to the people.
	option = {
		name = ppr_preaching.0020.a
		trigger = { ppr_preaching_county_other_rite_trigger = yes }
		skill = learning
		duel = {
			skill = learning
			value = ppr_preaching_flock_difficulty_value
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0020.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0020.a.success
					left_icon = root
					right_icon = scope:preach_county
					ppr_preaching_rite_success_effect = yes
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0020.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0020.a.failure
					left_icon = root
					right_icon = scope:preach_county
					add_prestige = minor_prestige_loss
				}
			}
		}
		ai_chance = { base = 50 }
	}

	# Speak with the lord of these lands about the rite of our fathers.
	option = {
		name = ppr_preaching.0020.b
		trigger = { ppr_preaching_holder_other_rite_trigger = yes }
		skill = diplomacy
		duel = {
			skill = diplomacy
			target = scope:preach_holder
			35 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = -15
					scope:preach_holder = { has_trait = zealous }
				}
				modifier = {
					add = 10
					scope:preach_holder = {
						opinion = {
							target = root
							value >= 25
						}
					}
				}
				min = 5
				desc = ppr_preaching.0020.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0020.b.success
					left_icon = root
					right_icon = scope:preach_holder
					scope:preach_holder = {
						set_character_rite = root.rite
						add_opinion = {
							modifier = respect_opinion
							target = root
							opinion = 20
						}
					}
					add_prestige = medium_prestige_gain
					add_piety = minor_piety_gain
				}
			}
			65 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0020.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0020.b.failure
					left_icon = root
					right_icon = scope:preach_holder
					ppr_preaching_annoy_holder_effect = { OPINION = -10 }
				}
			}
		}
		ai_chance = { base = 50 }
	}

	# One faith, many rites. Let it be.
	option = {
		name = ppr_preaching.0020.c
		add_piety = minor_piety_gain
		if = {
			limit = { ppr_preaching_holder_present_trigger = yes }
			scope:preach_holder = {
				add_opinion = {
					modifier = respect_opinion
					target = root
					opinion = 10
				}
			}
		}
		stress_impact = {
			zealous = minor_stress_impact_gain
			humble = minor_stress_impact_loss
		}
		ai_chance = { base = 25 }
	}
}

######################################################################
# 0030: Spreading the Tenets
######################################################################
ppr_preaching.0030 = {
	type = character_event
	title = ppr_preaching.0030.t
	desc = ppr_preaching.0030.desc
	theme = faith
	left_portrait = {
		character = root
		animation = preaching
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = interested
	}
	override_background = { reference = village }

	trigger = {
		ppr_preaching_tenets_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
		random_personal_tenet = {
			limit = {
				ppr_tenet_not_core_for_trigger = { CHARACTER = root }
			}
			save_scope_as = ppr_preach_tenet
		}
	}

	# A learned sermon, with chapter and verse.
	option = {
		name = ppr_preaching.0030.a
		skill = learning
		duel = {
			skill = learning
			value = ppr_preaching_flock_difficulty_value
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0030.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0030.success
					left_icon = root
					ppr_preaching_spread_tenet_effect = { CHANGE = medium_tenet_popularity_gain }
					add_learning_lifestyle_xp = minor_lifestyle_xp
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0030.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0030.failure
					left_icon = root
					ppr_preaching_spread_tenet_effect = { CHANGE = miniscule_tenet_popularity_gain }
					add_prestige = minor_prestige_loss
				}
			}
		}
		ai_chance = { base = 50 }
	}

	# Parables and songs the whole village can sing.
	option = {
		name = ppr_preaching.0030.b
		skill = diplomacy
		duel = {
			skill = diplomacy
			value = ppr_preaching_flock_difficulty_value
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0030.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0030.success
					left_icon = root
					ppr_preaching_spread_tenet_effect = { CHANGE = medium_tenet_popularity_gain }
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0030.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0030.failure
					left_icon = root
					ppr_preaching_spread_tenet_effect = { CHANGE = miniscule_tenet_popularity_gain }
					add_prestige = minor_prestige_loss
				}
			}
		}
		ai_chance = { base = 50 }
	}

	# Speak plainly, and trust the word to do its work.
	option = {
		name = ppr_preaching.0030.c
		ppr_preaching_spread_tenet_effect = { CHANGE = minor_tenet_popularity_gain }
		add_piety = minor_piety_gain
		if = { limit = { has_pam_dlc_trigger = yes } change_spiritual_fulfillment = minor_spiritual_fulfillment_value }
		stress_impact = {
			arrogant = minor_stress_impact_gain
			humble = minor_stress_impact_loss
		}
		ai_chance = { base = 25 }
	}
}

######################################################################
# 0040: A Vocation
######################################################################
ppr_preaching.0040 = {
	type = character_event
	title = ppr_preaching.0040.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:ppr_vocation_type = flag:monk }
				desc = ppr_preaching.0040.desc.monk
			}
			triggered_desc = {
				trigger = { scope:ppr_vocation_type = flag:cleric }
				desc = ppr_preaching.0040.desc.cleric
			}
			triggered_desc = {
				trigger = { scope:ppr_vocation_type = flag:scholar }
				desc = ppr_preaching.0040.desc.scholar
			}
			triggered_desc = {
				trigger = { scope:ppr_vocation_type = flag:peasant }
				desc = ppr_preaching.0040.desc.peasant
			}
			desc = ppr_preaching.0040.desc.peasant
		}
		desc = ppr_preaching.0040.desc.outro
	}
	theme = faith
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:ppr_vocation
		animation = personality_zealous
	}
	override_background = { reference = village }

	trigger = {
		ppr_preaching_vocation_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
		random_list = {
			25 = {
				create_character = {
					template = monk_character_template
					age = { 20 35 }
					location = scope:preach_barony.title_province
					culture = scope:preach_county.culture
					faith = root.faith
					rite = root.rite
					save_scope_as = ppr_vocation
				}
				save_scope_value_as = {
					name = ppr_vocation_type
					value = flag:monk
				}
			}
			25 = {
				create_character = {
					template = simple_priest_character_template
					gender_female_chance = root_faith_clergy_gender_female_chance
					age = { 18 26 }
					location = scope:preach_barony.title_province
					culture = scope:preach_county.culture
					faith = root.faith
					rite = root.rite
					trait = zealous
					save_scope_as = ppr_vocation
				}
				save_scope_value_as = {
					name = ppr_vocation_type
					value = flag:cleric
				}
			}
			25 = {
				create_character = {
					template = scholar_character
					age = { 22 35 }
					location = scope:preach_barony.title_province
					culture = scope:preach_county.culture
					faith = root.faith
					rite = root.rite
					save_scope_as = ppr_vocation
				}
				save_scope_value_as = {
					name = ppr_vocation_type
					value = flag:scholar
				}
			}
			25 = {
				create_character = {
					template = location_pilgrim_template
					age = { 18 35 }
					location = scope:preach_barony.title_province
					culture = scope:preach_county.culture
					faith = root.faith
					rite = root.rite
					dynasty = none
					save_scope_as = ppr_vocation
				}
				hidden_effect = {
					scope:ppr_vocation = { add_character_flag = peasant_outfit }
				}
				save_scope_value_as = {
					name = ppr_vocation_type
					value = flag:peasant
				}
			}
		}
	}

	# Walk with us.
	option = {
		name = ppr_preaching.0040.a
		ppr_camp_events_recruit_effect = {
			CHARACTER = scope:ppr_vocation
			OPINION = 30
		}
		add_piety = minor_piety_gain
		stress_impact = {
			compassionate = minor_stress_impact_loss
		}
		ai_chance = { base = 75 }
	}

	# Your calling is here, among your own people.
	option = {
		name = ppr_preaching.0040.b
		add_piety = minor_piety_gain
		ppr_preaching_dismiss_character_effect = { CHARACTER = scope:ppr_vocation }
		stress_impact = {
			humble = minor_stress_impact_loss
			ambitious = minor_stress_impact_gain
		}
		ai_chance = { base = 20 }
	}

	# We cannot feed another mouth.
	option = {
		name = ppr_preaching.0040.c
		ppr_preaching_dismiss_character_effect = { CHARACTER = scope:ppr_vocation }
		stress_impact = {
			compassionate = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		ai_chance = { base = 5 }
	}
}

######################################################################
# 0050: Blessing of the Land
######################################################################
ppr_preaching.0050 = {
	type = character_event
	title = ppr_preaching.0050.t
	desc = ppr_preaching.0050.desc
	theme = faith
	left_portrait = {
		character = root
		animation = prayer
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = happiness
	}
	override_background = { reference = farmland }

	trigger = {
		ppr_preaching_friendly_land_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
	}

	# Bless the fields.
	option = {
		name = ppr_preaching.0050.a
		scope:preach_county = {
			if = {
				limit = { has_county_modifier = ppr_blessed_land_modifier }
				remove_county_modifier = ppr_blessed_land_modifier
			}
			add_county_modifier = {
				modifier = ppr_blessed_land_modifier
				years = 10
			}
		}
		add_piety = minor_piety_gain
		ppr_preaching_please_holder_effect = yes
		stress_impact = {
			compassionate = minor_stress_impact_loss
			generous = minor_stress_impact_loss
		}
		ai_chance = { base = 50 }
	}

	# Lead the whole village around its boundaries, chanting the old litany.
	option = {
		name = ppr_preaching.0050.b
		skill = learning
		duel = {
			skill = learning
			value = ppr_preaching_flock_difficulty_value
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0050.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0050.b.success
					left_icon = root
					right_icon = scope:preach_county
					scope:preach_county = {
						if = {
							limit = { has_county_modifier = ppr_blessed_land_modifier }
							remove_county_modifier = ppr_blessed_land_modifier
						}
						add_county_modifier = {
							modifier = ppr_blessed_land_modifier
							years = 10
						}
					}
					add_piety = medium_piety_gain
					add_prestige = minor_prestige_gain
					ppr_preaching_please_holder_effect = yes
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0050.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0050.b.failure
					left_icon = root
					right_icon = scope:preach_county
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
		}
		ai_chance = { base = 30 }
	}

	# Accept the elders' gift instead.
	option = {
		name = ppr_preaching.0050.c
		add_gold = ppr_preaching_compensation_value
		add_piety = miniscule_piety_loss
		stress_impact = {
			greedy = minor_stress_impact_loss
			generous = minor_stress_impact_gain
			zealous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			ai_value_modifier = { ai_greed = 1 }
		}
	}
}

######################################################################
# 0100: Unrest in the Square (risk)
######################################################################
ppr_preaching.0100 = {
	type = character_event
	title = ppr_preaching.0100.t
	desc = ppr_preaching.0100.desc
	theme = unfriendly
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = anger
	}
	override_background = { reference = market }

	trigger = {
		ppr_preaching_friendly_land_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
	}

	# Climb on a cart and calm them.
	option = {
		name = ppr_preaching.0100.a
		skill = diplomacy
		duel = {
			skill = diplomacy
			value = ppr_preaching_flock_difficulty_value
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0100.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0100.a.success
					left_icon = root
					right_icon = scope:preach_county
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0100.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0100.a.failure
					left_icon = root
					right_icon = scope:preach_county
					ppr_preaching_county_control_loss_effect = { VALUE = minor_county_control_loss }
					ppr_preaching_annoy_holder_effect = { OPINION = -10 }
					add_prestige = minor_prestige_loss
				}
			}
		}
		stress_impact = {
			shy = minor_stress_impact_gain
			craven = minor_stress_impact_gain
		}
		ai_chance = { base = 50 }
	}

	# Bread and ale for everyone, and quickly.
	option = {
		name = ppr_preaching.0100.b
		trigger = { short_term_gold >= ppr_preaching_compensation_value }
		remove_short_term_gold = ppr_preaching_compensation_value
		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = { base = 30 }
	}

	# Leave it to the lord's men.
	option = {
		name = ppr_preaching.0100.c
		ppr_preaching_county_control_loss_effect = { VALUE = medium_county_control_loss }
		ppr_preaching_annoy_holder_effect = { OPINION = -20 }
		stress_impact = {
			compassionate = medium_stress_impact_gain
			callous = minor_stress_impact_loss
		}
		ai_chance = { base = 10 }
	}
}

######################################################################
# 0110: Trampled Fields (risk)
######################################################################
ppr_preaching.0110 = {
	type = character_event
	title = ppr_preaching.0110.t
	desc = ppr_preaching.0110.desc
	theme = unfriendly
	left_portrait = {
		character = root
		animation = shock
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = disapproval
	}
	override_background = { reference = farmland }

	trigger = {
		ppr_preaching_friendly_land_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
	}

	# Pay for the damage.
	option = {
		name = ppr_preaching.0110.a
		trigger = {
			short_term_gold >= ppr_preaching_compensation_value
			ppr_preaching_holder_present_trigger = yes
		}
		pay_short_term_gold = {
			target = scope:preach_holder
			gold = ppr_preaching_compensation_value
		}
		ppr_preaching_please_holder_effect = yes
		stress_impact = {
			greedy = minor_stress_impact_gain
			just = minor_stress_impact_loss
		}
		ai_chance = { base = 40 }
	}

	# Pray with the farmers for a good harvest.
	option = {
		name = ppr_preaching.0110.b
		skill = learning
		duel = {
			skill = learning
			value = ppr_preaching_flock_difficulty_value
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0110.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = ppr_preaching.0110.b.success
					left_icon = root
					right_icon = scope:preach_county
					add_piety = minor_piety_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = ppr_preaching.0110.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ppr_preaching.0110.b.failure
					left_icon = root
					right_icon = scope:preach_county
					ppr_preaching_trample_fields_effect = yes
					ppr_preaching_annoy_holder_effect = { OPINION = -10 }
					add_piety = minor_piety_loss
				}
			}
		}
		ai_chance = { base = 40 }
	}

	# The Lord's work has its price.
	option = {
		name = ppr_preaching.0110.c
		ppr_preaching_trample_fields_effect = yes
		ppr_preaching_annoy_holder_effect = { OPINION = -15 }
		stress_impact = {
			just = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			greedy = minor_stress_impact_loss
		}
		ai_chance = { base = 20 }
	}
}

######################################################################
# 0120: Fever among the Crowd (risk)
######################################################################
ppr_preaching.0120 = {
	type = character_event
	title = ppr_preaching.0120.t
	desc = ppr_preaching.0120.desc
	theme = medicine
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = worry
	}
	lower_right_portrait = {
		trigger = { exists = scope:ppr_fever_helper }
		character = scope:ppr_fever_helper
	}
	override_background = { reference = village }

	trigger = {
		ppr_preaching_friendly_land_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
		random_courtier = {
			limit = { ppr_preaching_fever_helper_trigger = yes }
			save_scope_as = ppr_fever_helper
		}
	}

	# Tend the sick with my own hands.
	option = {
		name = ppr_preaching.0120.a
		add_piety = medium_piety_gain
		if = { limit = { has_pam_dlc_trigger = yes } change_spiritual_fulfillment = minor_spiritual_fulfillment_value }
		scope:preach_barony.title_province = {
			add_province_modifier = {
				modifier = ppr_tended_sick_modifier
				years = 5
			}
		}
		random = {
			chance = 20
			contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
		}
		stress_impact = {
			compassionate = minor_stress_impact_loss
			craven = medium_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 40
			ai_value_modifier = { ai_compassion = 1 }
		}
	}

	# Send one of my followers to care for them.
	option = {
		name = ppr_preaching.0120.b
		trigger = { exists = scope:ppr_fever_helper }
		add_piety = minor_piety_gain
		scope:preach_barony.title_province = {
			add_province_modifier = {
				modifier = ppr_tended_sick_modifier
				years = 5
			}
		}
		scope:ppr_fever_helper = {
			random = {
				chance = 25
				contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
			}
		}
		stress_impact = {
			compassionate = miniscule_stress_impact_gain
		}
		ai_chance = { base = 40 }
	}

	# Keep the camp well away from them.
	option = {
		name = ppr_preaching.0120.c
		add_piety = minor_piety_loss
		stress_impact = {
			compassionate = medium_stress_impact_gain
			zealous = minor_stress_impact_gain
			craven = minor_stress_impact_loss
		}
		ai_chance = {
			base = 20
			ai_value_modifier = { ai_compassion = -1 }
		}
	}
}

######################################################################
# 0200: Stones and Insults (hostile land)
######################################################################
ppr_preaching.0200 = {
	type = character_event
	title = ppr_preaching.0200.t
	desc = ppr_preaching.0200.desc
	theme = unfriendly
	left_portrait = {
		character = root
		animation = pain
	}
	right_portrait = {
		trigger = { exists = scope:preach_holder }
		character = scope:preach_holder
		animation = schadenfreude
	}
	override_background = { reference = village }

	trigger = {
		ppr_preaching_hostile_land_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
	}

	# Turn the other cheek, and keep preaching.
	option = {
		name = ppr_preaching.0200.a
		add_piety = medium_piety_gain
		if = { limit = { has_pam_dlc_trigger = yes } change_spiritual_fulfillment = minor_spiritual_fulfillment_value }
		stress_impact = {
			base = minor_stress_impact_gain
			wrathful = medium_stress_impact_gain
			patient = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
		}
		ai_chance = {
			base = 40
			ai_value_modifier = { ai_zeal = 0.5 }
		}
	}

	# Answer them in kind: their gods are deaf and their lord a fool!
	option = {
		name = ppr_preaching.0200.b
		add_prestige = minor_prestige_gain
		if = {
			limit = { ppr_preaching_holder_present_trigger = yes }
			random_list = {
				35 = {
					desc = ppr_preaching.0200.b.insulted
					scope:preach_holder = {
						add_opinion = {
							modifier = ppr_insulted_preacher_opinion
							target = root
						}
					}
				}
				65 = {
					desc = ppr_preaching.0200.b.unnoticed
				}
			}
		}
		stress_impact = {
			wrathful = minor_stress_impact_loss
			calm = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = { ai_boldness = 0.5 }
		}
	}

	# Slip away before it gets worse.
	option = {
		name = ppr_preaching.0200.c
		trigger = { short_term_gold >= ppr_preaching_small_alms_value }
		remove_short_term_gold = ppr_preaching_small_alms_value
		stress_impact = {
			brave = minor_stress_impact_gain
			craven = minor_stress_impact_loss
		}
		ai_chance = {
			base = 30
			ai_value_modifier = { ai_boldness = -0.5 }
		}
	}
}

######################################################################
# 0210: A Secret Flock (hostile land)
######################################################################
ppr_preaching.0210 = {
	type = character_event
	title = ppr_preaching.0210.t
	desc = ppr_preaching.0210.desc
	theme = faith
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:ppr_secret_believer
		animation = beg
	}
	override_background = { reference = alley_night }

	trigger = {
		ppr_preaching_hostile_land_valid_trigger = yes
	}

	immediate = {
		ppr_preaching_event_setup_effect = yes
		create_character = {
			template = generic_peasant_character
			location = scope:preach_barony.title_province
			culture = scope:preach_county.culture
			faith = root.faith
			rite = root.rite
			save_scope_as = ppr_secret_believer
		}
		hidden_effect = {
			scope:ppr_secret_believer = { add_character_flag = peasant_outfit }
		}
	}

	# Leave them alms, and my blessing.
	option = {
		name = ppr_preaching.0210.a
		trigger = { short_term_gold >= ppr_preaching_compensation_value }
		remove_short_term_gold = ppr_preaching_compensation_value
		add_piety = medium_piety_gain
		if = { limit = { has_pam_dlc_trigger = yes } change_spiritual_fulfillment = minor_spiritual_fulfillment_value }
		ppr_preaching_dismiss_character_effect = { CHARACTER = scope:ppr_secret_believer }
		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		ai_chance = { base = 40 }
	}

	# Come with us. You will be safe among the pilgrims.
	option = {
		name = ppr_preaching.0210.b
		ppr_camp_events_recruit_effect = {
			CHARACTER = scope:ppr_secret_believer
			OPINION = 40
		}
		add_piety = minor_piety_gain
		stress_impact = {
			compassionate = minor_stress_impact_loss
			paranoid = minor_stress_impact_gain
		}
		ai_chance = { base = 40 }
	}

	# I cannot help you. Keep your faith hidden.
	option = {
		name = ppr_preaching.0210.c
		add_piety = minor_piety_loss
		ppr_preaching_dismiss_character_effect = { CHARACTER = scope:ppr_secret_believer }
		stress_impact = {
			compassionate = medium_stress_impact_gain
			zealous = minor_stress_impact_gain
		}
		ai_chance = { base = 10 }
	}
}

######################################################################
# 9000 (hidden) Missionaries just raised: take their provisions at once
######################################################################
# Triggered (1 day later, once the army exists) by the raise buttons through the scripted GUI
# ppr_missionaries_raised_gui (common/scripted_guis/ppr_preaching_mode_guis.txt). The engine has no
# on_action for raising an army, and without this the provisions were only taken on the first move
# or the monthly pulse, so the camp could still spend them in the meantime. Root = the preacher.
ppr_preaching.9000 = {
	type = character_event
	hidden = yes

	trigger = {
		is_landless_adventurer = yes
		has_realm_law = ppr_camp_purpose_pilgrims
	}

	immediate = {
		every_army = {
			limit = { is_barter_army = yes }
			save_scope_as = army
			root = {
				if = {
					limit = { ppr_missionaries_at_camp_trigger = yes }
					ppr_protect_camp_county_effect = yes
					ppr_missionaries_home_effect = yes
				}
				else = {
					# Raised away from the camp: they take their provisions now, wherever the camp is.
					ppr_load_mission_rations_effect = yes
				}
			}
		}
		ppr_refresh_missionary_purse_effect = yes
	}
}

######################################################################
# 9001 (hidden) Missionaries disbanded: their provisions go back to the camp
######################################################################
# Triggered by the disband buttons through ppr_missionaries_disbanded_gui. A single disband first goes
# through the vanilla confirmation popup, so while a missionary army still exists the event looks again
# the next day, for a week at most (the quarterly pulse remains the safety net). Root = the preacher.
ppr_preaching.9001 = {
	type = character_event
	hidden = yes

	trigger = {
		is_landless_adventurer = yes
		has_realm_law = ppr_camp_purpose_pilgrims
	}

	immediate = {
		if = {
			limit = { NOT = { any_army = { is_barter_army = yes } } }
			# No missionaries left: everything they carried goes back to the camp.
			ppr_keep_mission_rations_reserve_effect = yes
			ppr_refresh_missionary_purse_effect = yes
			remove_variable ?= ppr_disband_checks
		}
		else_if = {
			limit = {
				has_variable = ppr_disband_checks
				var:ppr_disband_checks < 7
			}
			change_variable = { name = ppr_disband_checks add = 1 }
			trigger_event = {
				id = ppr_preaching.9001
				days = 1
			}
		}
		else = {
			remove_variable ?= ppr_disband_checks
		}
	}
}
