﻿
# Update points_of_interest_tracker_effect when you change this!

# Capitals
poi_capitals = {
	build_province_list = {
		every_kingdom = {
			limit = {
				this = this.holder.primary_title
			}
			holder.capital_province ?= {
				add_to_list = provinces
			}
		}
		every_empire = {
			limit = {
				this = this.holder.primary_title
			}
			holder.capital_province ?= {
				add_to_list = provinces
			}
		}
		every_hegemony = {
			limit = {
				this = this.holder.primary_title
			}
			holder.capital_province ?= {
				add_to_list = provinces
			}
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_capitals.visit
			left_icon = root

			scope:province.barony.holder = {
				if = {
					limit = {
						primary_title = {
							tier >= tier_empire
						}
					}
					save_temporary_scope_value_as = {
						name = xp_gain_amount
						value = root.travel_major_xp
					}
				}
				else = {
					save_temporary_scope_value_as = {
						name = xp_gain_amount
						value = root.travel_medium_xp
					}
				}


				if = { # Merit-government Capitals that have royal courts give merit and the regular reward
					limit = {
						has_royal_court = yes
						government_allows = merit
						root = {
							government_allows = merit
						}
					}
					root = {
						change_merit = medium_merit_gain
					}
				}

				if = { # Merit-government Capitals without royal courts give just merit (no diplo)
					limit = {
						has_royal_court = no
						government_allows = merit
						root = {
							government_allows = merit
						}
					}
					root = {
						change_merit = medium_merit_gain
					}
				}
				else_if = {
					limit = {
						OR = {
							has_royal_court = no
							has_court_type = court_diplomatic
						}
					}
					root = {
						poi_lifestyle_experience_effect = {
							LIFESTYLE = diplomacy
							VALUE = scope:xp_gain_amount
						}
					}
				}
				else_if = {
					limit = {
						OR = {
							has_court_type = court_warlike
							has_court_type = court_tribal
							has_court_type = court_nomadic
						}
					}
					root = {
						poi_lifestyle_experience_effect = {
							LIFESTYLE = martial
							VALUE = scope:xp_gain_amount
						}
					}
				}
				else_if = {
					limit = {
						has_court_type = court_administrative
					}
					root = {
						poi_lifestyle_experience_effect = {
							LIFESTYLE = stewardship
							VALUE = scope:xp_gain_amount
						}
					}
				}
				else_if = {
					limit = {
						has_court_type = court_intrigue
					}
					root = {
						poi_lifestyle_experience_effect = {
							LIFESTYLE = intrigue
							VALUE = scope:xp_gain_amount
						}
					}
				}
				else_if = {
					limit = {
						has_court_type = court_scholarly
					}
					root = {
						poi_lifestyle_experience_effect = {
							LIFESTYLE = learning
							VALUE = scope:xp_gain_amount
						}
					}
				}
				else = {
					root = {
						poi_lifestyle_experience_effect = {
							LIFESTYLE = diplomacy
							VALUE = scope:xp_gain_amount
						}
					}
				}
				# Prestige for Wanderers
				wanderer_lifestyle_destination_effect = yes
			}

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = centralization_perk
				}
				custom_tooltip = {
					text = adventurers_centralization_perk.effect
				}
				every_courtier = {
					hidden_effect = {
						scope:province.barony.holder = {
							if = {
								limit = {
									has_royal_court = yes
									has_court_type = court_diplomatic
								}
								prev = {
									add_diplomacy_skill = 1
									force_character_skill_recalculation = yes
								}
							}
							else_if = {
								limit = {
									has_royal_court = yes
									has_court_type = court_warlike
								}
								prev = {
									add_martial_skill = 1
									force_character_skill_recalculation = yes
								}
							}
							else_if = {
								limit = {
									has_royal_court = yes
									has_court_type = court_administrative
								}
								prev = {
									add_stewardship_skill = 1
									force_character_skill_recalculation = yes
								}
							}
							else_if = {
								limit = {
									has_royal_court = yes
									has_court_type = court_intrigue
								}
								prev = {
									add_intrigue_skill = 1
									force_character_skill_recalculation = yes
								}
							}
							else_if = {
								limit = {
									has_royal_court = yes
									has_court_type = court_scholarly
								}
								prev = {
									add_learning_skill = 1
									force_character_skill_recalculation = yes
								}
							}
							else_if = {
								limit = {
									has_royal_court = yes
									OR = {
										has_court_type = court_tribal
										has_court_type = court_nomadic
									}
								}
								prev = {
									add_prowess_skill = 1
									force_character_skill_recalculation = yes
								}
							}
							else = {
								prev = {
									random_list = {
										1 = {
											add_prowess_skill = 1
										}
										1 = {
											add_learning_skill = 1
										}
										1 = {
											add_intrigue_skill = 1
										}
										1 = {
											add_stewardship_skill = 1
										}
										1 = {
											add_martial_skill = 1
										}
										1 = {
											add_diplomacy_skill = 1
										}
									}
									force_character_skill_recalculation = yes
								}
							}
						}
					}
				}
			}
		}

		visiting_poi_effect = yes
	}
}

