﻿# Pilgrims and Preachers - preaching mode of the missionaries, chosen from the army window
# (gui/window_army.gui, hbox "ppr_preaching_mode") or from the military view next to the button raising
# the missionaries (gui/window_military.gui), like the raid intent of raiders.
#   For alms (default): sermons earn gold, paid back in the camp's county.
#   For the faith:      sermons earn piety instead. Stored as the character variable ppr_preach_for_piety.
# Read by ppr_on_preaching_completion (common/on_action/ppr_preaching_on_actions.txt).

ppr_toggle_preaching_mode_gui = {
	scope = character

	is_shown = {
		is_landless_adventurer = yes
		has_realm_law = ppr_camp_purpose_pilgrims
	}

	is_valid = {
		is_landless_adventurer = yes
		has_realm_law = ppr_camp_purpose_pilgrims
	}

	effect = {
		if = {
			limit = { has_variable = ppr_preach_for_piety }
			remove_variable = ppr_preach_for_piety
		}
		else = {
			set_variable = ppr_preach_for_piety
		}
	}
}

# "Disband All" accepted in the warning (gui/hud.gui, ppr_disband_all_warning): no missionary
# carries anything any more.
ppr_clear_alms_on_the_road_gui = {
	scope = character

	effect = {
		if = {
			limit = { has_variable = ppr_alms_on_the_road }
			remove_variable = ppr_alms_on_the_road
		}
	}
}

# Raise buttons for missionaries (gui/window_military.gui, gui/window_rally_points.gui, and the
# "toggle bartering" button of gui/window_army.gui): the provisions are taken from the camp as soon as
# the army exists (hidden event ppr_preaching.9000, 1 day later), not at its first move.
ppr_missionaries_raised_gui = {
	scope = character

	is_valid = {
		is_landless_adventurer = yes
		has_realm_law = ppr_camp_purpose_pilgrims
	}

	effect = {
		trigger_event = {
			id = ppr_preaching.9000
			days = 1
		}
	}
}

# Disband buttons (gui/window_army.gui, gui/hud.gui, gui/window_military.gui, and the disband warnings):
# the provisions the missionaries carried go back to the camp as soon as they are gone (hidden event
# ppr_preaching.9001), instead of waiting for the quarterly pulse.
ppr_missionaries_disbanded_gui = {
	scope = character

	is_valid = {
		is_landless_adventurer = yes
		has_realm_law = ppr_camp_purpose_pilgrims
	}

	effect = {
		set_variable = { name = ppr_disband_checks value = 0 }
		trigger_event = {
			id = ppr_preaching.9001
			days = 1
		}
	}
}
