Jump to content

Animated Armour (Warriors Guild)


RickyD

Recommended Posts

Hello

Made a little script for farming the tokens at the warriors guild for getting my dragon defender.  

It's currently hardcoded to lobster and mithril armour but you can edit source...:)

Setup:

  • Have lobster in inventory
  • Have mithril platelegs, body and full helm in inventory

Jar file here

import org.osbot.rs07.api.model.GroundItem;
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 javax.swing.*;
import java.awt.*;

@ScriptManifest(name = "Animator by RickyD", author = "RickyD", version = 1.0, info = "Animates your armour to farm warrior guild tokens", logo = "")

public class Animated extends Script {

    String[] foodName = {"Lobster"};
    NPC anim;
    GroundItem lootables;
    String [] lootNames = {"Mithril platebody", "Warrior guild token", "Mithril full helm", "Mithril platelegs"};

    @Override

    public void onStart() {}


    @Override

    public void onExit() {}

    public boolean hasArmour(){
        if(getInventory().contains("Mithril platebody")){
            if(getInventory().contains("Mithril platelegs")){
                if(getInventory().contains("Mithril full helm")){
                    return true;
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }else{
            return false;
        }
    }


    @Override

    public int onLoop() throws InterruptedException{

        anim = getNpcs().closest(2454);
        lootables = getGroundItems().closest(lootNames);

        if(getInventory().contains(foodName) && getInventory().getAmount("Warrior guild token") < 1000){
            if(anim != null && anim.isInteracting(myPlayer())){
                if(myPlayer().getHealthPercent() < 50){

                    getInventory().interact("Eat", foodName);
                    //DTiming.waitCondition(() -> myPlayer().getAnimation() == 829, 2000);
                    new ConditionalSleep(2000){
                        @ Override
                        public boolean condition() throws InterruptedException
                        {
                            return myPlayer().getAnimation() == 829;
                        }
                    }.sleep();
                }else{
                    if(myPlayer().getInteracting() == null){
                        anim.interact("Attack");
                    }
                }
            }else{
                if(lootables != null){
                    lootables.interact("Take");
                }else{
                    if(hasArmour()){
                        getObjects().closest("Magical Animator").interact("Animate armour");
                    }
                }
            }
        }else{
            JOptionPane.showMessageDialog(null,
                    "NO FOOD or 1k Tokens",
                    "Alert",
                    JOptionPane.WARNING_MESSAGE);

            stop(false);
        }


        return 100; //The amount of time in milliseconds before the loop starts over

    }

    @Override

    public void onPaint(Graphics2D g) {}

}

 

Edited by RickyD
  • Like 1
Link to comment
Share on other sites

good stuff.

just in case you didn't know, you don't need so many if statements

    public boolean hasArmour(){
        if(getInventory().contains("Mithril platebody")){
            if(getInventory().contains("Mithril platelegs")){
                if(getInventory().contains("Mithril full helm")){
                    return true;
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }else{
            return false;
        }
    }
    public boolean hasArmour(){
        if(getInventory().contains("Mithril platebody") && getInventory().contains("Mithril platelegs") && getInventory().contains("Mithril full helm"))
            return true;
    }

the client sees these as the same

Link to comment
Share on other sites

  • 2 weeks later...
On 8/30/2017 at 11:59 PM, superuser said:

good stuff.

just in case you didn't know, you don't need so many if statements


    public boolean hasArmour(){
        if(getInventory().contains("Mithril platebody")){
            if(getInventory().contains("Mithril platelegs")){
                if(getInventory().contains("Mithril full helm")){
                    return true;
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }else{
            return false;
        }
    }

    public boolean hasArmour(){
        if(getInventory().contains("Mithril platebody") && getInventory().contains("Mithril platelegs") && getInventory().contains("Mithril full helm"))
            return true;
    }

the client sees these as the same

Also redundant code, though. It comes down to preference really. Thanks for contribution, OP.

public boolean hasArmour() {
	return getInventory().contains("x");
	}
Edited by Pseudo
Link to comment
Share on other sites

  • 3 weeks later...

You shouldn't have return 100; at the end. That's a really low return time (1/10th of a second) that speed will get you banned quickly. You should do return random(400, 700); Or something similar, but those return times have always worked for me. It's good to see you're learning though. Good luck :)

Edited by TTScripts
Link to comment
Share on other sites

8 hours ago, TTScripts said:

You shouldn't have return 100; at the end. That's a really low return time (1/10th of a second) that speed will get you banned quickly. You should do return random(400, 700); Or something similar, but those return times have always worked for me. It's good to see you're learning though. Good luck :)

so what part would you change? or do

Link to comment
Share on other sites

On 10/1/2017 at 9:29 PM, iroll said:

so what part would you change? or do

import org.osbot.rs07.api.model.GroundItem;
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 javax.swing.*;
import java.awt.*;

@ScriptManifest(name = "Animator by RickyD", author = "RickyD", version = 1.0, info = "Animates your armour to farm warrior guild tokens", logo = "")

public class Animated extends Script {

    String[] foodName = {"Lobster"};
    NPC anim;
    GroundItem lootables;
  	private String armorType = "Mithril"
    String[] lootNames;

    @Override

    public void onStart() {
    startTime = System.currentTimeMillis();
      lootNames = {armortType & "platebody", "Warrior guild token", armorType & " full helm", armorType & " platelegs"};
    }


    @Override

    public void onExit() {
    log("Script has exited successfully");
    }
  	private long startTime;

    public boolean hasArmour(){
        if(getInventory().contains(armorType & " platebody") && getInventory().contains(armortType & " platelegs") && getInventory().contains(armorType & " full helm")){
              return true;
        }
        return false;
    }


    @Override

    public int onLoop() throws InterruptedException{

        anim = getNpcs().closest(2454);//you should change this to a static method that gets the animated armor npc id
      //maybe anim = getNpcs().closest("Animated " & armorType & " armour");
      //or something like that
        lootables = getGroundItems().closest(lootNames);

        if(getInventory().contains(foodName) && getInventory().getAmount("Warrior guild token") < 1000){
            if(anim != null && anim.isInteracting(myPlayer())){
                if(myPlayer().getHealthPercent() < 50){

                    getInventory().interact("Eat", foodName);
                    //DTiming.waitCondition(() -> myPlayer().getAnimation() == 829, 2000);
                    new ConditionalSleep(2000){
                        @ Override
                        public boolean condition() throws InterruptedException
                        {
                            return myPlayer().getAnimation() == 829;
                        }
                    }.sleep();
                  sleep(random(400, 650);
                }else{
                    if(myPlayer().getInteracting() == null){
                        anim.interact("Attack");
                      sleep(random(800, 1100);
                    }
                }
            }else{
                if(lootables != null){
                    if (lootables.interact("Take")) {
                 		 sleep(random(1200, 1500);
                    }
                }else{
                    if(hasArmour()){
                        if (getObjects().closest("Magical Animator").interact("Animate armour")) {
                      		sleep(random(1200, 2000);
                        }
                    }
                }
            }
        }else{
                      stop(false);
            JOptionPane.showMessageDialog(null,
                    "NO FOOD or 1k Tokens",
                    "Alert",
                    JOptionPane.WARNING_MESSAGE);

        }


        return random(400, 700); //The amount of time in milliseconds before the loop starts over

    }

    @Override

    public void onPaint(Graphics2D g) {
      long millis = System.currentTimeMillis() - startTime;
      		String timeStr = String.format("%02d min, %02d sec", 
				TimeUnit.MILLISECONDS.toMinutes(millis),
				TimeUnit.MILLISECONDS.toSeconds(millis) - 
				TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))
				);
      
    	g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14);
                  g.setColor(Color.WHITE);
                  g.drawString("Time running: " + timeStr, 10, 250);
    }

}
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.
Note: Your post will require moderator approval before it will be visible.

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