Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @filename LKFarm.js
- * @author karyoplasma
- * @desc Open superchests in LK.
- */
- //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.
- function getKeyCount(){
- var i, count = 0, key = me.findItems(543, 0, 3);
- if (key) {
- for (i = 0; i < key.length; i += 1) {
- count += key[i].getStat(70);
- }
- }
- return count;
- }
- function restockKeys(){
- var npc, key;
- if (this.getKeyCount() < 6){
- npc = Town.initNPC("Key", "buyKeys");
- key = npc.getItem("key");
- try {
- key.buy(true);
- } catch (e) {
- print(e.message);
- return false;
- }
- }
- return true
- }
- function LKFarm() {
- Town.buyPotions();
- 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
- Town.repair();
- Town.cainID();
- Town.clearInventory();
- Pather.useWaypoint(79); // Use the nearest waypoint to area id 79 which is LK
- var presetUnits = getPresetUnits(79, 2); //get an array of objects that exist in LK
- for (var i = 0; i < presetUnits.length; i++){ //iterate through the array
- if (presetUnits[i].id == 160) { //id 160 is the campfire next to the superchest locations
- // 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
- Pather.moveTo(presetUnits[i].roomx * 5 + presetUnits[i].x - 35, presetUnits[i].roomy * 5 + presetUnits[i].y + 5); //move to the long vertical house
- 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
- 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
- Misc.openChests(10); //same deal as above (opens the weapon rack as well which I think is fair)
- }
- }
- Town.goToTown(); //take TP
- Pather.useWaypoint(103); //take WP to Act4 town for faster WP access
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement