Jump to content

Can't get this to compile


GetBackToOSRS

Recommended Posts

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) {
 
    }
 
}
Link to comment
Share on other sites

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