import java.awt.*;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.event.listeners.ServerMessageListener;
import com.speljohan.rsbot.event.events.ServerMessageEvent;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.script.wrappers.RSTile;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.accessors.*;
import com.speljohan.rsbot.accessors.Character;
import com.speljohan.rsbot.account.Account;
import java.awt.Graphics;
import com.speljohan.rsbot.event.listeners.PaintListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.lang.reflect.Array;
import java.applet.Applet;
import java.awt.Point;
public class HouseAlcher extends Script implements PaintListener {
public long startTime = System.currentTimeMillis();
public int alched = 0;
public int alchID = -1; //856
public int nature = 561;
public int housePortal = -1; //15479
public boolean canAlch = false;
public int startXP = 0;
public int currentXP = 0;
public double getVersion( ) {
return( 0.01 );
}
public String getName( ) {
return( "AutoAlcher[POH]" );
}
public String getAuthor( ) {
return( "Blood Argon" );
}
public String getScriptCategory() {
return( "Blood Argon" );
}
public String getScriptDescription( ) {
String html = "";
html += "<html>\n";
html += "<body>\n";
html += "<h2>" + getName( ) + " v" + getVersion( ) + "</h2><br>\n";
html += "Author: " + getAuthor( ) + "<br>\n";
html += "<br>\n";
html += "<center>\n";
html += "First Arg : ID of item to alch.\n";
html += "Second Arg : Outside your house portal, its ID\n";
html += "Example : 856,15479\n";
html += "Arguments:<input type=\"text\" name=\"args\">\n";
html += "</center>\n";
html += "</body>\n";
html += "</html\n";
return( html );
}
public boolean onStart(String[] args) {
Bot.getEventManager( ).addListener(PaintListener.class, this);
if(args.length < 1) {
log("You didnt fill in the proper arguments!");
return (false);
}
alchID = Integer.parseInt(args[0]);
housePortal = Integer.parseInt(args[1]);
log("alchID : "+alchID+" housePortal "+housePortal);
if (isLoggedIn())
{
startXP = skills.getCurrentSkillExp(STAT_MAGIC);
} else {
log("Please start logged in for proper XP counting.");
log("Now stopping script");
Bot.getEventManager( ).removeListener(PaintListener.class, this);
log("Paint listener removed");
wait(1000);
return(false);
}
return( true );
}
public void onFinish( ) {
Bot.getEventManager( ).removeListener(PaintListener.class, this);
}
public int loop( ) {
if (findObject(10, housePortal) != null) {
RSObject portal = findObject(10, housePortal);
if (atObject(portal, "Enter")) {
if(interfaceExists(232)) {
atInterface(232,3);
wait(random(1000,2000));
log("Entering house");
canAlch = true;
wait(random(7000,10000));
}
} else {
rotate();
}
} else {
//log("Didnt find the portal");
canAlch = true;
}
if (canAlch == true)
{
antiBan();
if (getCurrentTab() != TAB_MAGIC)
myOpenTab(TAB_MAGIC);
if(getMyPlayer().getAnimation() == -1) {
//castSpell(36);
if (!RSInterface.getInterface(13).isValid()) {
highAlch(36);
clickInventoryItem(alchID,true);
}
}
if (isLoggedIn())
{
if (getInventoryCount(nature) == 0) {
log("Out of natures");
stopAllScripts();
}
if (getInventoryCount(alchID) == 0) {
log("Out of alching item : "+alchID);
stopAllScripts();
}
}
}
return random(500,800);
} //Loop end
public void highAlch(int spell) {//Blood Argon
int x = 0;
int y = 0;
if (spell == 36) { //High Alch
x = 572;
y = 347;
}
if (spell == 14)
{
x = 716;
y = 251;
}
clickMouse(x + random(-5, 5), y + random(-5, 5), true);
}
public void rotate() {
int button = random(37,40);
Bot.getInputManager().pressKey((char) button);
wait(random(500, 1500));
Bot.getInputManager().releaseKey((char) button);
}
public int antiBan() {
switch(random(0, 800)) {
case 0: rotate(); break;
case 1: rotate(); break;
case 2: rotate(); break;
case 3: rotate(); break;
case 4: rotate(); break;
case 5: rotate(); break;
case 6: rotate(); break;
case 7: rotate(); break;
case 8: setRun(true); break;
case 9: rotate(); break;
case 10: moveMouse(random(0, 515), random(0, 337)); break;
case 11: moveMouse(random(0, 515), random(0, 337)); break;
case 12: moveMouse(random(0, 515), random(0, 337)); break;
case 13: moveMouse(random(0, 515), random(0, 337)); break;
case 14: moveMouse(random(0, 515), random(0, 337)); break;
case 15: moveMouse(random(0, 764), random(0, 502)); break;
case 16: moveMouse(random(0, 764), random(0, 502)); break;
case 17: moveMouse(random(0, 764), random(0, 502)); break;
case 18: openTab(TAB_INVENTORY); break;
case 19: openTab(TAB_INVENTORY); break;
case 20: openTab(TAB_STATS); break;
case 21: openTab(TAB_STATS); break;
case 23: openTab(random(0, 13)); break;
case 24: openTab(random(0, 13)); break;
case 25:
int X = getMyPlayer().getLocation().getX();
int Y = getMyPlayer().getLocation().getY();
int rX = random(-15,15);
int rY = random(-15,15);
int newX = X+rX;
int newY = Y+rY;
RSTile tilez2 = new RSTile(newX, newY);
walkTileMM(tilez2);
log("Initiate Walking");
break;
default: break;
}
return random(300, 500);
}
public void onRepaint( Graphics g ) {
if (isLoggedIn()) {
long millis = System.currentTimeMillis() - startTime;
long hours = millis / (1000 * 60 * 60);
millis -= hours * 1000 * 60 * 60;
long minutes = millis / (1000 * 60);
millis -= minutes * 1000 * 60;
long seconds = millis / 1000;
int x = 9;
int y = 188;
//interval of 12
int xp = 65;
int XPGain = 0;
XPGain = currentXP - startXP;
int countToNext = 0;
countToNext = skills.getXPToNextLevel(STAT_MAGIC) / xp + 1;
currentXP = skills.getCurrentSkillExp(STAT_MAGIC);
alched = XPGain / xp;
float expPerSec = 0;
if ((minutes > 0 || hours > 0 || seconds > 0) && XPGain > 0) {
expPerSec = ((float) XPGain)/(float)(seconds + (minutes*60) + (hours*60*60));
}
float expPerMin = expPerSec * 60;
float expPerHour = expPerMin * 60;
g.setColor(Color.blue);
g.drawString("==Alcher==", x, y);
g.setColor(Color.white);
g.drawString("Alched : "+alched, x, y+=12);
g.drawString("XP Gained "+XPGain, x, y+=12);
g.drawString("Alchs till Level : "+countToNext+".", x, y+=12);
g.drawString("Exp Per Hour: " + (int)expPerHour, x, y+=12);
g.drawString("Alchs Per Hour: " + ((int)expPerHour/xp), x, y+=12);
g.drawString("Currently level " + skills.getCurrentSkillLevel(STAT_MAGIC) + " and " + skills.getPercentToNextLevel(STAT_MAGIC) + "% to next level", x, y+=12);
g.drawString("Runtime: " + hours + " hours " + minutes + " minutes " + seconds + " seconds.", x, y+=12);
}
}
public void myOpenTab(int tab) { // Credit goes to nebule for this!
if (tab == getCurrentTab()) {
return;
}
switch(tab) {
case TAB_ATTACK: input.holdKey((char) KeyEvent.VK_F1, random(300, 700)); break;
case TAB_STATS: input.holdKey((char) KeyEvent.VK_F2, random(300, 700)); break;
case TAB_QUESTS: input.holdKey((char) KeyEvent.VK_F3, random(300, 700)); break;
case TAB_INVENTORY: input.holdKey((char) KeyEvent.VK_F4, random(300, 700)); break;
case TAB_EQUIPMENT: input.holdKey((char) KeyEvent.VK_F5, random(300, 700)); break;
case TAB_PRAYER: input.holdKey((char) KeyEvent.VK_F6, random(300, 700)); break;
case TAB_MAGIC: input.holdKey((char) KeyEvent.VK_F7, random(300, 700)); break;
case TAB_FRIENDS: input.holdKey((char) KeyEvent.VK_F8, random(300, 700)); break;
default: openTab(tab); break;
}
}
public boolean clickInventoryItem(int itemID, boolean click) {
if (getCurrentTab() != TAB_INVENTORY
&& !RSInterface.getInterface(INTERFACE_BANK).isValid()
&& !RSInterface.getInterface(INTERFACE_STORE).isValid()) {
openTab(TAB_INVENTORY);
}
int[] items = getInventoryArray();
java.util.List<Integer> possible = new ArrayList<Integer>();
for (int i = 0; i < items.length; i++) {
if (items[i] == itemID) {
possible.add(i);
}
}
if (possible.size() == 0) return false;
int idx = possible.get(random(0, possible.size()));
Point t = getInventoryItemPoint(idx);
clickMouse(t, 5, 5, click);
return true;
}
}