Hi guys, I made this little script today that collects tokens for the defenders at warrior guild by summoning an Animated Armour. Its very very basic, probably extremely poor written as I have very little experience with java but hey, it works. In the current settings it eats lobster and uses mithril armour tho by changing the ints in the code you can change it to whatever you like. It does not bank, so you'll have to get some food yourself every now and then. Don't expect any fancy, no paint, no updates, I was just too lazy to collect the tokens myself and thought it would be nice to share it with you guys:)
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 = 379;
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) {
}
}