HiddenCityLayout

From Kolmafia
Revision as of 04:55, 9 September 2011 by imported>Bale
Jump to navigation Jump to search


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


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();
   }
}