Jump to content

How can i accurately gage "Items collected"?


Guest Apogee

Recommended Posts

Guest Apogee

When picking this item up, there's no game message. So therefor, i can't use onMessage. (I feel this is the most reliable way of adding info to paint.)

 

When i pick the item up, the script sometimes miss clicks and adds +1 to int "looted" anyways. 

 

					supersecretitem.interact("Take");
					looted++;

This is what i have now. 

So my question to you is: What is a way that i can accurately detect when this item is picked up?

 

I thought about getting the current count in the inventory then when it enters the inventory it looted++'s but i couldn't figure it out.

Any help is appreciate. Looking to learn.

Link to comment
Share on other sites

Guest Apogee

get inventory count before and compare to after, if it is greater,  looted ++ or (difference between inventory count before and after).

 

Like i said, i tried this method. I ended up with like 5 ints and super confused. 

An example, if you have one, would be appreciated.

Link to comment
Share on other sites

this may work though i have not tested but it is something to work with.

long loot = 0;
long before = client.getInventory().getAmount("ITEM_NAME");
loot.interact("LOOT");
long after = client.getInventory().getAmount("ITEM_NAME");
		
		if(after > before) {
			loot += (after-before);
		}
Edited by precise
Link to comment
Share on other sites

Something like this would work I think

long amount = client.getInventory().getAmount("Item");
        item.interact("Take");
        sleep(500);
        while(myPlayer().isMoving()){
            sleep(50);
        }
        sleep(500);
        if(amount != client.getInventory().getAmount("Item")){
            itemsLooted++;
        }

Yeah basically the same as above...

Edited by Ande
Link to comment
Share on other sites

public ItemWatcher watcher = null;
public Thread wt = null;

public void onStart() {
  this.watcher = new ItemWatcher(this);
  this.wt = new Thread(this.watcher);
  this.wt.start();
}
public int onLoop() {
  System.out.println(this.watcher.getCollected());
  return 600;
}

public void onExit() {
  this.watcher.kill();
}
ItemWatcher.java

public class ItemWatcher implements Runnable {
  private Script s;
  private int start_item = 0;
  private int item_now = 0;
  private int collected_items = 0;
  private int item = 1337;

  private boolean run = true;
  public ItemWatcher(Script s) {
    this.s = s;
    this.start_item = s.client.getInventory().getAmount(item);
  }
  public void run() {
    while (run) {
      this.items_now = s.client.getInventory().getAmount(item);
      if (items_now > start_item) {
        this.collected_items += (items_now - start_item);
        this.start_item = items_now;
      }
      Thread.sleep(600);
    }
  }
  public void kill() {
    this.run = false;
  }
  public int getCollected() {
    return collected_items;
  }
}
ignore any typos, it was done in the osbot reply Edited by dreamliner
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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