﻿#####################################################################
# EFFECT LIST
#####################################################################

# Effects used in the Adventure Inspiration

start_adventure_effect = {

	#To save the location so we can use it in the effect checking the distance
	set_adventure_distance_variable_effect = { # Figure out how far it is there
		ADVENTURER = $ADVENTURER$
		DESTINATION = $LOCATION$
	}

	$ADVENTURER$ = {
		# Set a variable to check for availability 
		set_variable = gone_adventuring

		# Set up the event cycle
		# To trigger the event that progresses the inspiration
		trigger_event = {
			id = fund_inspiration.0053
			days = 1
		}
		# Fallback to make sure the inspiration is handled somehow if it goes on for too long
		trigger_event = {
			id = fund_inspiration.0054
			years = 10
		}
	}
}


set_adventure_distance_variable_effect = {
	# Requires ADVENTURER = character
	# Requires DESTINATION = barony_title
	$ADVENTURER$.location = {
		save_temporary_scope_as = start_barony
	}
	# Calculate distance to the destination
	# The value set indicates how long time it will take for the adventurer to come back
	if = {
		limit = {
			scope:start_barony = {
				squared_distance = {
					target = $DESTINATION$
					value > long_adventure_max_length
				}
			}
		}
		set_variable = {
			name = adventure_distance
			value = very_long_adventure_var
		}
	}
	else_if = {
		limit = {
			scope:start_barony = {
				squared_distance = {
					target = $DESTINATION$
					value > medium_adventure_max_length
				}
			}
		}
		set_variable = {
			name = adventure_distance
			value = long_adventure_var
		}
	}
	else_if = {
		limit = {
			scope:start_barony = {
				squared_distance = {
					target = $DESTINATION$
					value > short_adventure_max_length
				}
			}
		}
		set_variable = {
			name = adventure_distance
			value = medium_adventure_var
		}
	}
	else = {
		set_variable = {
			name = adventure_distance
			value = short_adventure_var
		}
	}
}
