Union Client Scripts

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

Moderator: Phades

Re: Union Client Scripts

Postby Arcanist » Thu Sep 05, 2013 6:12 am

Look in your cmd window (the one that appears when you open run.bat) and see what the error is in there.

EDIT: Do you have japi file in your scripts folder?
The error could be that you're using a skin instead of a flask, or that you don't have japi.

Try this script

Code: Select all
//#! tooltip = Starving by 4x speed
//#! name = Starving Bot
//#! uniq = dfccd2e6-1cd5-495d-8947-9f0d6d4059aa

var actionTimeout = 1000 * 60 * 1;

function main() {
   while (jGetHungry() > 50) {
      jSetSpeed(3);
      jMoveStep(jCoord(80, 0));
      jWaitStartMove(30000);
      drinkWater();
      jWaitEndMove(30000);
      jWaitEndProgress(30000);
      jMoveStep(jCoord(-80, 0));
      jWaitStartMove(30000);
      drinkWater();
      jWaitEndMove(30000);
      jWaitEndProgress(30000);
   }
}

function checkInventory() {
   if(!jHaveWindow("Inventory")) {
      jToggleInventory();
      while(!jHaveWindow("Inventory"))
         jSleep(100);
   }
   return jGetWindow("Inventory").getInventories()[0];
}

function drinkWater() {
   var inventory = checkInventory();
   var buckets = inventory.getItems("bucket-water");
   if (buckets.length > 0) {
      inventory.sortItems(buckets, "amount", false);
      var bucket = buckets[0];
      var bucket_coord = bucket.coord();
      if (bucket.isActual()) {
         bucket.take();
         jWaitDrag();
         var flasks = inventory.getItems("waterflask", "waterskin","kuksa");
         if (flasks.length > 0) {
            var flask = flasks[0];
            if (flask.isActual()) {
               flask.itemact(0);
               jSleep(500);
               inventory.drop(bucket_coord);
               jWaitDrop();
            }
         }
      }
   }
   var flasks = inventory.getItems("waterflask", "waterskin", "kuksa");
   if (flasks.length > 0) {
      var flask = flasks[0];
      if (flask.isActual()) {
         flask.iact();
         if (jWaitPopup(actionTimeout)) {
            jSelectContextMenu("Drink");
            jWaitProgress();
         }
      }
   }
}


main();


Also, here is japi, it's probably posted somewhere in this thread and most scripts seem to use it. Personally I shy away from including it, but anyway...

Code: Select all
var actionTimeout = 1000 * 60 * 1;

function waitUnActual(item) {
   while (item.isActual()) {
      jSleep(100);
   }
}

function resetCursor() {
   if (!jIsCursor("arw")) {
      jAbsClick(jCoord(0, 0), 3, 0);
      jWaitCursor("arw", actionTimeout);
   }
}

function checkInventory() {
   if(!jHaveWindow("Inventory")) {
      jToggleInventory();
      while(!jHaveWindow("Inventory"))
         jSleep(100);
   }
   return jGetWindow("Inventory").getInventories()[0];
}

function checkEquipment() {
   if(!jHaveWindow("Equipment")) {
      jToggleEquipment();
      while(!jHaveWindow("Equipment"))
         jSleep(100);
   }
   return jGetJSEquip();
}

function waitInventoryObject(inv, objname) {
   while (true) {
      var objs = inv.getItems(objname);
      if (objs.length > 0) break;
      else jSleep(100);
   }   
}

function drinkWater() {
   var inventory = checkInventory();
   var buckets = inventory.getItems("bucket-water");
   if (buckets.length > 0) {
      inventory.sortItems(buckets, "amount", false);
      var bucket = buckets[0];
      var bucket_coord = bucket.coord();
      if (bucket.isActual()) {
         bucket.take();
         jWaitDrag();
         var flasks = inventory.getItems("waterflask", "waterskin","kuksa");
         if (flasks.length > 0) {
            var flask = flasks[0];
            if (flask.isActual()) {
               flask.itemact(0);
               jSleep(500);
               inventory.drop(bucket_coord);
               jWaitDrop();
            }
         }
      }
   }
   var flasks = inventory.getItems("waterflask", "waterskin", "kuksa");
   if (flasks.length > 0) {
      var flask = flasks[0];
      if (flask.isActual()) {
         flask.iact();
         if (jWaitPopup(actionTimeout)) {
            jSelectContextMenu("Drink");
            jWaitProgress();
         }
      }
   }
}

function dropItem(coord) {
   var items = checkInventory().getItems("");
   for (var i = 0; i < items.length; i++) {
      if (items[i].coord().x == coord.x && items[i].coord().y == coord.y) {
         items[i].drop();
         break;
      }
   }   
}

function waitDragName(name) {
   while (true) {
      var item = jGetDraggingItem();
      if (item != null) {
         if (item.resName() != null) {
         if (item.resName().indexOf(name) >= 0) {
            break;
         } else {
            jSleep(100);
         }
         } else jSleep(100);
      } else {
         break;
      }
   }
}

function waitPFEndMove() {
   while (true) {
      jWaitEndMove();
      jSleep(500);
      if (!jIsMoving()) {
         return;
      }
   }
}

function getNearestTree() {
   var trees = jGetObjects(25, jCoord(0, 0), ["trees/fir", "trees/pine"]);
   var min_len = 100500; var objid = 0;
   for (var i = 0; i < trees.length; i++) {
      if (jObjectPos(trees[i]).dist(jMyCoords()) < min_len) {
         objid = trees[i];
         min_len = jObjectPos(trees[i]).dist(jMyCoords());
      }
   }
   return objid;
}

function travelCount() {
   var buffs = jGetBuffs();
   for (var i = 0; i < buffs.length; i++) {
      if (buffs[i].name().indexOf("Travel Weariness") >= 0) {
         return buffs[i].meter();
      }
   }
   return 0;
}

function noMoreWine() {
   var buffs = jGetBuffs();
   for (var i = 0; i < buffs.length; i++) {
      if (buffs[i].name().indexOf("Drunk and Riotous") >= 0) {
         return true;
      }
   }
   return false;
}

function _pf_click(id) {
   if (!jIsPathFree(jObjectPos(id))) {
      resetCursor();
      if (jPFClick(id) > 0) {
         if (jWaitStartMove(1000)) {
            waitPFEndMove();
            while (jIsMoving() || jMyCoords().dist(jObjectPos(id)) > 33) {
               jSleep(100);
            }
            return true;
         }
      }
   }
   return false;
}

function _pf_move(coord) {
   if (!jIsPathFree(coord)) {
      resetCursor();
      if (jPFMove(coord) > 0) {
         if (jWaitStartMove(1000)) {
            waitPFEndMove();
            while (jIsMoving() || jMyCoords().dist(coord) > 1) {
               jSleep(100);
            }
            return true;
         }
      }
   }
   return false;
}

function dropAll() {
   if (jIsDragging()) {
      jDropObject(0);
      jWaitDrop(actionTimeout);
   }
}

function waitChat(name, timeout) {
   var time = 0;
   while (true) {
      var chats = haven.getChats();
      for (var i = 0; i < chats.length; i++) {
         if (chats[i].chatName().indexOf(name) >= 0) {
            return true;
         }
      }
      jSleep(100);
      time += 100;
      if (time > timeout) return false;
   }
}

// Ãîâîðèò òåêñò â àðåà ÷àò
function sayArea(text) {
   var chats = jGetChats();
   for (var i = 0; i < chats.length; i++) {
      if (chats[i].chatName().indexOf("Area Chat") >= 0) {
         chats[i].sendMessage(text);
         break;
      }
   }
}


Name it jBotAPI.japi
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby xxlasciel » Thu Sep 05, 2013 6:38 am

Well I did all of the things you told me to and it seems at least one of them worked :)

My original error was : "ReferenceError: "drinkWater" is not defined. (Starving Bot#12) if that helps you pin anything down.

Regardless, many thanks for the help!
xxlasciel
 
Posts: 4
Joined: Tue Sep 03, 2013 7:38 pm

Re: Union Client Scripts

Postby Arcanist » Thu Sep 05, 2013 8:34 am

That would mean that you don't have japi in your scripts folder.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby maiklDuglas123 » Thu Sep 05, 2013 6:20 pm

Hello,i need help.Bot must re login and collect mussels but he dont collect it

PS sorry for my bad english :D
Code: Select all
//#! name = Adolf
//#! tooltip = Take mussel from whater
//#! icon = gfx/invobjs/mussel

include("jBotAPI");

var ACCNAME = "-";   //login
var CHARNAME = "-"; //name

function whereYouLoggedOut()  {
 jSleep(1000);
 jLogout();
 jSleep(1000);
 jLogin(ACCNAME);
   while(!jHaveCharlist())
      jSleep(700);
   jSelectChar(CHARNAME);
   var logwnd = jWaitNewWindow(CHARNAME, 120000);
   jSleep(100);
   logwnd.pushButton(2);
}

function main()  {
   while(true){
   var mussel = null;
   while (mussel == null && checkInventory().freeSlots() > 2)
   mussel = jFindObjectByName("mussel", 100);
 jDoClick(mussel.getID(), 3, 0);
 jWaitPopup(2000);
 jSelectContextMenu("Pick");
 jSleep(2000);
 jWaitMove();
 jWaitEndProgress(2000);
 jSleep(1000);
    }
}
while(true){
checkInventory();
whereYouLoggedOut();
main();
}
maiklDuglas123
 
Posts: 11
Joined: Thu Apr 07, 2011 8:25 am

Re: Union Client Scripts

Postby Arcanist » Thu Sep 05, 2013 7:35 pm

maiklDuglas123 wrote:Hello,i need help.Bot must re login and collect mussels but he dont collect it

PS sorry for my bad english :D
Code: Select all
//#! name = Adolf
//#! tooltip = Take mussel from whater
//#! icon = gfx/invobjs/mussel

include("jBotAPI");

var ACCNAME = "-";   //login
var CHARNAME = "-"; //name

