HiddenCityLayout

From Kolmafia
Jump to navigation Jump to search


This property stores the results of your most recent exploration of the hidden city. It consists of 25 characters each of which represents one of the city squares in order from 1 to 25. The meaning of each character is as follows.

 N - nature        0 - unexplored         T - temple
 L - lightning     E - explored           A - archaeologist
 F - fire          P - protector spirit
 W - water         D - defeated spirit

This information is useful for scripting hidden city exploration in combination with the hiddencity CLI command.


Assuming that you have sufficiently explored the Hidden City and identified the spheres, the following code will use the hiddenCityLayout property to place all spheres on their altars and fight the Protector Spectre.

string hiddenCityLayout = get_property("hiddenCityLayout");

int retrieve_square(string hunt) {
   for i from 1 to length(hiddenCityLayout)
      if(substring(hiddenCityLayout,i-1,i) == hunt) return i;
   return 0;
}

item this_stone(string desc) {
   for i from 2174 to 2177
      if(get_property("lastStoneSphere"+i) == desc) return to_item(i);
   return $item[none];
}

boolean do_altar(string god) {
   print("Finding the altar of "+god+"...");
   int loc = retrieve_square(substring(god,0,1));
   if(loc == 0) {
      print("Unable to reveal the "+god+" altar.");
      return false;
   }
   item stone = this_stone(god);
   if(stone == $item[none] || item_amount(stone) < 1) {
      print("Unable to discern the '"+stone+"' stone.  You may have to identify the stones yourself.", "red");
      return false;
   }
   cli_execute("hiddencity "+loc+" altar "+stone);
   return item_amount(stone) == 0;
}

if(do_altar("nature") && do_altar("lightning") && do_altar("fire") && do_altar("water")) {
   int temple = retrieve_square("t");
   if(temple == 0)
      print("The temple has not been found!", "red");
   else {
      cli_execute("hiddencity "+temple+" temple");
      run_combat();
   }
}