# Walls and Forts
poi_special_buildings_martial = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				OR = {
					has_building_with_flag = { flag = travel_point_of_interest_martial }
					has_building_with_flag = { flag = travel_point_of_interest_martial_minor }
				}
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root
			if = {
				# Walls and Forts
				limit = {
					scope:province = {
						has_building_with_flag = { flag = travel_point_of_interest_martial }
					}
				}
				add_poi_martial_experience_effect = yes
				traveler_danger_xp_effect = {
					MIN = 3
					MAX = 5
				}
			}
			else_if = {
				# Minor POI (mostly for multi-province defenses like Hadrian's wall)
				limit = {
					scope:province = {
						has_building_with_flag = { flag = travel_point_of_interest_martial_minor }
					}
				}
				poi_lifestyle_experience_effect = {
					LIFESTYLE = martial
					VALUE = travel_miniscule_lifestyle_xp
				}
				traveler_travel_xp_effect = {
					MIN = 1
					MAX = 1
				}
			}
			else = {
				# Rest / Fallback
				add_poi_learning_experience_effect = yes
				traveler_travel_xp_effect = {
					MIN = 3
					MAX = 5
				}
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
			
			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes
		}
		
		#For Cilician Gates and other EP3 monuments
		trigger_event = {
			on_action = on_visited_ep3_monument
		}

		visiting_poi_effect = yes
	}
}

# Universities & places of general learning
poi_special_buildings_learning = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_learning }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root

			if = {
				limit = {
					 has_lifestyle = diplomacy_lifestyle
				}
				add_poi_diplomacy_experience_effect = yes
			}
			else_if = {
				limit = {
					has_lifestyle = martial_lifestyle
				}
				add_poi_martial_experience_effect = yes
			}
			else_if = {
				limit = {
					has_lifestyle = stewardship_lifestyle
				}
				add_poi_stewardship_experience_effect = yes
			}
			else_if = {
				limit = {
					has_lifestyle = intrigue_lifestyle
				}
				add_poi_intrigue_experience_effect = yes
			}
			else = {
				add_poi_learning_experience_effect = yes
			}
			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}

		visiting_poi_effect = yes
	}
}

# Religious sites
poi_special_buildings_religious = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_religious }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root

			add_poi_learning_experience_effect = yes
			if = {
				limit = {
					scope:province.barony ?= {
						is_holy_site_of = root.faith
					}
				}
				add_piety = point_of_interest_piety_value
			}
			
			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes

			if = {
				limit = {
					has_trait = lifestyle_mystic
				}
				add_trait_xp = {
					trait = lifestyle_mystic
					value = lifestyle_mystic_xp_gain_minor_value
				}
			}

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
			if = {
				limit = {
					has_perk = church_and_state_perk
					has_government = landless_adventurer_government
				}
				add_piety = major_piety_gain
			}
		}

		visiting_poi_effect = yes
	}
}

# Palaces & Political places
poi_special_buildings_diplomatic = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_diplomatic }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root

			add_poi_diplomacy_experience_effect = yes

			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}

		visiting_poi_effect = yes
	}
}

# Grand Cities
poi_grand_city = {
	build_province_list = {
		province:4828 = { add_to_list = provinces } #Baghdad
		province:2575 = { add_to_list = provinces } #Rome
		province:496 = { add_to_list = provinces } #Constantinople
	}

	on_visit = {
		trigger_event = {
			on_action = on_visited_grand_city
		}
		if = {
			limit = {
				scope:province.county.holder != root #If I own it then it does not make sense to visit it.
			}
			custom_tooltip = poi_grand_city_visit_event_tt
		}
		if = {
			limit = {
				NOT = {
					has_trait = lifestyle_traveler
				}
			}
			add_trait = lifestyle_traveler
			traveler_travel_xp_effect = {
				MIN = 1
				MAX = 3
			}
			if = {
				limit = {
					is_landless_adventurer = yes
					has_perk = organized_muster_rolls_perk
				}
				send_interface_toast = {
					title = poi_grand_city.visit
					left_icon = root
					
					add_gold = minor_gold_laamps_value
				}
			}
		}
		else = {
			send_interface_toast = {
				title = poi_grand_city.visit
				left_icon = root

				traveler_travel_xp_effect = {
					MIN = 3
					MAX = 5
				}
				if = {
					limit = {
						has_government = landless_adventurer_government
						has_perk = organized_muster_rolls_perk
					}
					add_gold = minor_gold_laamps_value
				}
			}
		}
		# Prestige for Wanderers
		wanderer_lifestyle_destination_effect = yes

		visiting_poi_effect = yes
	}
}

# Ancient / New wonders
poi_special_buildings_wonder = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_wonder }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root

			add_poi_stewardship_experience_effect = yes
			point_of_interest_prestige_effect = yes

			if = {
				limit = {
					has_trait = lifestyle_mystic
				}
				add_trait_xp = {
					trait = lifestyle_mystic
					value = lifestyle_mystic_xp_gain_minor_value
				}
			}

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}

		visiting_poi_effect = yes
	}
}

# Economic Buildings (mines, ports)
poi_special_buildings_economic = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_economic }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root

			add_poi_stewardship_experience_effect = yes

			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes

			traveler_danger_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}

		visiting_poi_effect = yes
	}
}

poi_mausoleum_at_halicarnassus = {
	on_visit = {
		send_interface_toast = {
			title = poi_mausoleum_at_halicarnassus.visit
			left_icon = root

			add_poi_stewardship_experience_effect = yes
			point_of_interest_prestige_effect = yes

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}

		visiting_poi_effect = yes
	}
}

poi_lighthouse_of_alexandria = {
	on_visit = {
		send_interface_toast = {
			title = poi_lighthouse_of_alexandria.visit
			left_icon = root

			add_poi_stewardship_experience_effect = yes
			point_of_interest_prestige_effect = yes

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}

		visiting_poi_effect = yes
	}
}

# Natural features, e.g. Mount X, Lake X
poi_natural_feature = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_natural_feature }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_natural_feature.visit
			left_icon = root
			add_poi_wanderer_experience_effect = yes
			stress_impact = { base = minor_stress_impact_loss }

			if = {
				limit = {
					NOT = {
						has_trait = lifestyle_traveler
					}
				}
				send_interface_toast = {
					title = poi_natural_feature.visit
					left_icon = root
					add_trait = lifestyle_traveler
					traveler_travel_xp_effect = {
						MIN = 1
						MAX = 3
					}
					if = {
						limit = {
							has_government = landless_adventurer_government
							has_perk = organized_muster_rolls_perk
						}
						add_gold = minor_gold_laamps_value
					}
				}
			}
			else = {
				send_interface_toast = {
					title = poi_natural_feature.visit
					left_icon = root
					traveler_travel_xp_effect = {
						MIN = 3
						MAX = 5
					}
					if = {
						limit = {
							has_government = landless_adventurer_government
							has_perk = organized_muster_rolls_perk
						}
						add_gold = minor_gold_laamps_value
					}
				}
			}

			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes
		}

		visiting_poi_effect = yes
	}
}

# Legend stuff
poi_legend_capitals = {
	build_province_list = {
		every_legend = {
			limit = {
				OR = {
					legend_quality = illustrious
					legend_quality = mythical
				}
			}
			legend_owner.capital_province ?= {
				add_to_list = provinces
			}
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_legend_capitals.visit
			left_icon = root

			add_poi_diplomacy_experience_effect = yes
			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}
		visiting_poi_effect = yes
	}
}

poi_battles = {
	build_province_list = {
		every_in_global_list = {
			variable = battle_poi_list
			limit = {
				has_variable = battle_poi_winner
				has_variable = battle_poi_loser
				has_variable = battle_poi_date_day
				has_variable = battle_poi_date_month
				has_variable = battle_poi_date_year
				NOT = { has_travel_point_of_interest = poi_battles_historical }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_battles.visit
			left_icon = root

			if = {
				limit = {
					OR = {
						has_variable = battle_poi_trait_gained
						number_of_commander_traits > 1
					}
				}
				add_poi_martial_experience_effect = yes
			}
			else = {
				poi_lifestyle_experience_effect = {
					LIFESTYLE = martial
					VALUE = travel_minor_lifestyle_xp
				}
			}
			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes
		}

		if = {
			limit = {
				NOR = {
					has_variable = battle_poi_trait_gained
					number_of_commander_traits > 1
				}
			}
			scope:province = {
				random_list = {
					80 = {
						root = { add_poi_martial_experience_effect = yes }
					}
					20 = {
						switch = {
							trigger = terrain
							forest = { battle_poi_trait_effect = { TRAIT = forest_fighter } }
							taiga = { battle_poi_trait_effect = { TRAIT = forest_fighter } }
							farmlands = { battle_poi_trait_effect = { TRAIT = open_terrain_expert } }
							plains = { battle_poi_trait_effect = { TRAIT = open_terrain_expert } }
							steppe = { battle_poi_trait_effect = { TRAIT = open_terrain_expert } }
							hills = { battle_poi_trait_effect = { TRAIT = rough_terrain_expert } }
							mountains = { battle_poi_trait_effect = { TRAIT = rough_terrain_expert } }
							wetlands = { battle_poi_trait_effect = { TRAIT = rough_terrain_expert } }
							drylands = { battle_poi_trait_effect = { TRAIT = desert_warrior } }
							desert = { battle_poi_trait_effect = { TRAIT = desert_warrior } }
							desert_mountains = { battle_poi_trait_effect = { TRAIT = desert_warrior } }
							oasis = { battle_poi_trait_effect = { TRAIT = desert_warrior } }
							jungle = { battle_poi_trait_effect = { TRAIT = jungle_stalker } }
							floodplains = { battle_poi_trait_effect = { TRAIT = flexible_leader } }
						}
						root = {
							set_variable = battle_poi_trait_gained
						}
					}
				}
			}
		}

		traveler_danger_xp_effect = {
			MIN = 1
			MAX = 3
		}

		visiting_poi_effect = yes
	}
}

poi_battles_historical = {
	build_province_list = {
		# Note, please try to keep these in chronological order
		if = { # Battle of Yarmuk
			limit = { game_start_date > 636.8.20 }
			province:5954 = { add_to_list = provinces }
		}
		if = { # Battle of Aror
			limit = { game_start_date > 711.1.1 }
			province:1175 = { add_to_list = provinces }
		}
		if = { # Battle of Tours
			limit = { game_start_date > 732.10.10 }
			province:2253 = { add_to_list = provinces }
		}
		if = { # Battle of Talas
			limit = { game_start_date > 751.1.1 }
			province:7132 = { add_to_list = provinces }
		}
		if = { # Battle of Lechfeld
			limit = { game_start_date > 955.8.10 }
			province:2778 = { add_to_list = provinces }
		}
		if = { # Battle of Svolder
			limit = { game_start_date > 999.9.9 }
			province:2811 = { add_to_list = provinces }
		}
		if = { # Battle of Dandanaqan
			limit = { game_start_date > 1040.5.23 }
			province:4008 = { add_to_list = provinces }
		}
		if = { # Battle of Civitate
			limit = { game_start_date > 1053.6.18 }
			province:2605 = { add_to_list = provinces }
		}
		if = { # The Battle of Stamford Bridge
			limit = { game_start_date > 1066.9.25 }
			province:1595 = { add_to_list = provinces }
		}
		if = { # The Battle of Hastings
			limit = { game_start_date > 1066.10.14 }
			province:1509 = { add_to_list = provinces }
		}
		if = { # The Battle of Manzikert
			limit = { game_start_date > 1071.8.26 }
			province:701 = { add_to_list = provinces }
		}

		#Japan
		if = { #Battle of Subushi
			limit = { game_start_date > 789.5.28 }
			province:10698 = { add_to_list = provinces }
		}
		#Korea
		if = { #Battle of Baekgang
			limit = { game_start_date > 663.10.5 }
			province:9953 = { add_to_list = provinces }
		}
		#Sumatra
		if = { #Battle of Palembang
			limit = { game_start_date > 1025.3.1 }
			province:11296 = { add_to_list = provinces }
		}
		#Khmer
		if = { #Battle of Angkor
			limit = { game_start_date > 1177.1.5 }
			province:10816 = { add_to_list = provinces }
		}
		#Vietnam
		if = { #Siege of Songping
			limit = { game_start_date > 863.3.1 }
			province:10861 = { add_to_list = provinces }
		}
		#China
		if = { #Battle of Muye
			limit = { game_start_date > 1.1.1 } #1046 BCE
			province:10355 = { add_to_list = provinces }
		}
		if = { #Battle of Red Cliffs
			limit = { game_start_date > 208.11.26 }
			province:8978 = { add_to_list = provinces }
		}
		if = { #Battle of Guandu
			limit = { game_start_date > 200.9.30 }
			province:9820 = { add_to_list = provinces }
		}
		if = { #Battle of Yiling
			limit = { game_start_date > 221.8.2 }
			province:10020 = { add_to_list = provinces }
		}
		if = { #Battle of Fei River
			limit = { game_start_date > 383.11.30 }
			province:10249 = { add_to_list = provinces }
		}
		if = { #Battle of Canhe Slope
			limit = { game_start_date > 395.12.8 }
			province:11715 = { add_to_list = provinces }
		}
		if = { #Battle of Xiangji Temple
			limit = { game_start_date > 757.11.13 }
			province:10430 = { add_to_list = provinces }
		}
		if = { #Battle of Gaoliang River
			limit = { game_start_date > 979.1.3 }
			province:9702 = { add_to_list = provinces }
		}
	}

	on_visit = {
		send_interface_toast = {
			title = travel_point_historical_name_visit_message
			left_icon = root

			if = {
				limit = {
					OR = {
						has_variable = battle_poi_trait_gained
						number_of_commander_traits > 1
					}
				}
				add_poi_martial_experience_effect = yes
			}
			else = {
				poi_lifestyle_experience_effect = {
					LIFESTYLE = martial
					VALUE = travel_minor_lifestyle_xp
				}
			}

			if = {
				limit = {
					NOR = {
						has_variable = battle_poi_trait_gained
						number_of_commander_traits > 1
					}
				}
				random_list = {
					80 = {
						add_poi_martial_experience_effect = yes
					}
					20 = {
						scope:province = {
							switch = {
								trigger = this
								# Tours
								province:2256 = { battle_poi_trait_effect = { TRAIT = unyielding_defender } }
								# Lechfeld
								province:2778 = { battle_poi_trait_effect = { TRAIT = open_terrain_expert } }
								# Hastings
								province:1509 = { battle_poi_trait_effect = { TRAIT = aggressive_attacker } }
								# Stamford Bridge
								province:1588 = { battle_poi_trait_effect = { TRAIT = organizer } }
								# Manzikert
								province:701 = { battle_poi_trait_effect = { TRAIT = flexible_leader } }
								# Yarmuk
								province:5954 = { battle_poi_trait_effect = { TRAIT = reckless } }
								# Dandanaqan
								province:4008 = { battle_poi_trait_effect = { TRAIT = desert_warrior } }
								# Battle of Aror
								province:1175 = { battle_poi_trait_effect = { TRAIT = flexible_leader } }
								# Battle of Svolder
								province:2811 = { battle_poi_trait_effect = { TRAIT = holy_warrior } }
								# Battle of Civitate
								province:2605 = { battle_poi_trait_effect = { TRAIT = open_terrain_expert } }
								# Battle of Talas
								province:7132 = { battle_poi_trait_effect = { TRAIT = desert_warrior } }
								#Battle of Sufuku
								province:10698 = { battle_poi_trait_effect = { TRAIT = rough_terrain_expert } }
								#Battle of Baekgang
								province:9953 = { battle_poi_trait_effect = { TRAIT = unyielding_defender } }
								#Battle of Palembang
								province:11296 = { battle_poi_trait_effect = { TRAIT = flexible_leader } }
								#Battle of Angkor
								province:10816 = { battle_poi_trait_effect = { TRAIT = reaver } }
								#Battle of Songping
								province:10861 = { battle_poi_trait_effect = { TRAIT = reaver } }
								#Battle of Muye
								province:10355 = { battle_poi_trait_effect = { TRAIT = aggressive_attacker }	}
								#Battle of Guandu
								province:9820 = { battle_poi_trait_effect = { TRAIT = flexible_leader } }
								#Battle of Red Cliffs
								province:8978 = { battle_poi_trait_effect = { TRAIT = forder } }
								#Battle of Yiling
								province:10020 = { battle_poi_trait_effect = { TRAIT = reckless } }
								#Battle of Fei River
								province:10249 = { battle_poi_trait_effect = { TRAIT = unyielding_defender } }
								#Battle of Canhe Slope
								province:11715 = { battle_poi_trait_effect = { TRAIT = organizer } }
								#Battle of Xiangji Temple
								province:10430 = { battle_poi_trait_effect = { TRAIT = unyielding_defender } }
								#Battle of Gaoliang River
								province:9702 = { battle_poi_trait_effect = { TRAIT = logistician } }
							}
						}
						set_variable = battle_poi_trait_gained
					}
				}
			}

			traveler_danger_xp_effect = {
				MIN = 1
				MAX = 3
			}

			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes
		}

		visiting_poi_effect = yes
	}
}

# Stress relief
poi_special_buildings_stress_relief = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_stress_relief }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root

			# Stress loss
			stress_impact = {
				base = -10
				lazy = -5
				content = -5
				eccentric = 5
			}
			
			# If you have the Reveler trait, gain some XP
			if = {
				limit = { has_trait = lifestyle_reveler }
				add_trait_xp = {
					trait = lifestyle_reveler
					value = 5
				}
			}
			
			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes

			# Travel trait XP
			traveler_travel_xp_effect = {
				MIN = 2
				MAX = 4
			}
		}
	}
}

poi_silk_road_node = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = silk_road_node }
			}
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_special_buildings.visit
			left_icon = root

			add_poi_stewardship_experience_effect = yes

			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes

			traveler_danger_xp_effect = {
				MIN = 3
				MAX = 5
			}
			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}
		}

		visiting_poi_effect = yes
	}
}

# Religious sites
poi_mandala_capital = {
	build_province_list = {
		every_in_global_list = {
			variable = mandala_poi_list
			limit = { has_building_with_flag = { flag = mandala_capital_building } }
			add_to_list = provinces
		}
	}

	on_visit = {
		send_interface_toast = {
			title = poi_gp_buildings.visit
			left_icon = root

			add_learning_lifestyle_xp = minor_lifestyle_experience

			#Visiting Mandala Capital
			scope:province = {
				if = {
					limit = {  #Visiting Mandala Overlord
						root = {
							OR = {
								is_tributary = yes
								is_independent_ruler = no
							}
						}
						root.overlord ?= { government_has_flag = government_is_mandala }
						this = root.overlord.capital_province
						has_ruined_great_building = no
					}
					save_temporary_scope_value_as = {
						name = piety_gain_amount
						value = {
							value = {
								if = {
									limit = {
										root = { government_has_flag = government_is_mandala }
									}
									value = medium_piety_value
								}
								else = {
									value = minor_piety_value
								}
							}
							multiply = {
								switch = {
									trigger = has_building 
									mandala_capital_01 = { value = 1 }
									mandala_capital_02 = { value = 2 }
									mandala_capital_03 = { value = 3 }
									mandala_capital_04 = { value = 4 }
									mandala_capital_05 = { value = 5 }
								}
							}
						}
					}
				}
				else_if = { #Visiting Mandala Capital - Unaffiliated
					limit = {
						this.county.holder.capital_province = this
						NOT = { root = this.county.holder }
						has_ruined_great_building = no
						root = { #Only Tribals, Mandalas, or those of the same religion care
							OR = {
								government_has_flag = government_is_mandala
								government_has_flag = government_is_tribal
								faith.religion = prev.county.holder.faith.religion
							}
						}
					}
					save_temporary_scope_value_as = {
						name = piety_gain_amount
						value = {
							value = {
								if = {
									limit = {
										root = { government_has_flag = government_is_mandala }
									}
									value = minor_piety_value
								}
								else = {
									value = miniscule_piety_value
								}
							}
							multiply = {
								switch = {
									trigger = has_building 
									mandala_capital_01 = { value = 1 }
									mandala_capital_02 = { value = 2 }
									mandala_capital_03 = { value = 3 }
									mandala_capital_04 = { value = 4 }
									mandala_capital_05 = { value = 5 }
								}
							}
						}
					}
				}
				else_if = { #Visiting Mandala Capital - Ruined
					limit = {
						NOT = { root = this.county.holder }
						has_ruined_great_building = yes
						root = { #Only Tribals, Mandalas, or those of the same religion care
							OR = {
								government_has_flag = government_is_mandala
								government_has_flag = government_is_tribal
								faith.religion = prev.county.holder.faith.religion
							}
						}
					}
					save_temporary_scope_value_as = {
						name = piety_gain_amount
						value = miniscule_piety_value
					}
				}
				#Otherwise we do not care at all

				#Now you get your piety:
				if = {
					limit = { exists = scope:piety_gain_amount }
					root = { add_piety = scope:piety_gain_amount }
				}
			}
			
			# Prestige for Wanderers
			wanderer_lifestyle_destination_effect = yes

			if = { #Small XP Boost based on Mandala holders aspect
				limit = {
					government_has_flag = government_is_mandala
					scope:province.county.holder.capital_province = scope:province
					scope:province.county.holder = { has_mandala_aspect_trigger = yes }
				}
				scope:province.county.holder.house ?= {
					switch = {
						trigger = has_house_aspiration_parameter
						aspect_of_creation = {
							root = {
								poi_lifestyle_experience_effect = {
									LIFESTYLE = stewardship
									VALUE = minor_lifestyle_xp
								}
							}
						}
						aspect_of_serenity = {
							root = {
								poi_lifestyle_experience_effect = {
									LIFESTYLE = diplomacy
									VALUE = minor_lifestyle_xp
								}
							}
						}
						aspect_of_destruction = {
							root = {
								poi_lifestyle_experience_effect = {
									LIFESTYLE = martial
									VALUE = minor_lifestyle_xp
								}
							}
						}
						aspect_of_trickery = {
							root = {
								poi_lifestyle_experience_effect = {
									LIFESTYLE = intrigue
									VALUE = minor_lifestyle_xp
								}
							}
						}
					}
				}
			}

			if = {
				limit = {
					has_trait = lifestyle_mystic
				}
				add_trait_xp = {
					trait = lifestyle_mystic
					value = lifestyle_mystic_xp_gain_minor_value
				}
			}

			#Dynasty Legacy - Legitimacy Bonus for Visiting Wanua or Mandala
			if = {
				limit = {
					dynasty ?= {
						has_dynasty_perk = tgp_sea_legacy_1
					}
				}
				add_legitimacy_effect = { LEGITIMACY = minor_legitimacy_gain }
			}

			traveler_travel_xp_effect = {
				MIN = 3
				MAX = 5
			}

			if = {
				limit = {
					has_government = landless_adventurer_government
					has_perk = organized_muster_rolls_perk
				}
				add_gold = see_how_its_done_gold_reward_value
			}

		}

		visiting_poi_effect = yes
	}
}