function whereYouLoggedOut()  {
 jSleep(1000);
 jLogout();
 jSleep(1000);
 jLogin(ACCNAME);
   while(!jHaveCharlist())
      jSleep(700);
   jSelectChar(CHARNAME);
   var logwnd = jWaitNewWindow(CHARNAME, 120000);
   jSleep(100);
   logwnd.pushButton(2);
}

function main()  {
   while(true){
   var mussel = null;
   while (mussel == null && checkInventory().freeSlots() > 2)
   mussel = jFindObjectByName("mussel", 100);
 jDoClick(mussel.getID(), 3, 0);
 jWaitPopup(2000);
 jSelectContextMenu("Pick");
 jSleep(2000);
 jWaitMove();
 jWaitEndProgress(2000);
 jSleep(1000);
    }
}
while(true){
checkInventory();
whereYouLoggedOut();
main();
}


Post the co-ords of where you use this, that might have something to do with the problem.
User avatar
Arcanist
 
Posts: 2664
Joined: Mon Mar 19, 2012 2:01 pm

Re: Union Client Scripts

Postby Foetuses » Fri Sep 06, 2013 12:26 am

Arcanist wrote:
maiklDuglas123 wrote:Hello,i need help.Bot must re login and collect mussels but he dont collect it

PS sorry for my bad english :D
...


Post the co-ords of where you use this, that might have something to do with the problem.


:roll:
Foetuses
 
Posts: 79
Joined: Tue Mar 27, 2012 11:55 pm

Re: Union Client Scripts

Postby maiklDuglas123 » Fri Sep 06, 2013 9:50 am

Arcanist wrote:
maiklDuglas123 wrote:Hello,i need help.Bot must re login and collect mussels but he dont collect it

PS sorry for my bad english :D
Code: Select all
//#! name = Adolf
//#! tooltip = Take mussel from whater
//#! icon = gfx/invobjs/mussel

include("jBotAPI");

var ACCNAME = "-";   //login
var CHARNAME = "-"; //name

function whereYouLoggedOut()  {
 jSleep(1000);
 jLogout();
 jSleep(1000);
 jLogin(ACCNAME);
   while(!jHaveCharlist())
      jSleep(700);
   jSelectChar(CHARNAME);
   var logwnd = jWaitNewWindow(CHARNAME, 120000);
   jSleep(100);
   logwnd.pushButton(2);
}

function main()  {
   while(true){
   var mussel = null;
   while (mussel == null && checkInventory().freeSlots() > 2)
   mussel = jFindObjectByName("mussel", 100);
 jDoClick(mussel.getID(), 3, 0);
 jWaitPopup(2000);
 jSelectContextMenu("Pick");
 jSleep(2000);
 jWaitMove();
 jWaitEndProgress(2000);
 jSleep(1000);
    }
}
while(true){
checkInventory();
whereYouLoggedOut();
main();
}


Post the co-ords of where you use this, that might have something to do with the problem.


http://SSMaker.ru/1151a2cc/
maiklDuglas123
 
Posts: 11
Joined: Thu Apr 07, 2011 8:25 am

Re: Union Client Scripts

Postby juchan » Fri Sep 06, 2013 4:17 pm

Hey Again ;p

First bot work (Foetuses bot) but this bot only work for short distance and after collect all from spot dont look for other.

Arcanist bot dont work (after click i see mussel finished


Im looking for bot which will pick mussels to inventory and next looking for other mussels to pick.
Thanks :)
juchan
 
Posts: 15
Joined: Sun Aug 25, 2013 4:08 pm

Re: Union Client Scripts

Postby Foetuses » Fri Sep 06, 2013 10:36 pm

juchan wrote:Hey Again ;p

First bot work (Foetuses bot) but this bot only work for short distance and after collect all from spot dont look for other.

Arcanist bot dont work (after click i see mussel finished


Im looking for bot which will pick mussels to inventory and next looking for other mussels to pick.
Thanks :)


That bot would be quite a bit more complex; pathing down a river system isn't a simple thing to do dynamically. I'm afraid I can't help you there.

Of course, a human easily finds the optimal path. :roll:
Foetuses
 
Posts: 79
Joined: Tue Mar 27, 2012 11:55 pm

Re: Union Client Scripts

Postby haelmut » Tue Sep 10, 2013 6:02 pm

Hi can someone help me to understand whats the problem with this taker script? It worked fine and then witout reason stoped to work. After choising object to pick up bot finish to work without any actions.

It looks like something wrong with checkInventory() comand.


Code: Select all
    //#! name = Taker
    //#! tooltip = Take items from ground
    //#! uniq = taker_apxproductions

    include("jBotAPI");

    var selected = jSelectObject("Select object");
    var resname = selected.name();
    var obj = jFindObjectByName(resname, 15);
    while (obj != 0 && checkInventory().freeSlots() > 0) {
       jDoClick(obj.getID(), 3, 0);
       jWaitMove(1000);
       jSleep(100);
       if (jGetDraggingItem()) {
          jDropObject(0);
          break;
       }
       obj = jFindObjectByName(resname, 15);
    }


Image
User avatar
haelmut
 
Posts: 70
Joined: Sat Apr 06, 2013 9:36 am

PreviousNext

Return to The Wizards' Tower

Who is online

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