Jump to content

Using certain slots help


Rumb

Recommended Posts

Hello everyone!

 

I am currently trying to create a mouse path that will go through your inventory and click the items but not just in the standard path, for example:

This is the normal path the bot might take to enchant these rings, he would go to the end of the line and start over at the new line

 

XCEFWlc.png

 

 

 

 

 

 

This is what I want the path the bot should take to be:

vHB45TH.png

This way the bot is more efficient and less "bot predictable"

 

 

 

Currently I was trying to get the slot and the next ring available, take that slot it is in and move the mouse over to click it but there seems to be no method for getting the mouse or the overall location of any item slots, how would I go about finding the location of the particular slot or even how to move the moues to the location of the slot?

Link to comment
Share on other sites

Hello everyone!

 

I am currently trying to create a mouse path that will go through your inventory and click the items but not just in the standard path, for example:

This is the normal path the bot might take to enchant these rings, he would go to the end of the line and start over at the new line

 

XCEFWlc.png

 

 

 

 

 

 

This is what I want the path the bot should take to be:

vHB45TH.png

This way the bot is more efficient and less "bot predictable"

 

 

 

Currently I was trying to get the slot and the next ring available, take that slot it is in and move the mouse over to click it but there seems to be no method for getting the mouse or the overall location of any item slots, how would I go about finding the location of the particular slot or even how to move the moues to the location of the slot?

 

Here is the code to click a certain slot in the inventory:

getMouse().click(getInventory().getMouseDestination(**slot number here**));

i would include sleeps etc.

 

if you want to click them in a certain order, make an array of the slot numbers in order of when they should be clicked and loop through it ^_^

 

hope this helped.

 

Precise

  • Like 2
Link to comment
Share on other sites

Here's what I use, you won't be able to copy/paste it in your project and use it, but it should be somewhat educational nevertheless.

 

de0c474448b809d8fb3ff1ec0047d428.gif

package org.bjornkrols.inventory_patterns;
import org.bjornkrols.imported.ArrayUtilities;
import org.bjornkrols.imported.KnuthShuffle;

/**
 * @author 		Bjorn Krols (Botre)
 * @version		0.1
 * @since		March 15, 2015
 */

public final class InventoryPattern {
	
	private InventoryPattern() {
		// This class should never be instantiated.
		// Do not delete or make accessible.
	}
	
	private static final byte ROWS = 7;
	private static final byte COLUMNS = 4;
	private static final byte SLOTS = ROWS * COLUMNS;
	
	public static final int[] REGULAR = buildRegularPattern();
	public static final int[] SNAKE = buildSnakePattern();
	public static final int[] REVERSED_REGULAR = reversePattern(REGULAR);
	public static final int[] REVERSED_SNAKE = reversePattern(SNAKE);
				
	public static int[] getRandomizedPattern() {
		int[] array = REGULAR;
		KnuthShuffle.shuffle(array);
		return array;
	}
	
	private static int[] buildRegularPattern() {
		int[] array = new int[SLOTS];
		for (int index = 0; index < array.length; index++) {
			array[index] = index;
		}
		return array;
	}
	
	private static int[] buildSnakePattern() {
		int[] array = new int[SLOTS];
		byte index = 0;
		byte value = - COLUMNS - 1;
		byte row = 0;
		while (row < ROWS) {
			if (row % 2 == 0) {
				value += COLUMNS + 1;
				for (int iterator = 0; iterator < COLUMNS; iterator++) {
					array[index++] = value++;
				}
			} 
			else {	
				value += COLUMNS - 1;
				for (int iterator = 0; iterator < COLUMNS; iterator++) {
					array[index++] = value--;
				}
			} 
			row++;
		}
		return array;
	}	
	
	private static int[] reversePattern(int[] array) {
		int[] copy = array;
		ArrayUtilities.reverse(copy);
		return copy;
	}

// REGULAR
//	00 01 02 03 
//	04 05 06 07
//	08 09 10 11
//	12 13 14 15
//	16 17 18 19
//	20 21 22 23
//      24 25 26 27

// SNAKE
//	00 01 02 03 
//	07 06 05 04
//	08 09 10 11
//	15 14 13 12
//	16 17 18 19
//	23 22 21 20
//	24 25 26 27
	
// M //TODO
//	06 07 20 21 
//	05 08 19 22
//	04 09 18 23
//	03 10 17 24
//	02 11 16 25
//	01 12 15 26
//	00 13 14 27
	
// W //TODO
//	00 13 14 27 
//	01 12 15 26
//	02 11 16 25
//	03 10 17 24
//	04 09 18 23
//	05 08 19 22
//	06 07 20 21
	
// REVERSED_REGULAR
//	27 26 25 24 
//	23 22 21 20 
//	19 18 17 16
//	15 14 13 12
//	11 10 09 08
//	07 06 05 04
//	03 02 01 00
	
// REVERSED_SNAKE
//	27 26 25 24 
//	20 21 22 23 
//	19 18 17 16
//	12 13 14 15
//	11 10 09 08
//	04 05 06 07
//	03 02 01 00
	
}
package org.bjornkrols.events;

import java.util.Arrays;

import org.bjornkrols.inventory_patterns.InventoryPattern;
import org.bjornkrols.script.ConditionalSleep;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;

/**
 * @author 		Bjorn Krols (Botre)
 * @version		0.6
 * @since		March 17, 2015
 */

public abstract class DropAllEvent extends BotreEvent {
	
	private int[] pattern = InventoryPattern.REVERSED_SNAKE;
	private int iterator;
	
	public DropAllEvent(Script script) {
		super(script);
		setTimeout(60);
	}
	
	public abstract String[] itemsToDrop(); 
	
	@Override
	public int onLoop() {
		Item item = script.getInventory().getItemInSlot(pattern[iterator]);
		if (item != null && Arrays.asList(itemsToDrop()).contains(item.getName()) && script.getInventory().interact(pattern[iterator], "Drop")) {
			new ConditionalSleep(100, 2000) {
				@Override
				public boolean condition() {
					Item item = script.getInventory().getItemInSlot(pattern[iterator]);
					return item != null;
				}
			};
		}
		iterator++;
		return MethodProvider.random.nextInt(75) + 75;
	}
	
	@Override
	public void postLoop() {
		// Reset iterator.
		iterator = 0;
		super.postLoop();
	}

	@Override
	public boolean isFinished() {
		return iterator >= pattern.length;
	}

}
Edited by Botre
  • Like 2
Link to comment
Share on other sites

Here is the code to click a certain slot in the inventory:

getMouse().click(getInventory().getMouseDestination(**slot number here**));

i would include sleeps etc.

 

if you want to click them in a certain order, make an array of the slot numbers in order of when they should be clicked and loop through it happy.png

 

hope this helped.

 

Precise

Seems to be what I am looking for, in the **slot number here** location would I do getInventory.getSlot(x) because just sticking the number in there would obviously do nothing xD

Link to comment
Share on other sites

sticky a number would do something tongue.png the parameter is an int which is the slot number smile.png and yes that would work too

	private int[] slotArray = {1,2,3,7,6,5,4,8,9,10,11,15,14,13,12,16,17,18,19,23,22,21,20,24,25,26,27};
	private int arrayNumber = 0;

public void clickRing() throws InterruptedException {
		int x = slotArray[arrayNumber];
		getMouse().move(getInventory().getMouseDestination(getInventory().getSlot(x)));
		arrayNumber++;
}

This snippet are the basics of the clicking yet the mouse doesnt move when it is getMouse().move or even more and click in getMouse().click, the code does reach clickRing() as tested by some log() commands and the slotArray does advance though every loop, it just doesnt move or find the slot

Link to comment
Share on other sites

	private int[] slotArray = {1,2,3,7,6,5,4,8,9,10,11,15,14,13,12,16,17,18,19,23,22,21,20,24,25,26,27};
	private int arrayNumber = 0;

public void clickRing() throws InterruptedException {
		int x = slotArray[arrayNumber];
		getMouse().move(getInventory().getMouseDestination(getInventory().getSlot(x)));
		arrayNumber++;
}

This snippet are the basics of the clicking yet the mouse doesnt move when it is getMouse().move or even more and click in getMouse().click, the code does reach clickRing() as tested by some log() commands and the slotArray does advance though every loop, it just doesnt move or find the slot

 

 

you should look how to use for loops happy.png

 

here:

private int[] slotArray = {1,2,3,7,6,5,4,8,9,10,11,15,14,13,12,16,17,18,19,23,22,21,20,24,25,26,27};

	public void clickAllRing() throws InterruptedException {
		for(int i : slotArray) {
			getMouse().click(getInventory().getMouseDestination(i));
                        //add sleep here
                }
	}

you might want to change the order of the ints in the slotArray because they current will not obey your order of clicking.

 

Precise

Edited by Precise
Link to comment
Share on other sites

you should look how to use for loops happy.png

 

here:

private int[] slotArray = {1,2,3,7,6,5,4,8,9,10,11,15,14,13,12,16,17,18,19,23,22,21,20,24,25,26,27};

	public void clickAllRing() throws InterruptedException {
		for(int i : slotArray) {
			getMouse().click(getInventory().getMouseDestination(i));
                        //add sleep here
                }
	}

you might want to change the order of the ints in the slotArray because they current will not obey your order of clicking.

 

Precise

I can't just use a for loop like that, I have to click the enchant sapphire button every time so just going though and clicking all of them won't enchant all of them, also what do you mean change the order of the ints in the slotArray, why won't they obey and what should I try to change it too for them to obey?

Link to comment
Share on other sites

You could use a for loop like this:

package org.bjornkrols.script;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.ui.Spells.NormalSpells;
import org.osbot.rs07.script.Script;

public class EnchantExample extends Script {

	private int[] pattern = new int[] {27, 26, 25, 24, 20, 21, 22, 23, 19, 18, 17, 16, 12, 13, 14, 15, 11, 10, 9, 8, 4, 5, 6, 7, 3, 2, 1, 0};
	
	@Override
	public int onLoop() throws InterruptedException {
		for (int i = 0; i < pattern.length; i++) {
			Item item = getInventory().getItemInSlot(pattern[i]);
			if(item.getName().equals("Sapphire ring")) {
				if(getMagic().castSpell(NormalSpells.LVL_1_ENCHANT)) {
					item.interact("Enchant");
				}
			}
		}
		return 133 + 7;
	}

}
Edited by Botre
Link to comment
Share on other sites

So I had to completely restart my script because it was getting reallly out of had, I started to use your guy's code because I figured with a clean slate I should try to solve it before it gets out of hand again, it kinda work but for some reason it clicks on the inventory first before anything, any idea's why?

8552481c6d2ec83c6ef14b20be1a3da0.gif

package SapphireEnchanter;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.ui.Spells.NormalSpells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Rumble", info = "Sapphire Enchanter", logo = "", name = "SapphireEnchanter", version = 1.01)
public class SapphireEnchanter extends Script {

	private int[] pattern = new int[] {27, 26, 25, 24, 20, 21, 22, 23, 19, 18, 17, 16, 12, 13, 14, 15, 11, 10, 9, 8, 4, 5, 6, 7, 3, 2, 1, 0};
	
	@Override
	public int onLoop() throws InterruptedException {
		for (int i = 0; i < pattern.length; i++) {
			Item item = getInventory().getItemInSlot(pattern[i]);
			if(item.getName().equals("Sapphire ring")) {
				if(getMagic().castSpell(NormalSpells.LVL_1_ENCHANT)) {
					sleep(random(400,500));
					mouse.click(getInventory().getMouseDestination(pattern[i]), false);
				}
			}
		}
		return 133 + 7;
	}

}
Link to comment
Share on other sites

I'm newer to osbot scripting but i had one of the fastest magic scripts on rsbot. The only thing I cant grasp is osbot works off seeing the inventory so when you can for the action it isn't open because the screen doesn't update as fast as the script processes I can give two suggestions first try to add a wait til the inventory is open or visible on the screen to cast on the ring, if that doesn't work add a cached inventory system by storing it all into a array and pulling from it as needed.

Link to comment
Share on other sites

Ok I figured out the problem,

moveDest = getInventory().getMouseDestination(pattern[i]);

when it uses this it looks for the item in the inventory, since it can't see it it ties to open the inventory, what I want is to have it so that it will automatically go to the location whether it can see it or not so I am not waiting for the inventory to pop up and I can just go there while it it popping up, any solutions to this?

Link to comment
Share on other sites

Ok I figured out the problem,

moveDest = getInventory().getMouseDestination(pattern[i]);

when it uses this it looks for the item in the inventory, since it can't see it it ties to open the inventory, what I want is to have it so that it will automatically go to the location whether it can see it or not so I am not waiting for the inventory to pop up and I can just go there while it it popping up, any solutions to this?

 

Sleep after you cast the spell. So the script has enough time to process which tab is open.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...