Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.model.NPC;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import java.awt.*;
- import java.util.concurrent.TimeUnit;
- @ScriptManifest(name = "NPC_Beggar", author = "Aibanker", version = 1.0, info = "Begs for GP", logo = "http://i.imgur.com/04lPr43.png")
- public class NPC_Beggar extends Script {
- Area loot = new Area(2963, 3209, 2970, 3217).setPlane(1);
- private long timeBegan;
- private long timeRan;
- private long CoinsCollected;
- private long prevInvCount;
- private long coinshour;
- @Override
- public void onStart() {
- this.log("Starting script");
- this.timeBegan = System.currentTimeMillis();
- }
- private String ft(long duration) {
- String res = "";
- long days = TimeUnit.MILLISECONDS.toDays(duration);
- long hours = TimeUnit.MILLISECONDS.toHours(duration)
- - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
- long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
- long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
- if (days == 0) {
- res = (hours + ":" + minutes + ":" + seconds);
- } else {
- res = (days + ":" + hours + ":" + minutes + ":" + seconds);
- }
- return res;
- }
- private enum State {
- walk, talk, wait;
- };
- private State getState() {
- NPC anja = this.getNpcs().closest("Anja");
- if (!loot.contains(myPlayer()))
- return State.walk;
- if (anja != null)
- return State.talk;
- return State.wait;
- }
- @Override
- public void onExit() {
- }
- @Override
- public int onLoop() throws InterruptedException {
- long invCount = getInventory().getAmount("Coins");
- if (invCount > prevInvCount)
- CoinsCollected += (invCount - prevInvCount);
- prevInvCount = invCount;
- switch (getState()) {
- case walk:
- if (!this.loot.contains(myPlayer()))
- this.log("You are not at the looting area");
- this.getWalking().webWalk(loot);
- this.log("Walking to looting area");
- break;
- case talk:
- NPC anja = this.getNpcs().closest("Anja");
- if (this.loot.contains(myPlayer()) && anja != null)
- if (!this.getDialogues().inDialogue()) {
- this.log("Talking to npc");
- anja.interact("Talk-to");
- new ConditionalSleep(2000) {
- @Override
- public boolean condition() throws InterruptedException {
- return getDialogues().inDialogue();
- }
- }.sleep();
- }
- if (getDialogues().inDialogue())
- getDialogues().completeDialogue("I was hoping");
- break;
- case wait:
- break;
- }
- return 700;
- }
- @Override
- public void onPaint(Graphics2D g) {
- Point mP = getMouse().getPosition();
- g.drawLine(mP.x - 5, mP.y + 5, mP.x + 5, mP.y - 5);
- g.drawLine(mP.x + 5, mP.y + 5, mP.x - 5, mP.y - 5);
- Font font = new Font("Comic Sans", Font.PLAIN, 13);
- g.setFont(font);
- g.setFont(g.getFont().deriveFont(13.0f));
- timeRan = System.currentTimeMillis() - this.timeBegan;
- g.drawString(ft(timeRan), 150, 50);
- g.drawString(String.valueOf(CoinsCollected), 150, 70);
- g.drawString(String.valueOf(coinshour), 150, 90);
- coinshour = (int) (CoinsCollected / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
- g.drawString("Time:", 15, 50);
- g.drawString("Coins", 15, 70);
- g.drawString("Coins/hr", 15, 90);
- g.drawString("Status", 15, 110);
- g.drawString(this.getState().toString(), 150, 110);
- g.setColor(Color.decode("#FFFFFF"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement