Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby pabluuz » Sat Nov 02, 2013 8:34 pm

Hi Guys.

I've got some problems with scripting. Maybe someone had same problems as me, and would be able to help me out ;)

Code: Select all
function _pf_move(coord) {
   if (!jIsPathFree(coord))
   {
      resetCursor();
      jPFMove(jTilify(coord));
      while (jMyCoords().dist(jTilify(coord)) > 1)
      {
         jSleep(100);
      }
      return true;
      
   }
   else
   {
      resetCursor();
      jAbsClick(coord,1,0)
      while (jMyCoords().dist(coord) > 1)
      {
         jSleep(100);
      }
      return false;
   }
}
function NewArrayWithout1stElement(arr) {
   newarr = [];
   for (var i = 1; i < arr.length; i++) {
   newarr[i-1] = arr[i];
   }
return newarr;
}

function main()
{
var hartling = jMyCoords();
var logs = jGetObjects(20,jCoord(0,0),"log");
while (logs.length>0)
{
   var log = logs[0]
   jPrint(log.position());
   _pf_move(log.position());
   jSleep(500);
   jSendAction("carry");
   jWaitCursor("chi");
   jDoClick(log.getID(), 1, 0);
   //_move_wait_for_stop();
   //waitPFEndMove()
   //jSleep(1000);
   jSleep(1000);
   _pf_move(jTilify(jMyCoords()));
   //resetCursor();
   jSleep(500);
   _pf_move(hartling);
   jSleep(500);
   jAbsClick(jMyCoords(), 3, 0);
   jSleep(500);
   logs = NewArrayWithout1stElement(logs);
}
}


When it doesn't need PF, just a straight line, than it's fine (check it out). But when the time for PF comes..

So, my character picks up log, (he even PF to it, when it's unreachable by straight line) but he don't go back to start point (var hartling = jMyCoords();). My union client shows green path line, my character makes one step and than he stops. What I'm doing wrong? I've got problems with this PF functions every time I'm trying to use it :) What's the correct way?

Kind Regards! :)


Oh and btw, mvgulik. GJ! Works like a charm ;)

Edit:
I've tried different options (like PF from farmer script)
Code: Select all
function _pf_move(coord) {
   if (!jIsPathFree(coord))
   {
      resetCursor();
      jPFMove(coord);
      jWaitStartMove()
      waitPFEndMove();
      while (jIsMoving() || jMyCoords().dist(jTilify(coord)) > 1)
      {
         jSleep(100);
      }
      return true;
      
   }
   else
   {
      _move(coord)
      return false;
   }
}


But still no success. It get's more interesting, because farmer script is working fine for me ;)
Last edited by pabluuz on Tue Nov 12, 2013 2:52 pm, edited 1 time in total.
pabluuz
 
Posts: 4
Joined: Sun Sep 15, 2013 12:22 pm

Re: Union Client Scripts

Postby Arcanist » Sat Nov 02, 2013 11:37 pm

if he is standing on a hearthfire, recently ported to vidol, or attachet to a tool (eg loom) then he will have trouble PF walking.

Use
Code: Select all
   jMoveStep(jCoord(1, 0));
   jWaitMove(1000);
   jMoveStep(jCoord(-1, 0));
   jWaitMove(1000);


To get unstuck, before you try to PF
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby pabluuz » Sat Nov 02, 2013 11:52 pm

Arcanist wrote:if he is standing on a hearthfire, recently ported to vidol, or attachet to a tool (eg loom) then he will have trouble PF walking.

Use
Code: Select all
   jMoveStep(jCoord(1, 0));
   jWaitMove(1000);
   jMoveStep(jCoord(-1, 0));
   jWaitMove(1000);


To get unstuck, before you try to PF



Thanks for reply, but i'm not even 5 screens away from my HF or vidol or big tool like loom ;) Seems like there's problem with second pf move. Every first time i'm using pf move in script, it's ok, but when i'm using it second time, it gets stuck (even in open area 10x10 clean tiles). What PF function are You using to pf move, and than check if character reached it's destination?
pabluuz
 
Posts: 4
Joined: Sun Sep 15, 2013 12:22 pm

Re: Union Client Scripts

Postby Arcanist » Sat Nov 02, 2013 11:53 pm

Code: Select all
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
//Pathfinder
function _pf_click(id) {
   if (!jIsPathFree(jGob(id))) {
      resetCursor();
      if (jPFClick(id) > 0) {
         if (jWaitStartMove(1000)) {
            waitPFEndMove();
            while (jIsMoving() || jMyCoords().dist(jObjectPos(id)) > 33) {
               jSleep(100);
            }
            return true;
         }
      }
   }
   return false;
}

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;
     
   jPFMove(point);
   cycles = 0;
   while (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 == 10)
      {     
         jPrint("jPFMove_LX trying to move again");
         jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
         jSleep(500);
         jPFMove(point);
         cycles = 0
      }
      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) {
      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");
//      break;

         jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
         jSleep(500);
     
   }
}


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


Use jPFMoveOffset_LX(point, offset)

eg
jPFMoveOffset_LX(getNearestTree() /*or objid */.position(), 2);
waitPFEndMove();
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby pabluuz » Sun Nov 03, 2013 12:56 am

Yay! I dunno why, but it works.

