Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#! name = forager
- //#! uniq = forager_by_quinsta
- //#! tooltip = start foraging
- include("jBotAPI");
- var inventory = checkInventory();
- function getNearestFirTree() {
- var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir"]);
- var min_len = 100500; var obj = null;
- for (var i = 0; i < trees.length; i++) {
- if (trees[i].position().dist(jMyCoords()) < min_len) {
- obj = trees[i];
- min_len = trees[i].position().dist(jMyCoords());
- }
- }
- return obj;
- }
- var herbs = ["edelweiss","glimmermoss","frogscrown","chimingbluebell","royaltoadstool","bloadtedbolete","blueberry","dandelion","chantrelle"];
- function gatherHerbs() {
- while(true) {
- //if (jGetStamina() < 80) drinkWater();
- for (var i=0;i<herbs.length;i++) {
- herb = jFindObjectByName("gfx/terobjs/herbs/"+herbs[i], 200);
- if (herb) break;
- }
- if (herb) {
- jPFMove(herb.position());
- jWaitMove(2000);
- herb.doClick(3,0);
- jSelectContextMenu("Pick")
- jWaitProgress();
- } else {
- return;
- }
- }
- }
- function huntRabbit() {
- rabbit = jFindObjectByName("gfx/borka/s", 200);
- if (!rabbit) return;
- jPrint("rabbit found");
- //jPFMove(rabbit.position());
- }
- function huntFrogs() {
- var frogs = jGetObjects(25, jCoord(0, 0), ["kritter/rat/s"]);
- if (frogs.length==0) return;
- jPrint("frogs found: "+frogs.length);
- jMoveStep(frogs[0].position());
- jWaitMove(2000);
- frogs[0].doClick(3,0);
- }
- var directions = [jCoord(10,0),jCoord(10,10),jCoord(0,10),jCoord(-10,10),jCoord(-10,0),jCoord(-10,-10),jCoord(0,-10),jCoord(10,-10)];
- var current_direction = 0;
- function wander() {
- current_direction = (current_direction + Math.floor(Math.random()*3)-1+directions.length)%directions.length;
- while (jIsPathFree(directions[current_direction])) current_direction=(current_direction+1)%directions.length;
- jMoveStep(directions[current_direction]);
- jWaitMove(2000);
- }
- var edibles = ["blueberry","ants-larvae","ants-pupae","chantrelle"];
- function eat() {
- for (var i =0;i<edibles.length;i++) {
- var found = inventory.getItems(edibles[i]);
- for (var j=0;j<found.length && jGetHungry() < 95;j++) {
- if (found[j].isActual()) {
- found[j].iact();
- jWaitPopup(actionTimeout);
- jSelectContextMenu("Eat");
- waitUnActual(found[j]);
- }
- }
- }
- }
- var curiosities = ["conecow","dandelion"];
- function study() {
- var study = jGetStudy();
- for (var i=0;i<curiosities.length;i++) {
- if (study.getItems(curiosities[i]).length==0) {
- var found = inventory.getItems(curiosities[i]);
- if(found[0].isActual()) {
- var freeslot = study.freeSlotSizeCoord(jCoord(1,1));
- found[0].take();
- jWaitDrag();
- study.drop(freeslot);
- jWaitDrop();
- }
- }
- }
- }
- function main () {
- while(true) {
- gatherHerbs();
- //huntRabbit();
- //huntFrogs();
- makeConecow();
- eat();
- study();
- wander();
- }
- }
- function makeConecow() {
- conecow = inventory.getItems("conecow");
- if (conecow.length<1) {
- var tree = getNearestFirTree();
- if (!tree) return;
- var branches = inventory.getItems("branch");
- var cones = inventory.getItems("seed-fir");
- if (tree) {
- if (branches.length < 4) {
- tree.doClick(3,0);
- jWaitPopup(1000);
- jSelectContextMenu("Take branch");
- while(inventory.getItems("branch").length<4)
- jSleep(100);
- jMoveStep(jCoord(10,0));
- }
- if (cones.length < 1) {
- tree.doClick(3,0);
- jWaitPopup(1000);
- jSelectContextMenu("Pick cone");
- jSleep(1000);
- }
- }
- if (!jHaveCraft("Cone cow")) {
- jSendDoubleAction("craft","conecow");
- jWaitCraft("Cone cow",2000);
- }
- jCraftItem(true);
- jWaitProgress();
- }
- }
- function checkSheet() {
- if(!jHaveWindow("Character sheet")) {
- jToggleSheet();
- while(!jHaveWindow("Character sheet"))
- jSleep(100);
- }
- }
- main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement