Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by nade ( 17 years ago )
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.io.*;
import java.util.Scanner;
public class fight extends Script {
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
int fmode = 1;
int npcID = -1;
int pickUp = -1;
int sleepAt = 90;
int radius = Integer.MAX_VALUE;
int startX = -1;
int startY = -1;
int eatAt = -1;
int range = 25;
int foodID = 373;
long lastMoved = System.currentTimeMillis();
int oldX = -1;
int oldY = -1;
int newX = -1;
int newY = -1;
boolean walkBack = true;
int[] foodArray = {330, 333, 335, 332, 334, 336, 325, 326, 327, 328, 329, 750, 751, 357, 359, 367, 373, 370, 546};
int[] pickUps = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
int[] npcIDS = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
//int[] arrows = {11, 638, 640, 642, 644, 646, -1, -1, -1, -1, -1, -1, -1, -1, -1};
//int[] runesPick = {31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 46, 619, 10, 20};
public fight (Extension e) {
super(e);
}
public void init (String params) {
/* RLN has a wierd init/chooseScript system */
for ( int g = 1; g < npcIDS.length; g++ )
{
npcIDS[g] = -1;
pickUps[g] = -1;
}
String settingsFile = "fight.txt"; //Don't judge me nigga
try {
String name;
String value;
String line;
String[] tempIds;
File afSettings;
if (!params.equals("")) {
settingsFile = params.trim();
afSettings = new File(settingsFile);
} else {
afSettings = new File(settingsFile);
}
Scanner scanner = new Scanner(afSettings);
/* This really would be better with two functions but who cares */
while (scanner.hasNextLine())
{
line = scanner.nextLine();
Scanner sParser = new Scanner(line);
sParser.useDelimiter("=");
name = sParser.next();
value = sParser.next();
if (name.equalsIgnoreCase("npc"))
{
tempIds = value.trim().toLowerCase().split(",");
for (int a = 0; a < tempIds.length; a++)
{
npcIDS[a] = Integer.parseInt(tempIds[a]);
}
}
else if (name.equalsIgnoreCase("fMode"))
{
fmode = Integer.parseInt(value.trim());
}
else if (name.equalsIgnoreCase("pickup"))
{
tempIds = value.trim().toLowerCase().split(",");
for (int b = 0; b < tempIds.length; b++)
{
pickUps[b] = Integer.parseInt(tempIds[b]);
}
}
else if (name.equalsIgnoreCase("sleepAt"))
{
sleepAt = Integer.parseInt(value.trim());
}
else if (name.equalsIgnoreCase("eatAt"))
{
eatAt = Integer.parseInt(value.trim());
}
else if (name.equalsIgnoreCase("range"))
{
range = Integer.parseInt(value.trim());
}
}
} catch (Exception _ex) {
echo("Parameter Parsing Fail");
//System.out.println(_ex.getMessage());
stopScript();
} finally {
//sParser.close();
System.out.println("Loaded settings from: " + settingsFile);
startX = getX();
startY = getY();
printSettings();
}
}
public int main() {
boolean walkingBack = false;
if (getInventoryIndex(1263) == -1)
{
echo("This script requires a sleeping bag.");
echo("Stopping Script.");
stopScript();
} else {
//echo("Shrooms Autofight 2010");
}
if (startX == -1 && startY == -1)
{
startX = getX();
startY = getY();
}
newX = getX();
newY = getY();
checkIfBugged();
fightMode();
sleep();
/* Check if any shit was supplied and inventory not full*/
if (pickUps[0] != -1 && getInventoryCount() != 30)
{
/* See if monster dropped any items */
for(int l = 0; l < pickUps.length; l++)
{
int[] npcDrop = getItemById(pickUps[l]);
/* Is it under you? */
if (npcDrop[0] != -1 && distanceTo(npcDrop[1], npcDrop[2]) < 2)
{
/* Pick It Up */
pickupItem(npcDrop[0], npcDrop[1], npcDrop[2]);
return random(50, 80);
}
}
}
if(!inCombat()) {
eatFood();
/* No If NPC then wait */
if (trainOnNPC() == 1 && !walkingBack)
{
return random(100, 200);
}
/* If you walked outside range */
if(!isAtApproxCoords(startX, startY, range))
{
echo("Walked outside of range. Walking back now.");
walkTo(startX, startY);
return random(1000, 2000);
} else {
walkingBack = true;
}
oldX = getX();
oldY = getY();
}
return random(900, 980);
}
private final void printSettings()
{
Date date = new Date();
echo("Set script to the following settings: " );
System.out.print (" NPC IDS:\t(" );
System.out.print(npcIDS[0]);
for(int h = 1; h < npcIDS.length; h++)
{
if (npcIDS[h] != -1) {
System.out.print("," + npcIDS[h]);
}
}
System.out.print (")\n" );
System.out.println(" Fight Mode:\t" + fmode );
System.out.println(" Fight Radius:\t" + radius );
System.out.println(" Eat At:\t" + eatAt );
System.out.println(" Sleep At:\t" + sleepAt);
System.out.println(" Range:\t" + range );
System.out.print (" Pick Up:\t(" );
System.out.print(pickUps[0]);
for(int f = 1; f < pickUps.length; f++)
{
if (pickUps[f] != -1) {
System.out.print("," + pickUps[f]);
}
}
System.out.print (")\n\n\n" );
}
private final int trainOnNPC()
{
int closestNPC = -1;
int[] npc = null;
npc = getNpcById(npcIDS);
if(npc[0] > -1)
{
attackNpc(npc[0]);
return 0;
} else {
return 1;
}
}
private final void checkIfBugged()
{
if(System.currentTimeMillis() - lastMoved > 2 * 60 * 1000 && oldX == newX && oldY == newY)
{
int[] doorObj = getWallObjectById(2);
echo("(2) Min Idle: Looking for closed doors.");
if(doorObj[0] != -1)
{
atWallObject(doorObj[1], doorObj[2]);
lastMoved = System.currentTimeMillis();
echo("Resuming fight routine.");
} else {
echo("No Door Found. Wait(?).");
lastMoved = System.currentTimeMillis();
}
} else {
lastMoved = System.currentTimeMillis();
}
}
private final void echo(String output)
{
Date date = new Date();
System.out.println(" " + dateFormat.format(date) + ": " + output);
}
private final void fightMode()
{
if(getFightMode() != fmode)
{
setFightMode(fmode);
}
}
private final void sleep()
{
if(getFatigue() >= sleepAt && !inCombat())
{
echo("Reached fatigue threshold; nap time now.");
useSleepingBag();
}
}
private final void eatFood()
{
boolean found = false;
if(getCurrentLevel(3) <= eatAt)
{
for(int f = 0; f < foodArray.length; f++) {
echo(f + ":" + foodArray[f]);
if (getInventoryQuantity(foodArray[f]) > 0)
{
int fIndex = getInventoryIndex(foodArray[f]);
useItem(fIndex);
found = true;
}
}
if(!found)
{
echo("Nothing in your inventory matched with food array elements.");
echo("Stopping Script.");
stopScript();
}
}
}
}
Revise this Paste