Union Client Scripts

Forum for alternative clients, mods & discussions on the same.

Moderator: Phades

Re: Union Client Scripts

Postby Arcanist » Thu Nov 13, 2014 9:59 am

shubla wrote:except sometimes it gets stuck if log gets inside another tree. And sometimes it also starts pathfinding itself to random directions.


This script was intended for treefarms, no?


Builds Cupboards in area:

Code: Select all
//#! uniq = arcanist_builder
//#! name = Cupboard Builder
//#! icon = gfx/invobjs/small/cheese-tray

include("jBotAPI");

function getRandomArbitary(min, max){
  return Math.random() * (max - min) + min;
}

function jPFMove_LX(point) {
   point = jTilify(point);
   var MyX = jMyCoords().x;
   var MyY = jMyCoords().y;
   if (jIsPathFree(point)) jAbsClick(point, 1, 0);
   else jPFMove(point);
   cycles = 0;
   wcontinue = true;
   while (wcontinue) {
      wcontinue = MyX != point.x || MyY != point.y;
      jPrint("jPFMove_LX My =" + MyX + " " + MyY + " - " + point.x + " " + point.y);
      jSleep(1000);
      MyX = jMyCoords().x;
      MyY = jMyCoords().y;
      if(cycles == 6) {     
         jPrint("jPFMove_LX trying to move again");
         jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
         jSleep(500);
         if (!jIsPathFree(point)) jPFMove(point);
       else jAbsClick(point, 1, 0);
         cycles = 0
         wcontinue = false;
      }
      cycles++;
   }
   jPrint("jPFMove ended");
}

function jPFMoveOffset_LX(point, offset) {
   offsMoveS=jCoord(0,offset);
   offsMoveE=jCoord(offset,0);
   offsMoveW=jCoord(-offset,0);
   offsMoveN=jCoord(0,-offset);
   
   while (1){
try   {
   /*
   if (jIsPathFree(point.add(offsMoveS.mul(11)))) {
      jAbsClick(point, 1, 0);
      return offsMoveS;
      }
   if (jIsPathFree(point.add(offsMoveE.mul(11)))) {
      jAbsClick(point, 1, 0);
      return offsMoveE;
      }
   if (jIsPathFree(point.add(offsMoveW.mul(11)))) {
      jAbsClick(point, 1, 0);
      return offsMoveW;
      }
   if (jIsPathFree(point.add(offsMoveN.mul(11)))) {
      jAbsClick(point, 1, 0);
      return offsMoveN;
      }
   */
      if(jPFMove(point.add(offsMoveS.mul(11))) > 0) {
         jPFMove_LX(point.add(offsMoveS.mul(11)));
      return offsMoveS;
      }
     
      if(jPFMove(point.add(offsMoveE.mul(11))) > 0) {
         jPFMove_LX(point.add(offsMoveE.mul(11)));
      return offsMoveE;
      }
     
      if(jPFMove(point.add(offsMoveW.mul(11))) > 0) {
         jPFMove_LX(point.add(offsMoveW.mul(11)));
      return offsMoveW;
      }   
     
      if(jPFMove(point.add(offsMoveN.mul(11))) > 0) {
         jPFMove_LX(point.add(offsMoveN.mul(11)));
      return offsMoveN;
      }
      jPrint("jPFMoveOffset_LX can't find path to " + point + " offset " + offset);
//      break;

         jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
         jSleep(500);
     
   }
   catch(e) {
   jPrint(e);
   }
}
}


function waitPFEndMove(){
   jWaitStartMove(300);
   jSleep(100);
   while (true) {
      jWaitEndMove(10000);
      jSleep(200);
      if (!jIsMoving()) {
         return;
      }
   }
}


function selectAreaInRect(title) {
   jMoveStep(jCoord(0, 0));
   var offs = jCoord(0, 0);
   var size = jCoord(1, 1);
   var confirm = false;
   jDrawGroundRect(offs, size);
   var blist = ["West", "East", "North", "South", "Inc width", "Inc height", "Dec width", "Dec height", "Confirm", "Exit"];
   var selectWindow = jGUIWindow(jCoord(250, 250), jCoord(105, blist.length * 25 + 15), "Area");
   var label = jGUILabel(selectWindow, jCoord(5, 5), title);
   for(var i = 0; i < blist.length; i++)
      jGUIButton(selectWindow, jCoord(5, 25 + i*25),  100, blist[i]);
   selectWindow.toggleCloseButton();
   var btext = "";
   while(btext != "Exit"){
      btext = selectWindow.waitButtonClick();
      if(btext == blist[0]) offs.x--;
      if(btext == blist[1]) offs.x++;
      if(btext == blist[2]) offs.y--;
      if(btext == blist[3]) offs.y++;
      if(btext == blist[4]) size.x++;
      if(btext == blist[5]) size.y++;
      if(btext == blist[6]) if(size.x > 1) size.x--;
      if(btext == blist[7]) if(size.y > 1) size.y--;
      if(btext == blist[8]) {confirm = true; break;}
      jDrawGroundRect(offs, size);
   }
   selectWindow.destroy();
   jDrawGroundRect(offs, jCoord(0, 0));
   var startCoord = jMyCoords().add(offs.mul(11));
   var fieldSize = size;
   var returns = [];
   //jToConsole(size);
   //jToConsole(startCoord);
   //jToConsole(offs);

   returns[0] = jCoord(startCoord.x,startCoord.y ); // Top left
   returns[1] = jCoord(startCoord.x,startCoord.y + 11 * (size.y - 1) ); // Bottom Left
   returns[2] = jCoord(startCoord.x + 11 * (size.x- 1),startCoord.y ); // Top Right
   returns[3] = jCoord(startCoord.x + 11 * (size.x- 1),startCoord.y + 11 * (size.y - 1) ); // Bottom Right
   returns[4] = size;

   

   
   
   return returns;
}

function goNearPosition( position, offset){
       while (jIsMoving() || jMyCoords().dist(position) > offset*11){
         jPFMoveOffset_LX(position, offset);
         jSleep(500);
      }
}

function getBoards(number){
jPrint("Getting Boards");
var obj = jFindObjectByName("items/board", 15);
while (obj == null){
   var log = getNearest("log");
   goNearPosition( log.position(), 1);
   equipSaw();
   jDoClick(log.getID(), 3, 0);
    jWaitPopup(1000);
    jSelectContextMenu("Make Boards");
    jWaitProgress(actionTimeout);
   var obj = jFindObjectByName("items/board", 15);
   }

   

   while (obj != null && checkInventory().freeSlots() > 0 && checkInventory().getItems("items/board").length  < number) {
   if (obj == null) break;
      if (!jIsPathFree(obj.position())) {
         jPrint("Found board");
         jPrint(obj.position());
         jPFMoveOffset_LX(obj.position(), 0);
         waitPFEndMove();
         }
      jDoClick(obj.getID(), 3, 0);
      jWaitMove(1000);
      jSleep(100);
      if (jGetDraggingItem()) {
        jDropObject(0);
        break;
      }
      var obj = jFindObjectByName("items/board", 15);
   }
}

function makeSign(sign_coord, action, signwindow){
   while(!jGetWindow(signwindow)){
      jPrint("Trying to make sign");
      jPFMoveOffset_LX(sign_coord, 1);
      jSendDoubleAction(action[0], action[1]);
      jSleep(1000);
      
      
      jPlace(jCoord(0, -1),  1, 0);
      jSleep(1000);
      jAbsClick(sign_coord, 3, 0);
      var sign = jFindMapObjectNearAbs(sign_coord, 1, "sign");
      checkInventory().getItems("board")[0].transferSuchAll();
      
   }
   return sign;
}

function openSign(sign, signwindow){
      while(!jHaveWindow(signwindow)){
         jToConsole("Opening Sign");
         goNearPosition(sign.position(), 1);
         jSleep(500);
         jDoClick(sign.getID(), 3, 0);
         jSleep(500);
         if (!jHaveWindow(signwindow)) jSleep(500);
         }
         return;
}

