

defined_text = {
	name = GetAvatarTitle

	text = {
		trigger = { is_avatar_trigger = yes }
		localisation_key = String_Avatar
	}
	text = {
		trigger = { 
            is_avatar_trigger = no 
        }
		localisation_key = String_Avatars_Consort
	}
}

defined_text = {
	name = GetATLARegion
	
	use_first_valid = yes

	# Water Tribes
	text = {
		trigger = { 
			capital_holding = {
				region = world_northern_waters	
			}
			FROM = {
				location = {
					NOT = {
						region = world_northern_waters
					}
				}
			}
		}
		localisation_key = String_Region_Northern_Water_Tribe
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_southern_waters	
			}
			FROM = {
				location = {
					NOT = {
						region = world_southern_waters
					}
				}
			}
		}
		localisation_key = String_Region_Southern_Water_Tribe
	}
	# Earth Kingdom
	# Ba Sing Se
	text = {
		trigger = { 
			capital_holding = {
				region = world_ba_sing_se	
			}
			FROM = {
				location = {
					NOT = {
						region = world_ba_sing_se
					}
				}
			}
		}
		localisation_key = String_Region_Ba_Sing_Se
	}
	text = {
		trigger = { 
			capital_holding = {
				province_id = 109 # c_royal_earth_palace
			}
			FROM = {
				location = {
					region = world_ba_sing_se
					NOT = {
						province_id = 109 # c_royal_earth_palace
					}
				}
			}
		}
		localisation_key = String_Region_Earth_Royal_Palace
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_ba_sing_se_upper_ring
			}
			FROM = {
				location = {
					region = world_ba_sing_se
					NOT = {
						region = world_ba_sing_se_upper_ring	
					}
				}
			}
		}
		localisation_key = String_Region_Upper_Ring
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_ba_sing_se_middle_ring
			}
			FROM = {
				location = {
					region = world_ba_sing_se
					NOT = {
						region = world_ba_sing_se_middle_ring	
					}
				}
			}
		}
		localisation_key = String_Region_Middle_Ring
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_ba_sing_se_lower_ring
			}
			FROM = {
				location = {
					region = world_ba_sing_se
					NOT = {
						region = world_ba_sing_se_lower_ring	
					}
				}
			}
		}
		localisation_key = String_Region_Lower_Ring
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_ba_sing_se_laogai
			}
			FROM = {
				location = {
					region = world_ba_sing_se
					NOT = {
						region = world_ba_sing_se_laogai	
					}
				}
			}
		}
		localisation_key = String_Region_Lake_Laogai
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_ba_sing_se_agrarian_zone
			}
			FROM = {
				location = {
					region = world_ba_sing_se
					NOT = {
						region = world_ba_sing_se_agrarian_zone	
					}
				}
			}
		}
		localisation_key = String_Region_Agrarian_Zone
	}
	# Other Earth Kingdom regions
	text = {
		trigger = { 
			capital_holding = {
				region = world_si_wong	
			}
			FROM = {
				location = {
					NOT = {
						region = world_si_wong
					}
				}
			}
		}
		localisation_key = String_Region_Si_Wong_Desert
	}
	text = {
		trigger = {
			# loc key is Earth Kingdom only if the top liege (or suzerain) is The Earth King
			OR = {
				suzerain = {
					primary_title = {
						OR = {
							title = e_earth_kingdom #c_royal_earth_palace
							title = k_earth_kingdom #c_royal_earth_palace
						}
					}
				}
				top_liege = {
					primary_title = {
						OR = {
							title = e_earth_kingdom #c_royal_earth_palace
							title = k_earth_kingdom #c_royal_earth_palace
						}
					}
				}
			}
			capital_holding = {
				region = world_southern_earth_kingdom
			}
			FROM = {
				location = {
					region = world_greater_earth_kingdom
					NOT = {
						region = world_southern_earth_kingdom
					}
				}
			}
		}
		localisation_key = String_Region_Southern_Earth_Kingdom
	}
	# Earth Kingdom
	text = {
		trigger = {
			# loc key is Earth Kingdom only if the top liege (or suzerain) is The Earth King
			OR = {
				suzerain = {
					primary_title = {
						OR = {
							title = e_earth_kingdom #c_royal_earth_palace
							title = k_earth_kingdom #c_royal_earth_palace
						}
					}
				}
				top_liege = {
					primary_title = {
						OR = {
							title = e_earth_kingdom #c_royal_earth_palace
							title = k_earth_kingdom #c_royal_earth_palace
						}
					}
				}
			}
			capital_holding = {
				region = world_greater_earth_kingdom
			}
			FROM = {
				location = {
					NOT = {
						region = world_greater_earth_kingdom
					}
				}
			}
		}
		localisation_key = String_Region_Earth_Kingdom
	}
	# Fire Nation
	text = {
		trigger = { 
			capital_holding = {
				region = world_fire_isles	
			}
			FROM = {
				location = {
					NOT = {
						region = world_fire_isles
					}
				}
			}
		}
		localisation_key = String_Region_Fire_Nation
	}
	# Air Temples
	text = {
		trigger = { 
			capital_holding = {
				region = world_southern_air_temple	
			}
			FROM = {
				location = {
					NOT = {
						region = world_southern_air_temple
					}
				}
			}
		}
		localisation_key = String_Region_Southern_Air_Temple
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_northern_air_temple	
			}
			FROM = {
				location = {
					NOT = {
						region = world_northern_air_temple
					}
				}
			}
		}
		localisation_key = String_Region_Northern_Air_Temple
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_western_air_temple	
			}
			FROM = {
				location = {
					NOT = {
						region = world_western_air_temple
					}
				}
			}
		}
		localisation_key = String_Region_Western_Air_Temple
	}
	text = {
		trigger = { 
			capital_holding = {
				region = world_eastern_air_temple
			}
			FROM = {
				location = {
					NOT = {
						region = world_eastern_air_temple
					}
				}
			}
		}
		localisation_key = String_Region_Eastern_Air_Temple
	}
	# else use title as a name
	text = {
		trigger = {
            always = yes
        }
		localisation_key = String_Region_Default
	}
}