For everyone with same problem. Use jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0); if You're stuck in PF.
I've made small fix in jPFMove_LX, to prevent Your character from drunk movement while in problems with PF ;)
Here's complete movement script that checks if You need PF to reach target, or You can just move straight:

Code: Select all
// Paste it at the end of jbotapi and include in Your scripts ;)
// Use _pf_move(coord_here_plx); to move (You can get position of object by using object.position())
function _pf_move(coord) {
   if (!jIsPathFree(coord))
   {
      jPFMove_LX(coord);
      waitPFEndMove();
      return true;
      
   }
   else
   {
      _move(coord);
      return false;
   }
}
// CREDITS TO ARCANIST FOR THIS PART
function jPFMove_LX(point) {
   point = jTilify(point);
   var MyX = jMyCoords().x;
   var MyY = jMyCoords().y;
     
   jPFMove(point);
   cycles = 0;
   MyX = jMyCoords().x;
   MyY = jMyCoords().y;
   MyPrevX = MyX
   MyPrevY = MyY
   while (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 == 10)
      {     
         jPrint("jPFMove_LX trying to move again");
         jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
         jSleep(500);
         jPFMove(point);
         cycles = 0
      }
     if (MyX == MyPrevX && MyY == MyPrevY)
     {
      cycles++;
     }
     MyPrevX = MyX
     MyPrevY = MyY
   }
   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) {
      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");
//      break;

         jOffsetClick(jCoord(getRandomArbitary(-2,2),getRandomArbitary(-2,2)),1,0);
         jSleep(500);
     
   }
}


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


And here's updated logs collector (it moves logs to point where You started script)
Code: Select all
// don't forget to include movement functions ;)
include("jBotAPI");

function NewArrayWithout1stElement(arr) //not my function, but its great
{
   newarr = [];
   for (var i = 1; i < arr.length; i++) {
   newarr[i-1] = arr[i];
   }
return newarr;
}
function main()
{
var hartling = jMyCoords();

// Collect Logs
var logs = jGetObjects(20,jCoord(0,0),"log");
while (logs.length>0)
{
   var log = logs[0]
   jPrint(log.position());
   _pf_move(log.position());
   jSleep(500);
   jSendAction("carry");
   jWaitCursor("chi");
   jDoClick(log.getID(), 1, 0);
   jSleep(1000); // in case of lag :D
   _pf_move(hartling);
   jSleep(500);
   jAbsClick(jMyCoords(), 3, 0);
   jSleep(500);
   logs = NewArrayWithout1stElement(logs);
}
}
main();

It's 1.00 AM, so I might have missed something. Please tell me if It's something wrong.
Last edited by pabluuz on Tue Nov 12, 2013 2:51 pm, edited 2 times in total.
pabluuz
 
Posts: 4
Joined: Sun Sep 15, 2013 12:22 pm

Re: Union Client Scripts

Postby mvgulik » Sun Nov 03, 2013 2:14 pm

...
Last edited by mvgulik on Wed Dec 25, 2013 5:35 pm, edited 1 time in total.
mvgulik
 
Posts: 3774
Joined: Fri May 21, 2010 2:29 am

Re: Union Client Scripts

Postby pabluuz » Mon Nov 11, 2013 11:22 pm

Hello again ;)

I was wondering if anyone figured out, how to handle barter stand via script?

Ok, so I'm the owner of the stand, and i'd like to remove my *let's call them profit items* (can't find good word).

First of all, I should get item obj, and shift click it
Code: Select all
good_to_transfer=jSelectObject("Select good from stand");
jDoClick(good_to_transfer,1,1);//left, shift


Problem is, that I can't select it. (that's not a big surprise)
So, how can I define object in stall, so I can click it? Or maybe, there's no actual object there, and I need to figure it out somehow else? :)

Edit: jGetWindow("Barter Stand").pushButton("Plant fibres, quality 10+"); , nope
jGetWindow("Barter Stand").pushButton(1);, nope, but 2 changes sign of barter stand :P
pabluuz
 
Posts: 4
Joined: Sun Sep 15, 2013 12:22 pm

Bots for Union client

Postby Bambek » Wed Nov 13, 2013 9:23 pm

Hello.
Can anybody give me bots wich are now aviable to use?
I would be very thankful to u.
Last edited by borka on Wed Nov 13, 2013 10:08 pm, edited 1 time in total.
Reason: moved from HDI
Bambek
 
Posts: 1
Joined: Wed Nov 13, 2013 9:21 pm

Re: Union Client Scripts

Postby StuffedBoar » Fri Nov 22, 2013 3:36 pm

Could anyone share a script for drinking while running?
StuffedBoar
 
Posts: 10
Joined: Fri Oct 18, 2013 11:11 pm

Re: Union Client Scripts

Postby Bramson » Fri Nov 29, 2013 4:56 am

Working on a script where I want to pull things out of a build site..

jGetBuildValues("signname",1).charAt(0)

I can determine how much left needed to put in, but what about pulling out?

What code would make it so you can pull stuff out instantly with transferSuchAll();

Thanks!
"All video/images of coles abominably wearing beard will be purged from the forums." - Jorb

"We won't ever deploy our militia to fight anyone." - Robben_DuMarsch, leader of New Brodgar; diagnosis: Napoleon Syndrome
User avatar
Bramson
 
Posts: 244
Joined: Tue Jul 02, 2013 5:48 am
Location: Hawaii

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Amazon [Bot], Claude [Bot] and 0 guests