﻿namespace = mapmaking

### Map Choice Event
mapmaking.0001 = {
	type = character_event
	content_source = dlc_015
	title = mapmaking.0001.t
	desc = mapmaking.0001.desc
	theme = realm
	override_background = { reference = study }
	
	left_portrait = {
		character = root
		animation = writing
	}


	immediate = {
		#We care about: visited capitals of foreign rulers
		#Visited vassal capitals
		#Visited domain provinces
		#Visited points of interest
		random_in_list = {
			#Capitals are already tracked since they are points of interest
			variable = visited_poi
			limit = {
				this = county.holder.top_liege.capital_province
				county.holder.top_liege != root.top_liege
			}
			save_scope_as = foreign_capital_map_target
			kingdom = {
				save_scope_as = foreign_kingdom_map_target
			}
		}
		random_in_list = {
			#And now we save other types of Point of Interest
			variable = visited_poi
			limit = { #We prefer foreign points of interest
				OR = {
					has_building_with_flag = travel_point_of_interest_religious
					has_building_with_flag = travel_point_of_interest_learning
					has_building_with_flag = travel_point_of_interest_economic
					has_building_with_flag = travel_point_of_interest_martial
					has_building_with_flag = travel_point_of_interest_diplomatic
					has_building_with_flag = travel_point_of_interest_wonder
					has_building_with_flag = travel_point_of_interest_natural_feature
				}
				empire != root.capital_province.empire
			}
			alternative_limit = { #We prefer foreign points of interest
				OR = {
					has_building_with_flag = travel_point_of_interest_religious
					has_building_with_flag = travel_point_of_interest_learning
					has_building_with_flag = travel_point_of_interest_economic
					has_building_with_flag = travel_point_of_interest_martial
					has_building_with_flag = travel_point_of_interest_diplomatic
					has_building_with_flag = travel_point_of_interest_wonder
					has_building_with_flag = travel_point_of_interest_natural_feature
				}
				kingdom != root.capital_province.kingdom
			}
			alternative_limit = {
				OR = {
					has_building_with_flag = travel_point_of_interest_religious
					has_building_with_flag = travel_point_of_interest_learning
					has_building_with_flag = travel_point_of_interest_economic
					has_building_with_flag = travel_point_of_interest_martial
					has_building_with_flag = travel_point_of_interest_diplomatic
					has_building_with_flag = travel_point_of_interest_wonder
					has_building_with_flag = travel_point_of_interest_natural_feature
				}
				duchy != root.capital_province.duchy
			}
			alternative_limit = {
				OR = {
					has_building_with_flag = travel_point_of_interest_religious
					has_building_with_flag = travel_point_of_interest_learning
					has_building_with_flag = travel_point_of_interest_economic
					has_building_with_flag = travel_point_of_interest_martial
					has_building_with_flag = travel_point_of_interest_diplomatic
					has_building_with_flag = travel_point_of_interest_wonder
					has_building_with_flag = travel_point_of_interest_natural_feature
				}
			}
			save_scope_as = poi_map_target
		}
		random_in_list = {
			variable = mapmaking_location_list
			limit = {
				county.holder = root
				county != root.capital_province.county #We cannot in good conscience let someone map their own capital county with this decision
			}
			save_scope_as = visited_own_county
		}
		random_in_list = {
			variable = mapmaking_location_list
			limit = {
				county.holder != root
				county.holder.liege = root
				this = county.holder.capital_province
			}
			save_scope_as = visited_own_vassal
			county.holder.primary_title = {
				save_scope_as = visited_own_vassal_title
			}
		}
	}

	option = { 
		name = mapmaking.0001.a
		trigger = {
			exists = scope:visited_own_county
		} #Check for having visited own county
		custom_tooltip = mapmaking.0001.a.tt
		scope:visited_own_county = { save_scope_as = background_terrain_scope }
		trigger_event = {
			id = mapmaking.0010
			days = 5
		}
	}
	option = { 
		name = mapmaking.0001.b
		trigger = {
			exists = scope:visited_own_vassal
		} #Check for having visited vassal capital county
		custom_tooltip = mapmaking.0001.b.tt
		scope:visited_own_vassal = { save_scope_as = background_terrain_scope }
		trigger_event = {
			id = mapmaking.0020
			days = 5
		}
	}
	option = { 
		name = mapmaking.0001.c 
		trigger = {
			exists = scope:poi_map_target
			trigger_if = {
				limit = { exists = scope:visited_own_vassal }
				scope:visited_own_vassal != scope:poi_map_target
			}
		} #Check for having visited special county
		custom_tooltip = mapmaking.0001.c.tt
		scope:poi_map_target = { save_scope_as = background_terrain_scope }
		trigger_event = {
			id = mapmaking.0030
			days = 5
		}
	}
	option = { 
		name = mapmaking.0001.d
		trigger = {
			exists = scope:foreign_capital_map_target
			trigger_if = {
				limit = { exists = scope:poi_map_target }
				scope:foreign_capital_map_target != scope:poi_map_target
			}
		} #Check for having visited foreign capital county
		custom_tooltip = mapmaking.0001.d.tt
		scope:foreign_capital_map_target = { save_scope_as = background_terrain_scope }
		trigger_event = {
			id = mapmaking.0040
			days = 5
		}
	}
}

#Choice 1a - Own County
mapmaking.0010 = {
	type = character_event
	content_source = dlc_015
	title = mapmaking.0010.t
	desc = mapmaking.0010.desc
	theme = realm
	override_background = {
		trigger = {
			exists = scope:background_market_scope
		}
		reference = market_scope
	}
	override_background = {
		trigger = {
			exists = scope:background_temple_scope 
		}
		reference = temple_scope 
	}
	override_background = {
		trigger = {
			exists = scope:courtyard_scope 
		}
		reference = courtyard_scope 
	}
	override_background = {
		trigger = {
			scope:background_terrain_scope = {
				has_holding_type = tribal_holding
			}
		}
		reference = market_tribal 
	}
	
	left_portrait = {
		character = root
		animation = writing #We change the background in each event but not the animation, the background is what root is writing about
	}


	immediate = {
		scope:background_terrain_scope = {
			switch = {
				trigger = has_holding_type
				city_holding = {
					save_scope_as = background_market_scope
				}
				church_holding = {
					holder = {
						save_scope_as = background_temple_scope
					}
				}
				castle_holding = {
					save_scope_as = courtyard_scope
				}
			}
		}
	}

	#All options are stronger the more of your provinces you visited.

	option = { 
		name = mapmaking.0010.a
		custom_tooltip = mapmaking.0010.a.tt
		#Boosted by Stewardship
		save_scope_value_as = {
			name = own_domain_bonus
			value = flag:growth
		}
	}
	option = { 
		name = mapmaking.0010.b
		custom_tooltip = mapmaking.0010.b.tt
		#Boosted by Danger Track xp
		save_scope_value_as = {
			name = own_domain_bonus
			value = flag:defensive
		}
	}
	after = {
		trigger_event = {
			id = mapmaking.0004
			days = 5
		}
	}
}