defined_text = {
	name = GetTravelTime

	use_first_valid = yes

	text = {
		trigger = { 
			ROOT = {
				capital_holding = {
					FROM = {
						OR = {
							AND = {
								has_flying_pet_or_artifact_trigger = yes
								location = {
									distance = {
										who = PREVPREV
										value <= 500
									}
								}
							}
							location = {
								distance = {
									who = PREVPREV
									value >= 0
								}
								distance = {
									who = PREVPREV
									value <= 150
								}
							}
						}
					}
				}
			}
		}
		localisation_key = String_journey_will_take_a_week
	}
	text = {
		trigger = { 
			ROOT = {
				capital_holding = {
					FROM = {
						OR = {
							AND = {
								has_flying_pet_or_artifact_trigger = yes
								location = {
									distance = {
										who = PREVPREV
										value >= 501
									}
									distance = {
										who = PREVPREV
										value <= 1000
									}
								}
							}
							location = {
								distance = {
									who = PREVPREV
									value >= 151
								}
								distance = {
									who = PREVPREV
									value <= 400
								}
							}
						}
					}
				}
			}
		}
		localisation_key = String_journey_will_take_1_3_weeks
	}
	text = {
		trigger = { 
			ROOT = {
				capital_holding = {
					FROM = {
						OR = {
							AND = {
								has_flying_pet_or_artifact_trigger = yes
								location = {
									distance = {
										who = PREVPREV
										value >= 1000
									}
									distance = {
										who = PREVPREV
										value <= 2000
									}
								}
							}
							location = {
								distance = {
									who = PREVPREV
									value >= 400
								}
								distance = {
									who = PREVPREV
									value <= 650
								}
							}
						}
					}
				}
			}
		}
		localisation_key = String_journey_will_take_1_3_months
	}
	text = {
		trigger = { 
			ROOT = {
				capital_holding = {
					FROM = {
						location = {
							distance = {
								who = PREVPREV
								value >= 651
							}
							distance = {
								who = PREVPREV
								value <= 1000
							}
						}
					}
				}
			}
		}
		localisation_key = String_journey_will_take_months
	}
	text = {
		trigger = { 
			ROOT = {
				capital_holding = {
					FROM = {
						location = {
							distance = {
								who = PREVPREV
								value >= 1001
							}
							distance = {
								who = PREVPREV
								value <= 1600
							}
						}
					}
				}
			}
		}
		localisation_key = String_journey_will_take_half_a_year
	}
}
