Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Main;
- import org.osbot.rs07.api.filter.Filter;
- import org.osbot.rs07.api.model.*;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import java.util.concurrent.TimeUnit;
- import java.awt.*;
- @ScriptManifest(name = "Guard Killer", author = "Joey", version = 1, info = "", logo = "")
- public class Main extends Script {
- private long timeBegan;
- private long timeRan;
- private State state;
- private enum State{
- ATTACK_GUARD
- }
- private State getState() {
- return state.ATTACK_GUARD;
- }
- @Override
- public void onStart() {
- timeBegan = System.currentTimeMillis();
- }
- public void onPaint(Graphics2D g) {
- Graphics2D gr = g;
- timeRan = System.currentTimeMillis() - this.timeBegan;
- g.drawString(ft(timeRan), 150, 50);
- g.drawString("Time:", 10, 50);
- }
- 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;
- }
- @Override
- public int onLoop() throws InterruptedException {
- state = getState();
- switch(state) {
- case ATTACK_GUARD:
- NPC guard = getNpcs().closest(new Filter<NPC>() {
- @Override
- public boolean match(NPC npc) {
- return npc != null && npc.getName().equals("Guard") && getMap().canReach(npc) && !npc.isUnderAttack() && npc.getHealthPercent() >0;
- }
- });
- if (guard!=null && !getCombat().isFighting() && !guard.isUnderAttack() && !myPlayer().isUnderAttack() && !guard.isHitBarVisible()) {
- guard.interact("Attack");
- new ConditionalSleep(2000) {
- @Override
- public boolean condition() throws InterruptedException {
- return myPlayer().isUnderAttack();
- }
- }.sleep();
- }
- break;
- }
- return random(300,800);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement