Union Client Scripts

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

Moderator: Phades

User avatar
DPblH
Posts: 432
Joined: Wed Jun 09, 2010 4:57 pm

Re: Union Client Scripts

Post by DPblH »

tampax911 wrote:"...but when I debugged hearth fire action the console said act click: theTrav, hearth..."
what is the console ? how do you see/read/use it??
I cant find any console for debuging.

and for you question - try this:
jSendDoubleAction("theTrav", "hearth");
Press Shift+F12, and there will be debug info (in console) about ingame actions.
Give a man a game engine and he delivers a game. Teach a man how to make a game engine and he never delivers anything.
Marsunpaisti
Posts: 25
Joined: Thu Jan 26, 2012 9:35 pm

Re: Union Client Scripts

Post by Marsunpaisti »

Does someone know how to get to the curiosities inventory? I tried to get them like this but it didn't work and returned "cannot call method "getItems" of undefined when I had my character sheet open on the curiosities tab?

Code: Select all

var curiosities = jGetWindow("Character Sheet").getInventories()[0].getItems("invobjs/");
User avatar
Usernm
Posts: 38
Joined: Mon May 13, 2013 12:29 pm

Re: Union Client Scripts

Post by Usernm »

Your script not found inventory. And study not work right from bot without patching source code.
Sorry for my english, I am from Russia and use soviet one. :)
User avatar
overtyped
Posts: 3906
Joined: Tue Sep 28, 2010 2:09 am
Location: Quaran book burning festival

Re: Union Client Scripts

Post by overtyped »

Can some magnanimous person please post some scripts! I'm dying here.
Early world exploit: Put your hearthfire inside a cave, then hold shift to position a claim right in front of a cave. After 8 hours the claim will be unbreakable. Since your hearthfire is inside the cave, you can still get back inside, and leave, but nobody will be able to enter, effectively making you unraidable for the first 3-7 days. Enjoy
User avatar
DPblH
Posts: 432
Joined: Wed Jun 09, 2010 4:57 pm

Re: Union Client Scripts

Post by DPblH »

Marsunpaisti wrote:Does someone know how to get to the curiosities inventory? I tried to get them like this but it didn't work and returned "cannot call method "getItems" of undefined when I had my character sheet open on the curiosities tab?

Code: Select all

var curiosities = jGetWindow("Character Sheet").getInventories()[0].getItems("invobjs/");
I've added this yesterday to client, but I'm too lazy to upload sources, lol.

Code: Select all

jToConsole(jGetStudy().getItems("")[0].currentCurioLP());
Give a man a game engine and he delivers a game. Teach a man how to make a game engine and he never delivers anything.
naosnule
Posts: 394
Joined: Fri May 24, 2013 6:18 pm

Re: Union Client Scripts

Post by naosnule »

Reposting several scripts that are on the internet for those who don't know yet (I haven't authored any of them, but the more is widely known, the higher chance that jorbtar starts doing something about things).

There is some shit such as pathfinding code in the codes submitted below. Do specially pay attention at the functions called "jPFMove(point)" and "jPFMoveOffset_LX(point, offset)". Of course "jPFMove(point)" is already described in the documentation found at http://unionclient.ru/doc/jbot/index.ht ... x-all.html. The documentation is certainly lacking but by looking at how they are used in scripts, you can find out how to use them correctly.

Code: Select all

//#! name = log harvester
//#! tooltip = harvest log

include("jBotAPI");

var hartling = jMyCoords();   

function harvest(){
      var log = jFindObjectByName("log", 15).getID();
      jSendAction("carry");
      jWaitCursor("chi");
      jDoClick(log, 1, 0);
      jWaitMove();
      jSendDoubleAction("theTrav", "hearth");
      jWaitProgress(300000);
      jMoveStep(jCoord(0, -2));
      jWaitMove();
      jAbsClick(jMyCoords(), 3, 0);
      jWaitMove();
      jPFMove(hartling);
      waitPFEndMove();
      jAbsClick(jMyCoords(), 1, 0);
   

}   
while(true){
if (jMyCoords()==hartling){
harvest()
}
else{
jDoClick(jMyCoords(), 1, 0)
jPFMove(hartling);
waitPFEndMove();
}
}

Code: Select all

//#! name = Well to Barrel
//#! uniq = WELLTOBARRELBOT
//#! icon = gfx/terobjs/barrel
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 checks inventory
//and opens it, if it closed
function checkInventory()
{
	if(!jHaveWindow("Inventory"))
	{
		jToggleInventory();
		while(!jHaveWindow("Inventory"))
			jSleep(100);
	}
}

//like main() at C
function main()
{
	
	var RAD = 6;
	var well = jFindObjectByName("well", 10); //well
	var barrels = jGetObjects(RAD, jCoord(0, 0), "barrel"); //array of barrels
	jPrint("barrels = " + barrels.length);
	if(barrels[0] == 0)
		{
			jPrint("Cannot find barrels. Script failed.");
			return;
		}
	//if no wells around
	if(!well)
	{
		jPrint("Cannot find a well. Script failed.");
		return;
	}
	//well founded
	checkInventory();
	for(i=0;i<barrels.length;i++)
	{
	//if no barrels at array
	if(barrels[i] == 0) {
		jPrint("barrels[i] == 0");
		break;
	}
	while(1)
		{
			jPrint("WHILE WHILE");
			
				if (jGetWindow("Inventory").getInventories()[0].getItems("buckete")[0] == undefined){
	   if (jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0] == undefined){
		  jToConsole("No bucket in inventory. Script stopped");
		  jExit();
	   }
	   else{
		  jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0].iact();
		  jWaitPopup();
		  jSelectContextMenu("Empty");
		  while (jGetWindow("Inventory").getInventories()[0].getItems("buckete")[0] == undefined){
			 jSleep(100);
		  }
	   }
	}
			
			var bucket = jGetWindow("Inventory").getInventories()[0].getItems("buckete")[0];
			jPrint("WHILE 2");
			if(bucket == null) {
				jPrint("bucket == null");
				break;
			}
				jPrint("WHILE 3");
			var bc = bucket.coord();
			jPrint("bc = " + bc);
			bucket.take();
			jWaitDrag(5000);
			jSleep(100);
			tile = jPFMoveOffset_LX(well.position(),1);
			well.interactClick(0);
			var drag = jGetDraggingItem();
			//waits for the filled bucket
			while(drag.resName().indexOf("water") == -1)
				jSleep(100);
			jGetWindow("Inventory").getInventories()[0].drop(bc);
			jWaitDrop(5000);
			jSleep(100);
			tile = jPFMoveOffset_LX(barrels[i].position(),1);
			jDoClick(barrels[i].getID(), 3, 0);
			//waits for barrel window
			jWaitWindow("Barrel");
			jSleep(1000);
			if(jGetWindow("Barrel").getLabelText(1).indexOf("100.0") != -1) //barrel is full
			{
				//empty bucket
				var bucket2 = jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0];
				bucket2.iact();
				jWaitPopup(5000);
				jSelectContextMenu("Empty");
				while(bucket2.resName().indexOf("water") > -1)
					jSleep(100);
					tile = jPFMoveOffset_LX(well.position(),1);
				jDoClick(well, 1, 0);
				jSleep(700);
				break; //from while(1)
			}
			//if barrel isn't full
			var bucket2 = jGetWindow("Inventory").getInventories()[0].getItems("bucket-water")[0];
			var bc2 = bucket2.coord();
			bucket2.take();
			jWaitDrag(5000);
			tile = jPFMoveOffset_LX(barrels[i].position(),1);
			barrels[i].interactClick(0);
			var drag2 = jGetDraggingItem();
				jSleep(1000);
			jGetWindow("Inventory").getInventories()[0].drop(bc2);
			jWaitDrop(5000);
			jSleep(100);
			jAbsClick(barrels[i].position().add(tile.mul(11)), 1, 0);
		}//while 1
	}//for all barrels
}

//calls the main
jDropLastWindow();
main();

Code: Select all

//#! name =	Explorer-v2


include("jBotAPI");

function main(){
	while (1) {
		var herb = 0;
		while(herb == 0){
			if (jGetStamina() < 80) drinkWater();
			herb = jFindObjectByName("gfx/terobjs/herbs/edelweiss", 200);
			if(herb == 0)
			herb = jFindObjectByName("gfx/terobjs/herbs/glimmermoss", 200);
			if(herb == 0)
			herb = jFindObjectByName("gfx/terobjs/herbs/frogscrown", 200);
			if(herb == 0)
			herb = jFindObjectByName("gfx/terobjs/herbs/chimingbluebell", 200);
			if(herb == 0)
			herb = jFindObjectByName("gfx/terobjs/herbs/royaltoadstool", 200);
			if(herb == 0)
			herb = jFindObjectByName("gfx/terobjs/herbs/bloatedbolete", 200);	
			if(herb == 0)
			herb = jFindObjectByName("gfx/terobjs/herbs/blueberry", 200);
			
			
			
			if (herb != 0) {
				jPFMove(herb.position());
				jWaitStartMove();
				while (jIsMoving()) {
					jSleep(100);
				}
				jDoClick(herb.getID(),3,0);
				jSelectContextMenu("Pick")
				jWaitProgress();
			}
		}
	}
}

main();

Code: Select all

//#! tooltip = Aggroes enemies
//#! name = KillEmAll
//#! uniq = AGGROKILLEMALLBOT
//#! icon = paginae/pray/bread

//Requires Union 7.2b or higher

var enemy = false;
var globalBorkas = [];
var notifyUsers = ["Qant"]; //example: ["char1", "char2", ...]

function waitLoop() {
	while(1) {
		var borkas = jGetObjects(8, jCoord(11, 0), "/borka/");
		if(borkas.length > 0) {
			enemy = true;
			return;
		}
		jSleep(2000);
	}
}

function aggroBorkas() {
	var borkas = jGetObjects(8, jCoord(11, 0), "borka");
	for(var i = 0; i < borkas.length; i++) {
		if(globalBorkas.indexOf(borkas[i].getID()) != -1)
			continue; //this borka already aggroed
			jSendDoubleAction("atk", "pow");
			jWaitCursor("atk", 20000);
			jDoClick(borkas[i].getID(), 1, 0);
			jWaitCursor("arw", 20000);
			globalBorkas.push(borkas[i].getID());
			jSleep(100);
	}
}

function gotoHouse() {
	var door = jFindObjectByName("door2", 5);
	if(door != null) {
		jDoClick(door.getID(), 3, 0);
		while(jFindObjectByName("hearth-play", 3) == null)
			jSleep(300);
	}
}

function gotoStreet() {
	var door = jFindObjectByName("door2", 5);
	if(door != null) {
		jDoClick(door.getID(), 3, 0);
		while(jFindObjectByName("hearth-play", 3) != null)
			jSleep(300);
	}
}

function openPrivateChats() {
	for(var  i =0; i < notifyUsers.length; i++) {
		jPrivateChat(notifyUsers[i]);
		jSleep(100);
	}
	while(jGetChats().length < notifyUsers.length - 2)
		jSleep(500);
}

//IMPORTANT
//character may lost aggro if notify list too long
function privateSpam() {
	var chats = jGetChats();
	for(var i = 2; i < chats.length; i++) {
		chats[i].sendMessage("I'm aggroed someone. Please he#$#@*(%&(_ NO CARRIER");
		jSleep(3000);
	}
}

function main() {
	openPrivateChats();
	waitLoop();
	if(enemy) {
		while(1) {
			aggroBorkas();
			jSleep(100);
			gotoHouse();
			privateSpam();
			jSleep(2000);
			gotoStreet();
			jSleep(1000);
		}
	}
}

main();
User avatar
overtyped
Posts: 3906
Joined: Tue Sep 28, 2010 2:09 am
Location: Quaran book burning festival

Re: Union Client Scripts

Post by overtyped »

that curio script isnt functional, do you have one that is? or know how to make it work? From what i can tell, all that script does it pick herbs, if it see's it on the minimap, if not it will just script stops.
Early world exploit: Put your hearthfire inside a cave, then hold shift to position a claim right in front of a cave. After 8 hours the claim will be unbreakable. Since your hearthfire is inside the cave, you can still get back inside, and leave, but nobody will be able to enter, effectively making you unraidable for the first 3-7 days. Enjoy
naosnule
Posts: 394
Joined: Fri May 24, 2013 6:18 pm

Re: Union Client Scripts

Post by naosnule »

overtyped wrote:that curio script isnt functional, do you have one that is? or know how to make it work? From what i can tell, all that script does it pick herbs, if it see's it on the minimap, if not it will just script stops.

Overtyped, I didn't mean that they are the ultimate scripts that you just enable and never look back; the intention was to make it easier for people to program their own bots by providing more examples of how the functions are used.
User avatar
ramones
Posts: 3077
Joined: Fri Jul 09, 2010 10:03 pm
Location: I am a man who walks alone'

Re: Union Client Scripts

Post by ramones »

1. raise industry
2. sell good q stuff
3. earn curios
4. ignore curio botters :D
W16.1 - Pet Sematary (hermit)
W8 - Hermitage
W7 - Emerald City
W6 - Gomorrah
W5 - Pandemonium
W4 - Angkor
W3 - Angkor
User avatar
SuSavage
Posts: 51
Joined: Sun Jan 23, 2011 5:02 pm

Re: Union Client Scripts

Post by SuSavage »

A684 wrote:Hi all :) i have a new problem with farmer bot:
after separation barrels, Wine press, LC, and areas for harvest Harvest cursor appears, but there is no further nothing (without equipment bags for seeds).
If inventory is:
Image
what happens is this:
Image (I mowed it, bot departs at Vine Press)
Image
Have the same plroblem :(

Return to “The Wizards' Tower”