#Choice 1b - Vassal Capital County
mapmaking.0020 = {
	type = character_event
	content_source = dlc_015
	title = mapmaking.0020.t
	desc = mapmaking.0020.desc
	theme = realm
	override_background = {
		reference = throne_room_scope
	}
	
	left_portrait = {
		character = root
		animation = writing #We change the background in each event but not the animation, the background is what root is writing about
	}


	immediate = {
		scope:background_terrain_scope.county.holder = {
			save_scope_as = background_throne_room_scope
		}
	}

	#All options are stronger the more of your vassal capitals you have visited.


	option = { 
		name = mapmaking.0020.a
		custom_tooltip = mapmaking.0020.a.tt
		save_scope_value_as = {
			name = own_vassal_focus
			value = flag:dread
		}
		#Danger XP increases the outcome of this option
	}
	option = { 
		name = mapmaking.0020.b
		custom_tooltip = mapmaking.0020.b.tt
		save_scope_value_as = {
			name = own_vassal_focus
			value = flag:opinion
		}
		#Diplomacy increases the outcome of this option
	}
	option = { 
		name = mapmaking.0020.c
		custom_tooltip = mapmaking.0020.c.tt
		save_scope_value_as = {
			name = own_vassal_focus
			value = flag:intrigue
		}
		#Intrigue increases the outcome of this option
	}
	after = {
		trigger_event = {
			id = mapmaking.0004
			days = 5
		}
	}
}

#Choice 1c - Point of Interest
mapmaking.0030 = {
	type = character_event
	content_source = dlc_015
	title = mapmaking.0030.t
	desc = mapmaking.0030.desc
	theme = realm
	override_background = {
		trigger = {
			scope:background_terrain_scope.barony = {
				is_holy_site = no
			}
			NOT = { scope:background_terrain_scope = province:4828 }
		}
		reference = terrain_scope
	}
	override_background = {
		trigger = {
			scope:background_terrain_scope.barony = {
				is_holy_site = yes
			}
		}
		reference = holy_site_scope
	}
	override_background = {
		trigger = {
			scope:background_terrain_scope = province:4828 #Baghdad
		}
		reference = ep2_holy_site_mena
	}
	
	left_portrait = {
		character = root
		animation = writing #We change the background in each event but not the animation, the background is what root is writing about
	}

	option = { 
		name = mapmaking.0030.a
		custom_tooltip = mapmaking.0030.a.tt
		#Based on traveller danger XP
		save_scope_value_as = {
			name = poi_focus
			value = flag:safety_speed
		}
	}
	option = { 
		name = mapmaking.0030.b
		custom_tooltip = mapmaking.0030.b.tt
		#Based on what PoI type
		#Better with Traveller XP
		save_scope_value_as = {
			name = poi_focus
			value = flag:location_based
		}
	}
	after = {
		trigger_event = {
			id = mapmaking.0004
			days = 5
		}
	}
}

#Choice 1d - Foreign Kingdom Capital County
mapmaking.0040 = {
	type = character_event
	content_source = dlc_015
	title = mapmaking.0040.t
	desc = mapmaking.0040.desc
	theme = realm
	override_background = {
		reference = throne_room_scope
	}
	
	left_portrait = {
		character = root
		animation = writing #We change the background in each event but not the animation, the background is what root is writing about
	}


	immediate = {
		scope:background_terrain_scope.county.holder = {
			save_scope_as = background_throne_room_scope
		}
		mapmaking_mythical_lie_effect = yes
	}

	option = { 
		name = mapmaking.0040.a
		custom_tooltip = mapmaking.0040.a.tt
		save_scope_value_as = {
			name = kingdom_focus
			value = flag:court_life
		}
		#Better with traveller XP and knowing Language and Court Language
	}
	option = { 
		name = mapmaking.0040.b
		custom_tooltip = mapmaking.0040.b.tt
		save_scope_value_as = {
			name = kingdom_focus
			value = flag:people_focus
		}
		#Better with Traveller Danger XP and Knowing Culture's Language
	}
	option = { 
		name = mapmaking.0040.c
		custom_tooltip = mapmaking.0040.c.tt
		trigger = {
			has_trait = eccentric
		}
		save_scope_value_as = {
			name = kingdom_focus
			value = flag:mythical_creatures
		}
		#Better with Traveller XP and Levels of Fame
	}
	after = {
		trigger_event = {
			id = mapmaking.0004
			days = 5
		}
	}
}

