Jump to content

Can't get this to compile


Recommended Posts

Posted

Someone had posted a warrior tokens script in Local, but I can't get it to compile. Code as follows:

 

 

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
import java.util.Random;
 
import org.osbot.rs07.api.Skills; 
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.NPCS;
 
import java.awt.*;
 
@ScriptManifest(author = "You", info = "My first script", name = "MegaWGuild", version = 0, logo = "")
public class MegaWGuild extends Script {
int randomHealth = random(30, 40);
public static int foodId = 385;
public static int helmId = 1159;
public static int bodyId = 1121;
public static int legsId = 1071;
public static int tokenId = 8851;
public static String goatName = "Animated Mithril Armour";
 
    @Override
    public void onStart() {
        log("Let's get started!");
    }
 
    @Override
    public int onLoop() throws InterruptedException {
     if ((this.inventory.contains(new int[] { foodId })) && (!myPlayer().isMoving())) {
    if (!myPlayer().isMoving())
       {
    NPC goat = (NPC)this.npcs.closest(new String[] {goatName});
    GroundItem helm = (GroundItem)this.groundItems.closest(new int[] {helmId });
    GroundItem body = (GroundItem)this.groundItems.closest(new int[] {bodyId });
    GroundItem legs = (GroundItem)this.groundItems.closest(new int[] {legsId });
    GroundItem token = (GroundItem)this.groundItems.closest(new int[] {tokenId });
    if (currentHealth() < randomHealth) {
              eat();
              sleep(random(300, 500));
             }
    else if ((goat != null) && (!goat.isUnderAttack())) {
    goat.interact(new String[] { "Attack" });
                 sleep(random(1000, 1500));
    }
    else if (body != null){ 
    takeGroundItem(bodyId);
    }
    else if (helm != null){ 
    takeGroundItem(helmId);
        }
    else if (legs != null){ 
    takeGroundItem(legsId);
        }
    else if (token != null){ 
    takeGroundItem(tokenId);
    sleep(random(100, 400));
        }
    else if ((helm == null) && (legs == null) && (body == null) && (token == null))  {
    Item use = this.inventory.getItem(new int[] {bodyId });
    use.interact(new String[] { "Use"});
    sleep(random(100, 500));
    RS2Object tile = this.objects.closest(new String[] { "Magical Animator" });
    tile.interact(new String[] { "Use"});
    sleep(random(2000, 3000));
    } 
    }
     }
      return random(200, 300);
    }
    
 
private void eat() {
Item food = this.inventory.getItem(new int[] {foodId });
food.interact(new String[] { "Eat" });
}
 
int currentHealth() {
int percperone = 100 / this.skills.getStatic(Skill.HITPOINTS);
return percperone * this.skills.getDynamic(Skill.HITPOINTS);
}      
 
private void takeGroundItem(int id)
    {
      try
      { 
        GroundItem horn = (GroundItem)this.groundItems.closest(new int[] { id });
        
        horn.interact(new String[] { "Take" });
        
        sleep(random(1200, 1500));
      }
      catch (Exception localException) {}
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my Warrior Guild script!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}
Posted (edited)

Hopefully this works but completely untested.

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
import java.util.Random;
 
import org.osbot.rs07.api.Skills; 
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.NPCS;
 
import java.awt.*;
 
@ScriptManifest(author = "You", info = "My first script", name = "MegaWGuild", version = 0, logo = "")
public class main extends Script {
int randomHealth = random(30, 40);
public static int foodId = 385;
public static int helmId = 1159;
public static int bodyId = 1121;
public static int legsId = 1071;
public static int tokenId = 8851;
public static String goatName = "Animated Mithril Armour";
 
    @Override
    public void onStart() {
        log("Let's get started!");
    }
 
    @Override
    public int onLoop() throws InterruptedException {
     if ((this.inventory.contains(new int[] { foodId })) && (!myPlayer().isMoving())) {
    if (!myPlayer().isMoving())
       {
    NPC goat = (NPC)this.npcs.closest(new String[] {goatName});
    GroundItem helm = (GroundItem)this.groundItems.closest(new int[] {helmId });
    GroundItem body = (GroundItem)this.groundItems.closest(new int[] {bodyId });
    GroundItem legs = (GroundItem)this.groundItems.closest(new int[] {legsId });
    GroundItem token = (GroundItem)this.groundItems.closest(new int[] {tokenId });
    if (currentHealth() < randomHealth) {
              eat();
              sleep(random(300, 500));
             }
    else if ((goat != null) && (!goat.isUnderAttack())) {
    goat.interact(new String[] { "Attack" });
                 sleep(random(1000, 1500));
    }
    else if (body != null){ 
    takeGroundItem(bodyId);
    }
    else if (helm != null){ 
    takeGroundItem(helmId);
        }
    else if (legs != null){ 
    takeGroundItem(legsId);
        }
    else if (token != null){ 
    takeGroundItem(tokenId);
    sleep(random(100, 400));
        }
    else if ((helm == null) && (legs == null) && (body == null) && (token == null))  {
    Item use = this.inventory.getItem(new int[] {bodyId });
    use.interact(new String[] { "Use"});
    sleep(random(100, 500));
    RS2Object tile = this.objects.closest(new String[] { "Magical Animator" });
    tile.interact(new String[] { "Use"});
    sleep(random(2000, 3000));
    } 
    }
     }
      return random(200, 300);
    }
    
 
private void eat() {
Item food = this.inventory.getItem(new int[] {foodId });
food.interact(new String[] { "Eat" });
}
 
int currentHealth() {
int percperone = 100 / this.skills.getStatic(Skill.HITPOINTS);
return percperone * this.skills.getDynamic(Skill.HITPOINTS);
}      
 
private void takeGroundItem(int id)
    {
      try
      { 
        GroundItem horn = (GroundItem)this.groundItems.closest(new int[] { id });
        
        horn.interact(new String[] { "Take" });
        
        sleep(random(1200, 1500));
      }
      catch (Exception localException) {}
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my Warrior Guild script!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

Download: http://uppit.com/jrz67pk733ba/OSBOT_Script.jar

 

I've compiled it for you. It looks kinda outdated through so I'd recommend you re-write it or something.

Edited by steve498

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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