Jump to content
H0rn

H0rns Dummy Attacker (Quick level 8 attack)

Recommended Posts

Pretty simple script, it picks a random dummy in the room to attack in varrock east, gets you 8 attack then stops.

 

Download: dummy.jar

 

Source:

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.event.WalkingEvent;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;

@ScriptManifest(name = "H0rns Dummy Attacker", author = "H0rn", version = 0.1, info = "", logo = "") 

public class Main extends Script {

	private long startTime, timeRan;
	Position[] dummySpot = {new Position(3254,3437,0), new Position(3251,3436,0), new Position(3251,3438,0)};
	
	Position chosenSpot;
    public static String currentStatus = "Starting";
    @Override

    public void onStart() {
    	 
    	this.startTime = System.currentTimeMillis();
		getExperienceTracker().start(Skill.ATTACK);
        log ("* Welcome to " + this.getName());
        
        chosenSpot = dummySpot[random(0,dummySpot.length-1)];
        log ("We chose spot"+chosenSpot);
        
    }

    @Override

    public void onExit() {

        log ("* Thanks for using "+ this.getName());
        log ("We gained "+getSkills().getExperienceTracker().getGainedXP(Skill.ATTACK)+" ("+getSkills().getExperienceTracker().getGainedLevels(Skill.ATTACK)+" Levels)");

    }
    
    @Override

    public int onLoop() throws InterruptedException {

    	if (!myPosition().equals(chosenSpot)) {
    		currentStatus = "Walking to dummy";
    		WalkingEvent walkEvent = new WalkingEvent(chosenSpot);
    		walkEvent.setMinDistanceThreshold(0);
    		walkEvent.setOperateCamera(true);
    		execute(walkEvent);
    	}
    	else if (getSkills().getStatic(Skill.ATTACK) < 8) {
    		attackDummy();
    	}
    	else if (getSkills().getStatic(Skill.ATTACK) >=8) {
    		log ("Attack level is 8.");
    		this.stop(false);
    	}
        return random(100,600);
    }

    @Override

    public void onPaint(Graphics2D g)
    {
    	this.timeRan = (System.currentTimeMillis() - this.startTime);
    	g.setFont(new Font("Sans-Serif", Font.BOLD, 10));
        g.setColor(Color.RED);
        g.drawRect(mouse.getPosition().x - 3, mouse.getPosition().y - 3, 6, 6);
        g.setColor(new Color(20,237,240,255));
        g.drawString(getName()+" v"+getVersion(), 10, 60);  
        g.setColor(Color.WHITE);
        g.drawString("Runtime: "+ft(this.timeRan), 10,75);
        g.drawString("Task: "+currentStatus,10,90);
        if (getSkills().getExperienceTracker().getGainedXP(Skill.ATTACK) >0) {
        	g.drawString("Attack Lvl: "+getSkills().getStatic(Skill.ATTACK) + " (+"+getSkills().getExperienceTracker().getGainedLevels(Skill.ATTACK)+")",10,105);
        	g.drawString("Attack XP: "+getSkills().getExperienceTracker().getGainedXP(Skill.ATTACK),10,120);
        }

    }
    public final String ft(final long ms){
	    long s = ms / 1000, m = s / 60, h = m / 60;
	    s %= 60; m %= 60; h %= 24;
	    return String.format("%02d:%02d:%02d", h, m, s);
	}
    
    private void attackDummy() throws InterruptedException {
    	RS2Object dummy = objects.closest("Dummy");
    	if (dummy != null && dummy.interact("Attack")) {
    		currentStatus = "Attacking dummy";
    		Sleep.sleepUntil(() -> !myPlayer().isAnimating(),3000);
    	}
    }
}

 

Edited by H0rn
Removed unused imports.
  • Like 1
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.

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...