#Choice 3 - Based on the Dangers of the Province itself
mapmaking.0004 = {
	type = character_event
	content_source = dlc_015
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:fighting
				}
				desc = mapmaking.0004.fighting.t
			}
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:snow
				}
				desc = mapmaking.0004.snow.t
			}
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:heat
				}
				desc = mapmaking.0004.heat.t
			}
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:monsoon
				}
				desc = mapmaking.0004.monsoon.t
			}
			desc = mapmaking.0004.t
		}
	}
	desc = {
		desc = mapmaking.0004.desc.intro
		#Potential Dangers
		#May or may not exist, set in immediate
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:fighting
				}
				desc = mapmaking.0004.fighting.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:snow
				}
				desc = mapmaking.0004.snow.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:heat
				}
				desc = mapmaking.0004.heat.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_danger ?= flag:monsoon
				}
				desc = mapmaking.0004.monsoon.desc
			}
		}
		#Terrain - Always Present
		#What to display is decided in immediate
		first_valid = {
			triggered_desc = { #Forest
				trigger = {
					scope:terrain_category = flag:deep_forest
				}
				desc = mapmaking.0004.terrain_deep_forests.desc
			}
			triggered_desc = { #Open
				trigger = {
					scope:terrain_category = flag:open_terrain
				}
				desc = mapmaking.0004.terrain_open.desc
			}
			triggered_desc = { #Open
				trigger = {
					scope:terrain_category = flag:steppes
				}
				desc = mapmaking.0004.terrain_steppes.desc
			}
			triggered_desc = { #Farmlands
				trigger = {
					scope:terrain_category = flag:farmlands
				}
				desc = mapmaking.0004.terrain_open_farmland.desc
			}
			triggered_desc = { #Jungle
				trigger = {
					scope:terrain_category = flag:jungle
				}
				desc = mapmaking.0004.terrain_jungle.desc
			}
			triggered_desc = { #Undulating
				trigger = {
					scope:terrain_category = flag:undulating
				}
				desc = mapmaking.0004.terrain_undulating.desc
			}
			triggered_desc = { #Desert
				trigger = {
					scope:terrain_category = flag:desert
				}
				desc = mapmaking.0004.terrain_desert.desc
			}
			triggered_desc = { #Wetlands
				trigger = {
					scope:terrain_category = flag:wetlands
				}
				desc = mapmaking.0004.terrain_wetlands.desc
			}
			desc = mapmaking.0004.desc.generic_fallback #Fallback if we somehow have no terrain
		}
	}
	theme = realm
	
	override_background = {
		trigger = {
			scope:potential_danger ?= flag:fighting
		}
		reference = battlefield
	}
	override_background = {
		trigger = {
			scope:terrain_category = flag:farmlands
		}
		reference = farmland
	}
	override_background = {
		reference = wilderness_scope #Fallback
	}
	
	override_effect_2d = {
		trigger = {
			scope:potential_danger ?= flag:fighting
		}
		reference = flies #Fits the battlefield
	}
	widget = {
		is_shown = {
			scope:potential_danger ?= flag:cold
		}
		gui = "event_window_widget_vfx_snow"
		container = "foreground_shader_vfx_container"
	}
	override_effect_2d = {
		trigger = {
			scope:potential_danger ?= flag:heat
		}
		reference = legend_glow	#Sun 
	}
	override_effect_2d = {
		trigger = {
			scope:potential_danger ?= flag:monsoon
		}
		reference = rain	
	}
	override_effect_2d = {
		trigger = {
			scope:terrain_category = flag:wetlands
			NOT = { exists = scope:potential_danger }
		}
		reference = fog	#Make the Wetland look more menacing
	}

	

	left_portrait = {
		character = root
		animation = writing #We change the background in each event but not the animation, the background is what root is writing about
	}


	immediate = {
		scope:background_terrain_scope = {
			save_scope_as = background_wilderness_scope

			#Extra potential dangers depending on location
			random_list = {
				1 = {
					trigger = {
						OR = {
							county = { county_control < 50 }
							county.holder.top_liege = {
								is_at_war = yes
							}
							county.holder = {
								is_at_war = yes
							}
						}
					}
					save_scope_value_as = {
						name = potential_danger
						value = flag:fighting
					}
				}
				1 = {
					trigger = {
						OR = {
							geographical_region = world_tibet
							geographical_region = world_europe_north
							geographical_region = world_steppe
							terrain = taiga
						}
					}
					save_scope_value_as = {
						name = potential_danger
						value = flag:cold
					}
				}
				1 = {
					trigger = {
						OR = {
							geographical_region = world_middle_east
							geographical_region = world_india
							geographical_region = world_burma
							geographical_region = world_africa
							geographical_region = world_asia_southeast
							is_desert_trigger = yes
							terrain = jungle
						}
					}
					save_scope_value_as = {
						name = potential_danger
						value = flag:heat
					}	
				}
				1 = {
					trigger = {
						OR = {
							geographical_region = world_india
							geographical_region = world_burma
							geographical_region = world_asia_southeast
						}
					}
					save_scope_value_as = {
						name = potential_danger
						value = flag:monsoon
					}
				}
			}

			#What terrain do we describe?
			#This is done here instead of just as triggers in the description because we don't want to replicate the check again when generating the artifact:
			if = {
				limit = {
					scope:background_wilderness_scope = {
						OR = {
							terrain = taiga
							terrain = forest
						}
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:deep_forest
				}
			}
			else_if = {
				limit = {
					scope:background_wilderness_scope = {
						OR = {
							graphical_plains_trigger = yes
							graphical_drylands_trigger = yes
						}
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:open_terrain
				}
			}
			else_if = {
				limit = {
					scope:background_wilderness_scope = {
						terrain = farmlands
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:farmlands
				}
			}
			else_if = {
				limit = {
					scope:background_wilderness_scope = {
						graphical_wilderness_jungle_trigger = yes
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:jungle
				}
			}
			else_if = {
				limit = {
					scope:background_wilderness_scope = {
						OR = {
							graphical_hills_trigger = yes
							graphical_wilderness_mountains_trigger = yes
						}
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:undulating
				}
			}
			else_if = {
				limit = {
					scope:background_wilderness_scope = {
						graphical_wilderness_desert_trigger = yes
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:desert
				}
			}
			else_if = {
				limit = {
					scope:background_wilderness_scope = {
						graphical_wilderness_wetlands_trigger = yes
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:wetlands
				}
			}
			else_if = {
				limit = {
					scope:background_wilderness_scope = {
						graphical_wilderness_steppe_trigger = yes
					}
				}
				save_scope_value_as = {
					name = terrain_category
					value = flag:steppes
				}
			}
		}
	}

	option = { 
		name = mapmaking.0004.a #Terrain, this can always be picked
		custom_tooltip = mapmaking.0004.a.tt
		save_scope_value_as = {
			name = danger_type
			value = flag:terrain
		}
	}
	option = { 
		name = mapmaking.0004.b
		custom_tooltip = mapmaking.0004.b.tt
		trigger = {
			scope:potential_danger ?= flag:fighting
		}
		save_scope_value_as = {
			name = danger_type
			value = flag:fighting
		}
	}
	option = { 
		name = mapmaking.0004.c
		custom_tooltip = mapmaking.0004.c.tt
		trigger = {
			scope:potential_danger ?= flag:cold
		}
		save_scope_value_as = {
			name = danger_type
			value = flag:cold
		}
	}
	option = { 
		name = mapmaking.0004.d
		custom_tooltip = mapmaking.0004.d.tt
		trigger = {
			scope:potential_danger ?= flag:heat
		}
		save_scope_value_as = {
			name = danger_type
			value = flag:heat
		}
	}
	option = { 
		name = mapmaking.0004.e
		custom_tooltip = mapmaking.0004.e.tt
		trigger = {
			scope:potential_danger ?= flag:monsoon
		}
		save_scope_value_as = {
			name = danger_type
			value = flag:monsoon
		}
	}
	after = {
		trigger_event = {
			id = mapmaking.1000
			days = 5
		}
	}
}

# Finish Event - What map did we get out of this?
mapmaking.1000 = {
	type = character_event
	content_source = dlc_015
	title = mapmaking.1000.t
	desc = mapmaking.1000.desc
	theme = realm

	override_background = {
		trigger = {
			scope:background_terrain_scope.barony = {
				is_holy_site = no
			}
			NOT = { scope:background_terrain_scope = province:4828 }
		}
		reference = terrain_scope
	}
	override_background = {
		trigger = {
			scope:background_terrain_scope.barony = {
				is_holy_site = yes
			}
		}
		reference = holy_site_scope
	}
	override_background = {
		trigger = {
			scope:background_terrain_scope = province:4828 #Baghdad
		}
		reference = ep2_holy_site_mena
	}
	
	left_portrait = {
		character = root
		animation = writing #We change the background in each event but not the animation, the background is what root is writing about
	}
	artifact = { # To display the artifact in the event-window
		trigger = { exists = scope:newly_created_artifact }
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}

	immediate = {
		save_scope_as = author
		#First we make the artifact, then we assign effects and descriptions.
		hidden_effect = {
			if = {
				limit = {
					artifacts_use_indian_books_trigger = yes
				}
				create_artifact = {
					name = map_artifact_name
					type = journal
					creator = root
					description = map_artifact_beginning_far_eastern
					visuals = indian_book
					modifier = character_travel_speed_1
					save_scope_as = newly_created_artifact
					wealth = 50
					quality = 50
				}
			}
			else = {
				create_artifact = {
					name = map_artifact_name
					type = journal
					creator = root
					description = map_artifact_beginning_western
					visuals = book
					modifier = character_travel_speed_1
					save_scope_as = newly_created_artifact
					wealth = 50
					quality = 50
				}
			}

			hidden_effect_new_object = {

				if = {
					limit = {
						scope:background_terrain_scope.county.holder.top_liege = root.top_liege
					}
					scope:newly_created_artifact = {
						set_artifact_description = map_artifact_beginning_internal
					}
				}
				else = {
					scope:newly_created_artifact = {
						set_artifact_description = map_artifact_beginning_external
					}
				}

				#Dangers of Province:
				if = { #Terrain
					#Each terrain gives 1 combat modifier and 1 travel danger modifier
					limit = {
						scope:danger_type = flag:terrain
					}
					switch = {
						trigger = scope:terrain_category
						flag:deep_forest = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_forests
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									forest = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_forest_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_forest_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_forest_advantage_3_modifier
												}
											}
										}
									}
									taiga = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_taiga_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_taiga_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_taiga_advantage_3_modifier
												}
											}
										}
									}
								}
							}
						}
						flag:open_terrain = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_open
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									drylands = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_drylands_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_drylands_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_drylands_advantage_3_modifier
												}
											}
										}
									}
									plains = {
										scope:newly_created_artifact = {
											random_list = {
												65 = {
													add_artifact_modifier = artifact_plains_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_plains_advantage_3_modifier
												}
											}
										}
									}
								}
							}
						}
						flag:farmlands = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_farmlands

								random_list = {
									65 = {
										add_artifact_modifier = artifact_farmlands_advantage_2_modifier
									}
									35 = {
										add_artifact_modifier = artifact_farmlands_advantage_3_modifier
									}
								}
							}
						}
						flag:jungle = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_jungle
								add_artifact_modifier = artifact_jungle_danger_travel_modifier
								random_list = {
									65 = {
										add_artifact_modifier = artifact_jungle_advantage_2_modifier
									}
									35 = {
										add_artifact_modifier = artifact_jungle_advantage_3_modifier
									}
								}
							}
						}
						flag:undulating = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_undulating
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									hills = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_hills_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_hills_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_hills_advantage_3_modifier
												}
											}
										}
									}
									mountains = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_mountains_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_mountains_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_mountains_advantage_3_modifier
												}
											}
										}
									}
								}
							}
						}
						flag:desert = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_desert
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									desert = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_desert_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_desert_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_desert_advantage_3_modifier
												}
											}
										}
									}
									desert_mountains = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_desert_mountains_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_desert_mountains_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_desert_mountains_advantage_3_modifier
												}
											}
										}
									}
									oasis = { #Too rare so we give desert
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_desert_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_desert_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_desert_advantage_3_modifier
												}
											}
										}
									}
								}
							}
						}
						flag:wetlands = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_wetlands
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									floodplains = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_floodplains_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_floodplains_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_floodplains_advantage_3_modifier
												}
											}
										}
									}
									wetlands = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_wetlands_danger_travel_modifier
											random_list = {
												65 = {
													add_artifact_modifier = artifact_wetlands_advantage_2_modifier
												}
												35 = {
													add_artifact_modifier = artifact_wetlands_advantage_3_modifier
												}
											}
										}
									}
								}
							}
						}
						flag:steppes = {
							scope:newly_created_artifact = {
								set_artifact_description = map_artifact_danger_type_steppes
								add_artifact_modifier = artifact_steppe_danger_travel_modifier
								random_list = {
									65 = {
										add_artifact_modifier = artifact_steppe_advantage_2_modifier
									}
									35 = {
										add_artifact_modifier = artifact_steppe_advantage_3_modifier
									}
								}
							}
						}
					}
				}
				if = { #Fighting
					limit = {
						scope:danger_type = flag:fighting
					}
					scope:newly_created_artifact = {
						set_artifact_description = map_artifact_danger_type_fighting
						add_artifact_modifier = artifact_travel_safety_2
						random_list = {
							25 = { add_artifact_modifier = artifact_controlled_province_advantage_3_modifier }
							25 = { add_artifact_modifier = artifact_enemy_hard_casualty_modifier_1_modifier }
							50 = { add_artifact_modifier =character_travel_speed_1 }
						}
					}
				}
				if = { #Cold
					limit = {
						scope:danger_type = flag:cold
					}
					scope:newly_created_artifact = {
						set_artifact_description = map_artifact_danger_type_snowstorms
						add_artifact_modifier = artifact_winter_movement_speed
						add_artifact_modifier = artifact_winter_advantage
					}
				}
				if = { #Heat
					limit = {
						scope:danger_type = flag:heat
					}
					scope:newly_created_artifact = {
						set_artifact_description = map_artifact_danger_type_heat
						#Multiple Travel Danger Modifiers:
						add_artifact_modifier = artifact_jungle_danger_travel_modifier
						add_artifact_modifier = artifact_desert_danger_travel_modifier
						add_artifact_modifier = artifact_drylands_danger_travel_modifier
						add_artifact_modifier = artifact_desert_mountains_danger_travel_modifier
					}
				}
				if = { #Monsoon
					limit = {
						scope:danger_type = flag:monsoon
						
					}
					scope:newly_created_artifact = {
						set_artifact_description = map_artifact_danger_type_monsoons
						#Multiple Travel Danger Modifiers:
						add_artifact_modifier = artifact_jungle_danger_travel_modifier
						add_artifact_modifier = artifact_wetlands_danger_travel_modifier
						add_artifact_modifier = artifact_desert_mountains_danger_travel_modifier
					}
				}

				#End Danger
				scope:newly_created_artifact = {
					set_artifact_description = map_artifact_danger_type_end

				}

				#Purpose related bonuses
				#These max out around what would be assigned to a masterwork artifact in artifact_creation_effects

				#Domain
				if = { #Growth
					limit = {
						scope:own_domain_bonus ?= flag:growth
					}
					scope:newly_created_artifact = {
						set_artifact_name = map_artifact_name_domain
						set_artifact_description = map_artifact_domain_purpose_growth
					}
					random_list = {
						50 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder = root
									county != root.capital_province.county
									count < 4
								}
							}
							modifier = { #Lowered by Stewardship
								stewardship > 2
								add = {
									value = stewardship
									multiply = -1
								}
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									drylands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_drylands_development_growth_1 }
									}
									desert = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_desert_development_growth_1 }
									}
									desert_mountains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_desert_mountains_development_growth_1 }
									}
									mountains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_mountains_development_growth_1 }
									}
									hills = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_hills_development_growth_1 }
									}
									plains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_plains_development_growth_1 }
									}
									forest = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_forest_development_growth_1 }
									}
									taiga = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_taiga_development_growth_1 }
									}
									oasis = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_oasis_development_growth_1 }
									}
									farmlands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_farmlands_development_growth_1 }
									}
									floodplains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_floodplains_development_growth_1 }
									}
									wetlands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_wetlands_development_growth_1 }
									}
								}
							}
						}
						35 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder = root
									county != root.capital_province.county
									count < 7
								}
							}
							modifier = { #Upped by Stewardship
								stewardship > 2
								add = {
									value = stewardship
									divide = 2
								}
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									drylands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_drylands_development_growth_2 }
									}
									desert = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_desert_development_growth_2 }
									}
									desert_mountains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_desert_mountains_development_growth_2 }
									}
									hills = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_hills_development_growth_2 }
									}
									mountains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_mountains_development_growth_2 }
									}
									plains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_plains_development_growth_2 }
									}
									forest = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_forest_development_growth_2 }
									}
									taiga = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_taiga_development_growth_2 }
									}
									oasis = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_oasis_development_growth_2 }
									}
									farmlands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_farmlands_development_growth_2 }
									}
									floodplains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_floodplains_development_growth_2 }
									}
									wetlands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_wetlands_development_growth_2 }
									}
								}
							}
						}
						15 = {
							modifier = { #Upped by Stewardship
								stewardship > 2
								add = {
									value = stewardship
								}
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = terrain
									drylands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_drylands_development_growth_3 }
									}
									desert = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_desert_development_growth_3 }
									}
									desert_mountains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_desert_mountains_development_growth_3 }
									}
									hills = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_hills_development_growth_3 }
									}
									mountains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_mountains_development_growth_3 }
									}
									plains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_plains_development_growth_3 }
									}
									forest = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_forest_development_growth_3 }
									}
									taiga = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_taiga_development_growth_3 }
									}
									oasis = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_oasis_development_growth_3 }
									}
									farmlands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_farmlands_development_growth_3 }
									}
									floodplains = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_floodplains_development_growth_3 }
									}
									wetlands = {
										scope:newly_created_artifact = { add_artifact_modifier = artifact_wetlands_development_growth_3 }
									}
								}
							}
						}
					}
				}
				if = { #Defensive
					limit = {
						scope:own_domain_bonus ?= flag:defensive
					}
					scope:newly_created_artifact = {
						set_artifact_name = map_artifact_name_domain
						set_artifact_description = map_artifact_domain_purpose_defensive
					}
					random_list = {
						50 = {
							trigger={
								any_in_list = {
									variable = mapmaking_location_list
									county.holder = root
									county != root.capital_province.county
									count < 4
								}
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value <= 100
								}
								add = -10
							}
							modifier = {
								martial > 5
								add = {
									value = martial
									multiply = -1
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_controlled_province_advantage_2_modifier
									}
									30 = {
										add_artifact_modifier = artifact_men_at_arms_maintenance_2_modifier
									}
									20 = {
										add_artifact_modifier = artifact_controlled_province_advantage_3_modifier
									}
									20 = {
										add_artifact_modifier = artifact_men_at_arms_maintenance_3_modifier
									}
								}
							}
						}
						35 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder = root
									county != root.capital_province.county
									count < 7
								}
							}
							modifier = { #Upped by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = 10
							}
							modifier = {
								martial > 1
								add = {
									value = martial
									divide = 2
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									40 = {
										add_artifact_modifier = artifact_controlled_province_advantage_4_modifier
									}
									40 = {
										add_artifact_modifier = artifact_men_at_arms_maintenance_4_modifier
									}
									10 = {
										add_artifact_modifier = artifact_controlled_province_advantage_5_modifier
									}
									10 = {
										add_artifact_modifier = artifact_men_at_arms_maintenance_5_modifier
									}
								}
							}
						}
						15 = {
							modifier = { #Upped by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 75
								}
								add = 15
							}
							modifier = {
								add = {
									value = martial
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									50 = {
										add_artifact_modifier = artifact_controlled_province_advantage_5_modifier
									}
									50 = {
										add_artifact_modifier = artifact_men_at_arms_maintenance_5_modifier
									}
								}
							}
						}
					}
				}

				#Vassals
				if = { #Dread
					limit = {
						scope:own_vassal_focus ?= flag:dread
					}
					scope:newly_created_artifact = {
						set_artifact_name = map_artifact_name_vassal_dread
						set_artifact_description = map_artifact_vassal_purpose_dread
					}

					random_list = {
						50 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder != root
									county.holder.liege = root
									this = county.holder.capital_province
									county.holder = {
										is_powerful_vassal_of = root
									}
									count < 4
								}
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value <= 100
								}
								add = -10
							}
							scope:newly_created_artifact = {
								add_artifact_modifier = artifact_dread_gain_mult_1_modifier
							}
						}
						35 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder != root
									county.holder.liege = root
									this = county.holder.capital_province
									county.holder = {
										is_powerful_vassal_of = root
									}
									count < 4
								}
							}
							modifier = { #Upped by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = 10
							}
							scope:newly_created_artifact = {
								add_artifact_modifier = artifact_dread_gain_mult_2_modifier
							}
						}
						15 = {
							modifier = { #Upped by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 75
								}
								add = 15
							}
							scope:newly_created_artifact = {
								add_artifact_modifier = artifact_dread_gain_mult_3_modifier
							}
						}
					}
				}
				if = { #Opinion
					limit = {
						scope:own_vassal_focus ?= flag:opinion
					}
					scope:newly_created_artifact = {
						set_artifact_name = map_artifact_name_vassal_opinion
						set_artifact_description =map_artifact_vassal_purpose_opinion
					}
					random_list = {
						50 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder != root
									county.holder.liege = root
									this = county.holder.capital_province
									county.holder = {
										is_powerful_vassal_of = root
									}
									count < 4
								}
							}
							modifier = { #Lowered by Diplomacy
								diplomacy > 1
								add = {
									value = diplomacy
									multiply = -1
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_happy_powerful_vassal_tax_contribution_mult_1_modifier
									}
									15 = {
										add_artifact_modifier = artifact_happy_powerful_vassal_tax_contribution_mult_2_modifier
									}
								}
							}
						}
						35 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder != root
									county.holder.liege = root
									this = county.holder.capital_province
									county.holder = {
										is_powerful_vassal_of = root
									}
									count < 4
								}
							}
							modifier = { #Upped by Diplomacy
								diplomacy > 2
								add = {
									value = diplomacy
									divide = 2
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_happy_powerful_vassal_tax_contribution_mult_3_modifier
									}
									30 = {
										add_artifact_modifier = artifact_monthly_prestige_gain_per_happy_powerful_vassal_add_1_modifier
									}
									15 = {
										add_artifact_modifier = artifact_happy_powerful_vassal_tax_contribution_mult_4_modifier
									}
									15 = {
										add_artifact_modifier = artifact_monthly_prestige_gain_per_happy_powerful_vassal_add_2_modifier
									}
								}
							}
						}
						15 = {
							modifier = { #Upped by Diplomacy
								diplomacy > 2
								add = {
									value = diplomacy
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									50 = {
										add_artifact_modifier = artifact_happy_powerful_vassal_tax_contribution_mult_4_modifier
									}
									50 = {
										add_artifact_modifier = artifact_monthly_prestige_gain_per_happy_powerful_vassal_add_2_modifier
									}
								}
							}
						}
					}
				}
				if = { #Intrigue
					limit = {
						scope:own_vassal_focus ?= flag:intrigue
					}
					scope:newly_created_artifact = {
						set_artifact_name = map_artifact_name_vassal_intrigue
						set_artifact_description =map_artifact_vassal_purpose_intrigue
					}
					random_list = {
						50 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder != root
									county.holder.liege = root
									this = county.holder.capital_province
									county.holder = {
										is_powerful_vassal_of = root
									}
									count < 4
								}
							}
							modifier = { #Lowered by Intrigue
								intrigue > 5
								add = {
									value = intrigue
									multiply = -1
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_owned_hostile_scheme_success_chance_add_2_modifier
									}
									30 = {
										add_artifact_modifier = artifact_owned_scheme_secrecy_add_2_modifier
									}
									15 = {
										add_artifact_modifier = artifact_owned_hostile_scheme_success_chance_add_3_modifier
									}
									15 = {
										add_artifact_modifier = artifact_owned_scheme_secrecy_add_3_modifier
									}
								}
							}
						}
						35 = {
							trigger = {
								any_in_list = {
									variable = mapmaking_location_list
									county.holder != root
									county.holder.liege = root
									this = county.holder.capital_province
									county.holder = {
										is_powerful_vassal_of = root
									}
									count < 4
								}
							}
							modifier = { #Upped by Intrigue
								intrigue > 2
								add = {
									value = intrigue
									divide = 2
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_owned_hostile_scheme_success_chance_add_4_modifier
									}
									30 = {
										add_artifact_modifier = artifact_owned_scheme_secrecy_add_4_modifier
									}
									15 = {
										add_artifact_modifier = artifact_owned_hostile_scheme_success_chance_add_5_modifier
									}
									15 = {
										add_artifact_modifier = artifact_owned_scheme_secrecy_add_5_modifier
									}
								}
							}
						}
						15 = {
							modifier = { #Upped by Intrigue
								intrigue > 2
								add = {
									value = intrigue
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_owned_hostile_scheme_success_chance_add_5_modifier
									}
									30 = {
										add_artifact_modifier = artifact_owned_scheme_secrecy_add_5_modifier
									}
									15 = {
										add_artifact_modifier = artifact_owned_hostile_scheme_success_chance_add_6_modifier
									}
									15 = {
										add_artifact_modifier = artifact_owned_scheme_secrecy_add_6_modifier
									}
								}
							}
						}
					}
				}

				#Point of Interest
				if = {
					limit = {
						scope:poi_focus ?= flag:safety_speed
					}
					scope:newly_created_artifact = {
						set_artifact_description = map_artifact_poi_travel
					}
					random_list = {
						50 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value <= 70
								}
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = -10
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 40
								}
								add = -5
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 30
								}
								add = -5
							}
							scope:newly_created_artifact = {
								add_artifact_modifier = character_travel_speed_1
								add_artifact_modifier = artifact_travel_safety_1
							}
						}
						35 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value <= 100
								}
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 70
								}
								add = -10
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = -5
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 40
								}
								add = -5
							}
							scope:newly_created_artifact = {
								random_list = {
									50 = {
										add_artifact_modifier = character_travel_speed_1
										add_artifact_modifier = artifact_travel_safety_2
									}
									50 = {
										add_artifact_modifier = character_travel_speed_2
										add_artifact_modifier = artifact_travel_safety_1
									}
								}
							}
						}
						15 = {
							modifier = { #Increased by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 80
								}
								add = 10
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 65
								}
								add = 5
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = 5
							}
							scope:newly_created_artifact = {
								add_artifact_modifier = character_travel_speed_2
								add_artifact_modifier = artifact_travel_safety_2
							}
						}
					}
				}
				if = { #PoI Specific Outcome
					limit = {
						scope:poi_focus ?= flag:location_based
					}
					scope:newly_created_artifact = {
						set_artifact_name = map_artifact_name_poi
						set_artifact_description =map_artifact_poi_purpose
					}
					random_list = {
						50 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value <= 70
								}
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = -10
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 40
								}
								add = -5
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 30
								}
								add = -5
							}
							#Scripted effect to choose modifier based on poi type
							scope:background_terrain_scope = {
								switch = {
									trigger = has_travel_point_of_interest 
									poi_capitals = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_diplomacy_lifestyle_xp_1_modifier
										}
									}
									poi_special_buildings_martial = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_martial_lifestyle_xp_1_modifier
										}
									}
									poi_special_buildings_learning = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_learning_lifestyle_xp_1_modifier
										}
									}
									poi_special_buildings_religious = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_piety_1_modifier
										}
									}
									poi_special_buildings_diplomatic = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_diplomacy_lifestyle_xp_1_modifier
										}
									}
									poi_grand_city = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
										}
									}
									poi_special_buildings_wonder = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
										}
									}
									poi_special_buildings_economic = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
										}
									}
									poi_mausoleum_at_halicarnassus = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
										}
									}
									poi_lighthouse_of_alexandria = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
										}
									}
									poi_natural_feature = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_hunt_lifestyle_xp_gain_mult_modifier
										}
									}
								}
							}
						}
						35 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value <= 100
								}
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 70
								}
								add = -10
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = -5
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 40
								}
								add = -5
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = has_travel_point_of_interest 
									poi_capitals = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_diplomacy_lifestyle_xp_2_modifier
										}
									}
									poi_special_buildings_martial = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_martial_lifestyle_xp_2_modifier
										}
									}
									poi_special_buildings_learning = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_learning_lifestyle_xp_2_modifier
										}
									}
									poi_special_buildings_religious = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_piety_2_modifier
										}
									}
									poi_special_buildings_diplomatic = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_diplomacy_lifestyle_xp_2_modifier
										}
									}
									poi_grand_city = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_2_modifier
										}
									}
									poi_special_buildings_wonder = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_2_modifier
										}
									}
									poi_special_buildings_economic = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_2_modifier
										}
									}
									poi_mausoleum_at_halicarnassus = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_2_modifier
										}
									}
									poi_lighthouse_of_alexandria = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_2_modifier
										}
									}
									poi_natural_feature = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_hunt_lifestyle_xp_gain_mult_modifier
										}
									}
								}
							}
						}
						15 = {
							modifier = { #Increased by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 80
								}
								add = 10
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 65
								}
								add = 5
							}
							modifier = { #Lowered by Travel Danger XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = 5
							}
							scope:background_terrain_scope = {
								switch = {
									trigger = has_travel_point_of_interest 
									poi_capitals = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_diplomacy_lifestyle_xp_3_modifier
										}
									}
									poi_special_buildings_martial = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_martial_lifestyle_xp_3_modifier
										}
									}
									poi_special_buildings_learning = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_learning_lifestyle_xp_3_modifier
										}
									}
									poi_special_buildings_religious = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_piety_3_modifier
										}
									}
									poi_special_buildings_diplomatic = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_diplomacy_lifestyle_xp_3_modifier
										}
									}
									poi_grand_city = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_3_modifier
										}
									}
									poi_special_buildings_wonder = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_3_modifier
										}
									}
									poi_special_buildings_economic = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_3_modifier
										}
									}
									poi_mausoleum_at_halicarnassus = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_3_modifier
										}
									}
									poi_lighthouse_of_alexandria = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_monthly_stewardship_lifestyle_xp_3_modifier
										}
									}
									poi_natural_feature = {
										scope:newly_created_artifact = {
											add_artifact_modifier = artifact_hunt_lifestyle_xp_gain_mult_modifier
										}
									}
								}
							}
						}
					}
				}

				#Foreign Kingdom:
				if = { #Court Life
					limit = {
						scope:kingdom_focus ?= flag:court_life
					}
					scope:newly_created_artifact = {
						#Uses fallback name
						set_artifact_description = map_artifact_foreign_purpose_court
					}
					random_list = {
						50 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value <= 70
								}
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = -10
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 40
								}
								add = -5
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 30
								}
								add = -5
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										trigger = {
											root = { has_royal_court = no }
										}
										add_artifact_modifier = artifact_monthly_prestige_1_modifier
									}
									30 = {
										trigger = {
											root = { has_royal_court = yes }
										}
										add_artifact_modifier = artifact_court_grandeur_baseline_add_1_modifier
									}
									30 = {
										add_artifact_modifier = artifact_courtly_vassal_opinion_2_modifier
									}
									15 = {
										add_artifact_modifier = artifact_courtly_tax_contribution_mult_2_modifier
									}
									15 = {
										trigger = {
											root = { has_royal_court = no }
										}
										add_artifact_modifier = artifact_monthly_prestige_2_modifier
									}
									15 = {
										trigger = {
											root = { has_royal_court = yes }
										}
										add_artifact_modifier = artifact_court_grandeur_baseline_add_2_modifier
									}
								}
							}
						}
						35 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value <= 100
								}
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 70
								}
								add = -10
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = -5
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 40
								}
								add = -5
							}
							modifier = { #Increased by knowing their language
								knows_language_of_culture = scope:background_terrain_scope.culture
								add = 5
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										trigger = {
											root = {
												has_royal_court = no
											}
										}
										add_artifact_modifier = artifact_monthly_prestige_2_modifier
									}
									30 = {
										trigger = {
											root = {
												has_royal_court = yes
											}
										}
										add_artifact_modifier = artifact_court_grandeur_baseline_add_2_modifier
									}
									30 = {
										add_artifact_modifier = artifact_courtly_vassal_opinion_3_modifier
									}
									15 = {
										add_artifact_modifier = artifact_courtly_tax_contribution_mult_3_modifier
									}
									15 = {
										trigger = {
											root = {
												has_royal_court = no
											}
										}
										add_artifact_modifier = artifact_monthly_prestige_3_modifier
									}
									15 = {
										trigger = {
											root = {
												has_royal_court = yes
											}
										}
										add_artifact_modifier = artifact_court_grandeur_baseline_add_3_modifier
									}
								}
							}
						}
						15 = {
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 80
								}
								add = 10
							}
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 65
								}
								add = 5
							}
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = 5
							}
							modifier = { #Increased by knowing their language
								knows_language_of_culture = scope:background_terrain_scope.culture
								add = 10
							}
							modifier = { #Increased by knowing their court language
								knows_court_language_of = scope:background_terrain_scope.barony.holder
								add = 5
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										trigger = {
											root = { has_royal_court = no }
										}
										add_artifact_modifier = artifact_monthly_prestige_3_modifier
									}
									30 = {
										trigger = {
											root = { has_royal_court = yes }
										}
										add_artifact_modifier = artifact_court_grandeur_baseline_add_3_modifier
									}
									30 = {
										add_artifact_modifier = artifact_courtly_vassal_opinion_4_modifier
									}
									15 = {
										add_artifact_modifier = artifact_courtly_tax_contribution_mult_3_modifier
									}
									15 = {
										trigger = {
											root = { has_royal_court = no }
										}
										add_artifact_modifier = artifact_monthly_prestige_4_modifier
									}
									15 = {
										trigger = {
											root = { has_royal_court = yes }
										}
										add_artifact_modifier = artifact_legitimacy_gain_mult_4_modifier
									}
								}
							}
						}
					}
				}
				if = { #People and Customs
					limit = {
						scope:kingdom_focus ?= flag:people_focus
					}
					scope:newly_created_artifact = {
						#Uses Fallback Name
						set_artifact_description = map_artifact_foreign_purpose_people
					}
					random_list = {
						50 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value <= 70
								}
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = -10
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 40
								}
								add = -5
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 30
								}
								add = -5
							}
							scope:newly_created_artifact = {
								random_list = {
									40 = {
										add_artifact_modifier = artifact_independent_ruler_opinion_1_modifier
									}
									40 = {
										add_artifact_modifier = artifact_learn_language_scheme_phase_duration_add_1_modifier
									}
									5 = {
										add_artifact_modifier = artifact_diplomacy_1_modifier
									}
									15 = {
										add_artifact_modifier = artifact_independent_ruler_opinion_2_modifier
									}
								}
							}
						}
						35 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value <= 100
								}
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 70
								}
								add = -10
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = -5
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 40
								}
								add = -5
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_independent_ruler_opinion_2_modifier
									}
									30 = {
										add_artifact_modifier = artifact_learn_language_scheme_phase_duration_add_2_modifier
									}
									5 = {
										add_artifact_modifier = artifact_diplomacy_2_modifier
									}
									15 = {
										add_artifact_modifier = artifact_independent_ruler_opinion_3_modifier
									}
								}
							}
						}
						15 = {
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 80
								}
								add = 10
							}
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 65
								}
								add = 5
							}
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = danger
									value >= 50
								}
								add = 5
							}
							modifier = { #Increased by knowing their language
								knows_language_of_culture = scope:background_terrain_scope.culture
								add = 10
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_independent_ruler_opinion_3_modifier
									}
									30 = {
										add_artifact_modifier = artifact_diplomacy_3_modifier
									}
									20 = {
										add_artifact_modifier = artifact_learn_language_scheme_phase_duration_add_2_modifier
									}
									20 = {
										add_artifact_modifier = artifact_independent_ruler_opinion_4_modifier
									}
								}
							}
						}
					}
				}
				if = { #Mythical Beasts
					limit = {
						scope:kingdom_focus ?= flag:mythical_creatures
					}
					scope:newly_created_artifact = {
						set_artifact_name = map_artifact_name_mythical
						set_artifact_description = map_artifact_foreign_purpose_mythical
					}
					random_list = {
						50 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value <= 70
								}
								prestige_level < high_prestige_level
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = -10
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 40
								}
								add = -5
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 30
								}
								add = -5
							}
							scope:newly_created_artifact = {
								random_list = {
									30 = {
										add_artifact_modifier = artifact_monthly_prestige_add_1_modifier
									}
									30 = {
										add_artifact_modifier = artifact_dynasty_opinion_2_modifier
									}
									15 = {
										add_artifact_modifier = artifact_monthly_prestige_add_2_modifier
									}
									15 = {
										add_artifact_modifier = artifact_monthly_prestige_gain_per_knight_add_1_modifier
									}
								}
							}
						}
						35 = {
							trigger = {
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value <= 100
								}
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 70
								}
								add = -10
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = -5
							}
							modifier = { #Lowered by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 40
								}
								add = -5
							}
							modifier = { #Increased by Fame
								prestige_level > 1
								add = {
									value = prestige_level
									multiply = 2
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									40 = {
										add_artifact_modifier = artifact_monthly_prestige_add_2_modifier
									}
									40 = {
										add_artifact_modifier = artifact_monthly_prestige_gain_per_knight_add_1_modifier
									}
									20 = {
										add_artifact_modifier = artifact_monthly_prestige_add_3_modifier
									}
								}
							}
						}
						15 = {
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 80
								}
								add = 10
							}
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 65
								}
								add = 5
							}
							modifier = { #Increased by Travel XP
								has_trait_xp = {
									trait = lifestyle_traveler
									track = travel
									value >= 50
								}
								add = 5
							}
							modifier = { #Increased by Fame
								prestige_level > 1
								add = {
									value = prestige_level
									multiply = 2
								}
							}
							scope:newly_created_artifact = {
								random_list = {
									60 = {
										add_artifact_modifier = artifact_monthly_prestige_add_3_modifier
									}
									20 = {
										add_artifact_modifier = artifact_monthly_prestige_gain_per_knight_add_2_modifier
									}
									20 = {
										add_artifact_modifier = artifact_monthly_prestige_add_4_modifier
									}
								}
							}
						}
					}

				}
			}
		}
		if = {
			limit = {
				has_any_nickname = no
			}
			random_list = {
				80 = {} #Nothing Happens
				20 = {
					give_nickname = nick_the_mapmaker
				}
			}
		}
	}

	option = { 
		name = mapmaking.1000.a
		stress_impact = {
			lifestyle_traveler = major_stress_loss #In practice this is base as you will always have this
		}
	}
}