function main(){
    var rect = selectAreaInRect("Select area to build");
   var signwindow = "Cupboard";
    var topleft_coord = rect[0];
    var bottomright_coord = rect[3];
    var widthtiles = Math.floor((bottomright_coord.x-topleft_coord.x)/11)
    var heighttiles = Math.floor((bottomright_coord.y-topleft_coord.y)/11)
    for (var height=0;height<=heighttiles;height++){
        for (var width=0;width<=widthtiles;width++){
      
         getBoards(8);
         
         var sign = makeSign(jCoord(topleft_coord.x+width*11,topleft_coord.y+height*11), ["bp", "cupboard"], signwindow);
         drinkWater();
         openSign(sign, signwindow);
         var vals = GetBuildValues(signwindow, 1)[0];
         jToConsole(vals);
         while(vals > 0){
            getBoards(GetBuildValues(signwindow, 1)[0]);
            drinkWater();
            putItemsToSign ("board", sign, signwindow, 1, 1);
            var sign = jFindMapObjectNearAbs(jCoord(topleft_coord.x+width*11,topleft_coord.y+height*11), 1, "sign");
            jMoveStep(jCoord(0, 0));
            jSleep(500);
            openSign(sign, signwindow);
            var vals = GetBuildValues(signwindow, 1)[0];
            jToConsole(vals);
         }
         

         var sign = jFindMapObjectNearAbs(jCoord(topleft_coord.x+width*11,topleft_coord.y+height*11), 1, "sign");
         openSign(sign, signwindow);

         var sign = jFindMapObjectNearAbs(jCoord(topleft_coord.x+width*11,topleft_coord.y+height*11), 1, "sign");
         
         jPrint("Going to build");
         jSleep(500);
         while (sign){
            while(!jHaveWindow(signwindow)){
               openSign(sign, signwindow);
               
            }
            jSleep(1000);
            while (!jHaveHourglass() && jHaveWindow(signwindow)){
               jGetWindow(signwindow).pushButton("Build");
               jPrint("Pressed Button");
               jSleep(250);
            }
            jWaitStartProgress(actionTimeout);
            while (jHaveHourglass()) {
               jSleep(500);
            }
            var sign = jFindMapObjectNearAbs(jCoord(topleft_coord.x+width*11,topleft_coord.y+height*11), 1, "sign");
         }
      }
   }
   
}

main();
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby TheMasterWolf » Wed Dec 03, 2014 5:20 am

Does anyone have a fully functional logger bot that will chop tree and take the logs to village idol , im looking for one and works in the wild not on a tree farm? The one i have has a buggy wine function
The Master of All Dictators!! Anger me and you will be sent to the chambers!
TheMasterWolf
 
Posts: 124
Joined: Tue Jul 02, 2013 6:07 pm

Re: Union Client Scripts

Postby Arcanist » Wed Dec 03, 2014 6:19 am

why not just fix the wine function?

I posted one earlier, but it's not very good.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby TheMasterWolf » Wed Dec 03, 2014 2:22 pm

I've tried and cant really figure it out
The Master of All Dictators!! Anger me and you will be sent to the chambers!
TheMasterWolf
 
Posts: 124
Joined: Tue Jul 02, 2013 6:07 pm

Re: Union Client Scripts

Postby Ocerion » Mon Dec 15, 2014 7:49 pm

Any chance a simple mining script to mine a selected area (Much like the mining script in the Ceres client) and drop anything picked up, could be requested? Well. Be requested...and then someone come up with one?
Ocerion
 
Posts: 113
Joined: Tue Feb 08, 2011 6:53 am

Re: Union Client Scripts

Postby TheMasterWolf » Sun Dec 28, 2014 7:02 pm

What is the res for a heartfire? im trying to make a script that will move logs from idol to hf and stack them at the hearthfire but i need to know the res for the hearthfire.
The Master of All Dictators!! Anger me and you will be sent to the chambers!
TheMasterWolf
 
Posts: 124
Joined: Tue Jul 02, 2013 6:07 pm

Re: Union Client Scripts

Postby windmaker » Sun Dec 28, 2014 7:10 pm

gfx/terobjs/hearth
Image #swag
User avatar
windmaker
 
Posts: 1855
Joined: Thu Mar 29, 2012 7:08 am
Location: in the forum where some mods are fags.

Re: Union Client Scripts

Postby juchan » Mon Dec 29, 2014 4:03 pm

Wondering if there is bot for full cheese making.
If you got something (even similiar) share please :-) :-)
juchan
 
Posts: 15
Joined: Sun Aug 25, 2013 4:08 pm

Re: Union Client Scripts

Postby windmaker » Mon Dec 29, 2014 4:06 pm

juchan wrote:Wondering if there is bot for full cheese making.
If you got something (even similiar) share please :-) :-)

the exit is there ->
Image #swag
User avatar
windmaker
 
Posts: 1855
Joined: Thu Mar 29, 2012 7:08 am
Location: in the forum where some mods are fags.

Re: Union Client Scripts

Postby Arcanist » Mon Dec 29, 2014 8:43 pm

windmaker wrote:
juchan wrote:Wondering if there is bot for full cheese making.
If you got something (even similiar) share please :-) :-)

the exit is there ->
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot] and 1 guest