﻿# EK NOTE: removed vanilla references

# 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
		#EK DISABLED
		#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 = {
		# EK EDIT: replaced with our own
		province:2071 = { add_to_list = provinces } #White-Gold
		province:2930 = { add_to_list = provinces } #Alinor
		province:4119 = { add_to_list = provinces } #Vivec City
		province:4061 = { add_to_list = provinces } #Mournhold
		province:3539 = { add_to_list = provinces } #Senchal
	}

	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
	}
}
#EK DISABLED
#poi_mausoleum_at_halicarnassus = {
#	on_visit = {
#		send_interface_toast = {
#			title = poi_mausoleum_at_halicarnassus.visit
#			left_icon = root
#
#			add_stewardship_lifestyle_xp = travel_medium_xp
#			add_prestige = medium_prestige_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
#			}
#		}
#	}
#}
#EK DISABLED
#poi_lighthouse_of_alexandria = {
#	build_province_list = {
#		province:6053 = {
#			add_to_list = provinces
#		}
#	}
#
#	on_visit = {
#		send_interface_toast = {
#			title = poi_lighthouse_of_alexandria.visit
#			left_icon = root
#
#			add_stewardship_lifestyle_xp = travel_medium_xp
#			add_prestige = medium_prestige_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
#			}
#		}
#	}
#}

# 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 } }
							#EK ADDITION: Traits for new terrain types.
							valenwood = { battle_poi_trait_effect = { TRAIT = jungle_stalker } }
							ashlands = { battle_poi_trait_effect = { TRAIT = rough_terrain_expert } }
							tundra = { battle_poi_trait_effect = { TRAIT = open_terrain_expert } }
							black_marsh = { battle_poi_trait_effect = { TRAIT = rough_terrain_expert } }
							#EK ADDITION END
						}
						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 Moesring
			limit = { game_start_date > 139.1.1 }
			province:1675 = { add_to_list = provinces }
		}
		if = { # Battle of Glenumbra Moor
			limit = { game_start_date > 480.1.1 }
			province:55 = { add_to_list = provinces }
		}
		if = { # Battle of Mount Hattu
			limit = { game_start_date > 791.1.1 }
			province:627 = { add_to_list = provinces }
		}
		if = { # Siege of First Orsinium
			limit = { game_start_date > 980.1.1 }
			province:5500 = { add_to_list = provinces }
		}
		if = { # Battle of Bangkorai Garrison
			limit = { game_start_date > 1029.1.1 }
			province:220 = { add_to_list = provinces }
		}
		if = { # Red Eagles Last Stand
			limit = { game_start_date > 1030.1.1 }
			province:1470 = { add_to_list = provinces }
		}
		if = { # Battle of Red Mountain
			limit = { game_start_date > 1700.1.1 }
			province:4269 = { add_to_list = provinces }
		}
		if = { # Battle of Pale Pass
			limit = { game_start_date > 2703.1.1 }
			province:5486 = { add_to_list = provinces }
		}
		if = { # Xi-Tsei Massacre
			limit = { game_start_date > 2820.8.14 }
			province:4842 = { add_to_list = provinces }
		}
		if = { # Battle of Bodrum
			limit = { game_start_date > 2920.3.20 }
			province:2770 = { add_to_list = provinces }
		}
		if = { # Battle of Ald Marak
			limit = { game_start_date > 2920.6.16 }
			province:2856 = { add_to_list = provinces }
		}				
		if = { # Sack of Second Orsinium
			limit = { game_start_date > 3350.1.1 }
			province:241 = { 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
								# Moesring
								province:1675 = { battle_poi_trait_effect = { TRAIT = winter_soldier } }
								# Glenumbra Moor
								province:55 = { battle_poi_trait_effect = { TRAIT = flexible_leader  } }
								# Mount Hattu
								province:627 = { battle_poi_trait_effect = { TRAIT = unyielding_defender } }
								# First Orsinium
								province:5500 = { battle_poi_trait_effect = { TRAIT = military_engineer } }
								# Bangkorai Garrison
								province:220 = { battle_poi_trait_effect = { TRAIT = holy_warrior } }
								# Red Eagle
								province:1470 = { battle_poi_trait_effect = { TRAIT = reckless } }								
								# Red Mountain
								province:4269 = { battle_poi_trait_effect = { TRAIT = rough_terrain_expert } }
								# Pale Pass
								province:5486 = { battle_poi_trait_effect = { TRAIT = logistician } }
								# Xi-Tsei
								province:4842 = { battle_poi_trait_effect = { TRAIT = aggressive_attacker } }
								# Bodrum
								province:2770 = { battle_poi_trait_effect = { TRAIT = organizer } }
								# Ald Marak
								province:2856 = { battle_poi_trait_effect = { TRAIT = forder } }	
								# Second Orsinium
								province:241 = { battle_poi_trait_effect = { TRAIT = reaver } }
							}
						}
						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_power_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
	}
}

# EK ADDITIONS BEYOND THIS POINT
# EK ADDITION: added intrigue, dark arts & magic POI
# Intrigue Buildings
poi_special_buildings_intrigue = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_intrigue }
			}
			add_to_list = provinces
		}
	}

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

			add_intrigue_lifestyle_xp = travel_medium_xp
			traveler_danger_xp_effect = {
				MIN = 3
				MAX = 5
			}
		}
	}
}

# Magic Buildings
poi_special_buildings_magic = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_magic }
			}
			add_to_list = provinces
		}
	}

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

			add_magic_lifestyle_xp = travel_medium_xp
			traveler_danger_xp_effect = {
				MIN = 3
				MAX = 5
			}
		}
	}
}

# Dark Arts Buidlings
poi_special_buildings_dark_arts = {
	build_province_list = {
		every_special_building_province = {
			limit = {
				has_building_with_flag = { flag = travel_point_of_interest_dark_arts }
			}
			add_to_list = provinces
		}
	}

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

			add_dark_arts_lifestyle_xp = travel_medium_xp
			traveler_danger_xp_effect = {
				MIN = 3
				MAX = 5
			}
		}
	}
}
# EK ADDITION END

# Thuum Mastery points of interest
poi_thuum_mastery_points_of_interest = {
	build_province_list = {
		province:1153 = { add_to_list = provinces }
		province:1361 = { add_to_list = provinces }
		province:1094 = { add_to_list = provinces }
		province:1017 = { add_to_list = provinces }
		province:2166 = { add_to_list = provinces }
		province:2068 = { add_to_list = provinces }
		province:1863 = { add_to_list = provinces }
		province:993 = { add_to_list = provinces }
		province:1083 = { add_to_list = provinces }
		province:1150 = { add_to_list = provinces }
		province:4270 = { add_to_list = provinces }
	}

	on_visit = {
		if = {
			limit = {
				has_trait = thuum_mastery
				has_trait_xp = { trait = thuum_mastery value >= 20 }
				has_trait_xp = { trait = thuum_mastery value < 57 }
			}
			send_interface_toast = {
				title = poi_thuum_mastery_points_of_interest.visit
				left_icon = root
			}
			add_trait_xp = {
				trait = thuum_mastery
				value = 4
			}
		}
	}
}