Advertisement
Guest User

LKFarm

a guest
Dec 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. *   @filename   LKFarm.js
  3. *   @author     karyoplasma
  4. *   @desc       Open superchests in LK.
  5. */
  6.  
  7. //usually, key buying is controlled by Config.OpenChests, but that also changes the Pather to open chests on your way and waste time, so I modified the function. Pretty much all code here is from Town.js, I just removed various checks.
  8.  
  9. function getKeyCount(){
  10.     var i, count = 0, key = me.findItems(543, 0, 3);
  11.  
  12.         if (key) {
  13.             for (i = 0; i < key.length; i += 1) {
  14.                 count += key[i].getStat(70);
  15.             }
  16.         }
  17.  
  18.         return count;
  19. }
  20.  
  21. function restockKeys(){
  22.     var npc, key;
  23.     if (this.getKeyCount() < 6){
  24.         npc = Town.initNPC("Key", "buyKeys");
  25.         key = npc.getItem("key");
  26.         try {
  27.             key.buy(true);
  28.         } catch (e) {
  29.             print(e.message);
  30.  
  31.             return false;
  32.         }
  33.     }
  34.     return true
  35. }
  36.  
  37. function LKFarm() {
  38.    
  39.     Town.buyPotions();
  40.     this.restockKeys(); //In contrast to Town.buyKeys(), my version simply ignores your setting in the config file and makes the bot buy them when needed
  41.     Town.repair();
  42.     Town.cainID();
  43.     Town.clearInventory();
  44.     Pather.useWaypoint(79); // Use the nearest waypoint to area id 79 which is LK
  45.    
  46.     var presetUnits = getPresetUnits(79, 2); //get an array of objects that exist in LK
  47.    
  48.     for (var i = 0; i < presetUnits.length; i++){ //iterate through the array
  49.         if (presetUnits[i].id == 160) { //id 160 is the campfire next to the superchest locations
  50.         // so if the unit we are looking at is a campfire, we just need to adjust the coordinates a bit to get to the superchests since they spawn in fixed locations
  51.             Pather.moveTo(presetUnits[i].roomx * 5 + presetUnits[i].x - 35, presetUnits[i].roomy * 5 + presetUnits[i].y + 5); //move to the long vertical house
  52.             Misc.openChests(10); //open all chests in a range of 10 (very often only the 2 superchests, sometimes another chest spawns outside, you can try to adjust the range, but 10 is good imo
  53.             Pather.moveTo(presetUnits[i].roomx * 5 + presetUnits[i].x, presetUnits[i].roomy * 5 + presetUnits[i].y - 35); //move inside the house with the superchest and the weapon rack
  54.             Misc.openChests(10); //same deal as above (opens the weapon rack as well which I think is fair)
  55.         }
  56.     }
  57.     Town.goToTown(); //take TP
  58.     Pather.useWaypoint(103); //take WP to Act4 town for faster WP access
  59.     return true;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement