Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gmc.actions;
- import com.gmc.*;
- import org.osbot.script.rs2.def.*;
- import org.osbot.script.rs2.model.*;
- import org.osbot.script.rs2.ui.Option;
- import org.osbot.script.mouse.*;
- import java.awt.*;
- public class UseItemOnObject implements Action {
- int dataNum[] = new int[8];
- String dataWord[] = new String[8];
- public UseItemOnObject(int dataNum[], String dataWord[]) {
- this.dataNum = dataNum;
- this.dataWord = dataWord;
- }
- @Override
- public String getBuildText() {
- return "Use " + new Item(dataNum[0], 1).getDefinition().getName() + "(" + dataNum[0] + ") on " + ObjectDefinition.forId(dataNum[1]).getName() + "(" + dataNum[1] + ")";
- }
- @Override
- public void executeAction(SuperScript script) throws InterruptedException {
- boolean returns = false;
- RS2Object obj = script.closestObject(dataNum[1]);
- String action = "Use <col=ff9040>" + new Item(dataNum[0], 1).getDefinition().getName() +"<col=ffffff> -> <col=ffff>" + ObjectDefinition.forId(dataNum[1]).getName();
- if(obj != null) {
- script.client.getInventory().interactWithId(dataNum[0], "Use");
- script.sleep(200);
- script.client.moveMouse(obj.getMouseDestination(), true);
- script.sleep(50);
- script.client.clickMouse(true);
- script.sleep(50);
- int i = -1;
- for (int index = 0; index < script.client.getMenuCount(); index++) {
- String indexaction = ((Option)script.client.getMenu().get(index)).action + " " + ((Option)script.client.getMenu().get(index)).noun;
- if (indexaction.equals(action)) {
- i = index;
- break;
- }
- }
- if (i == -1) {
- returns = false;
- }
- Point menu = new Point(script.client.getMenuX(), script.client.getMenuY());
- int xOff = script.random(4, 95);
- int yOff = 21 + 16 * i + 3;
- RectangleDestination rectangle_destination = new RectangleDestination(new Rectangle(menu.x, menu.y + yOff, xOff, 8));
- script.client.moveMouse(rectangle_destination, true);
- if (script.client.isMenuOpen()) {
- script.client.clickMouse(false);
- script.sleep(25);
- returns = true;
- }
- returns = false;
- } else {
- script.sleep(2000);
- script.log("Cannot find object - " + dataNum[1] + "!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement