import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.util.Map;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Calculations;
import org.rsbot.script.Constants;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.wrappers.RSInterface;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import org.rsbot.event.events.ServerMessageEvent;
@ScriptManifest(authors = "Pyratepig", category = "Mining", name = "Pyratepig'sTinMiner", version = 1.0, description =
"Pyrate's TinMiner. Start in bank, minining area, with pickaxe wielded or in inventory.")
public class PyratePigTinMiner extends Script implements PaintListener{
public RSObject rock;
RSTile [ ] bankToRocks = {new RSTile (3168, 3425), new RSTile(3172, 3408), new RSTile(3173, 3394), new RSTile
(3177, 3381), new RSTile(3174, 3367) } ;
RSTile [ ] rocksToBank = {new RSTile (3177, 3369), new RSTile(3168, 3372), new RSTile(3162, 3382), new RSTile
(3164, 3398), new RSTile(3164, 3413), new RSTile(3173, 3426), new RSTile(3182, 3436) } ;
public int oreID = (11957);
public int pickaxeID [] = {1265, 1267, 1269, 1273, 1271, 1275} ;
RSObject tinrock;
RSTile bankTile = new RSTile(3182, 3436) ;
RSTile miningAreaTile = new RSTile(3177, 3369) ;
RSNPC banker;
int Tin = 11957;
int pickaxe=1265;
public long startTime = System.currentTimeMillis();
public int startexp;
public int tinPrice = 91;
public int exp;
public int expGained;
public int levelsGained;
public int energyToRunAt = random(25, 100);
public int bankerID = 6533;
private String status = "";
public boolean onStart( Map<String,String> args ) {
setCompass('n');
return true;
}
public void serverMessageRecieved(ServerMessageEvent e) {
if(e.getMessage().contains("You've just advanced a Mining level!")) {
levelsGained++;
}
}
private boolean openBank() {
RSNPC banker = getNearestNPCByID(5912);
if (banker != null) {
if (tileOnScreen(banker.getLocation())) {
wait(random(50,100));
turnToTile(banker.getLocation(), 15);
atNPC(banker, "Bank Banker");
}
}
return false;
}
public int Mine() {
if(getMyPlayer().getAnimation() == -1) {
RSObject Rock = getNearestObjectByID(11959);
if (Rock != null){
if(distanceTo(Rock.getLocation()) <= 3){
turnToTile(Rock.getLocation());
wait(random(300, 500));
}
if (distanceTo(Rock.getLocation()) >= 4) {
turnToTile(Rock.getLocation());
wait(random(300, 500));
}
if (distanceTo(Rock.getLocation()) > random(5,6)) {
walkTileMM(Rock.getLocation());
wait(random(200, 500));
}
if(tileOnScreen(Rock.getLocation())) {
setCompass('w');
setCameraAltitude(true);
atObject(Rock,"Mine Tin");
wait(random(300,500));
}
}
}
return 500;
}
public boolean walkToBank(){
if (distanceTo(bankTile) > 8) {
if (distanceTo(getDestination()) < random(5, 12)
|| distanceTo(getDestination()) > 100) {
if (!walkPathMM(rocksToBank)) {
walkToClosestTile(rocksToBank);
}
}
}
return true;
}
public boolean walkToRocks(){
if (distanceTo(miningAreaTile) > 20) {
if (distanceTo(getDestination()) < random(5, 12)
|| distanceTo(getDestination()) > 40) {
if (!walkPathMM(bankToRocks)) {
walkToClosestTile(bankToRocks);
}
}
}
return true;
}
private int antiBan(){
final int random = random(1,20);
switch (random) {
case 1:
if(random(1, 45) == 3){
moveMouseRandomly(300);
}
return random(100, 500);
case 2:
if(random(1, 50) == 19){
setCameraRotation(75);
}
return random(100, 500);
case 3:
if(random(1, 35) == 4){
openTab(Constants.TAB_STATS);
moveMouse(random(665, 395), random(709, 412));
}
return random(100, 500);
case 4:
if(random(1, 23) == 8){
moveMouseRandomly(600);
}
return random(100, 500);
case 5:
if(random(1, 29) == 6){
setCameraRotation(189);
}
return random(100, 500);
}
return 800;
}
public int loop() {
if(getEnergy() >= energyToRunAt){
setRun(true);
}
if(getMyPlayer().getAnimation() != -1){
setCameraAltitude(true);
status = "Mining...";
}
if(isInventoryFull()){
antiBan();
status = "Walking to bank..";
walkToBank();
if (RSInterface.getInterface(Constants.INTERFACE_BANK).isValid()) {
bank.depositAllExcept(pickaxeID);
} else {
openBank();
}
}else{
walkToRocks();
Mine();
}
return random(800, 1000);
}
public void onRepaint(Graphics g) {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (isLoggedIn()) {
if ( startexp == 0) {
startexp = skills.getCurrentSkillExp(Constants.STAT_MINING);
}
expGained = skills.getCurrentSkillExp(Constants.STAT_MINING) - startexp;
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;
long minutes2 = minutes + (hours * 60);
g.setColor(new Color(0, 0, 0, 140));
g.fillRect(549, 207, 186, 256);
g.setColor(new Color(47, 47, 89, 200));
g.setColor(Color.GREEN);
g.setFont(new Font("southpark", Font.PLAIN, 14));
g.drawString("Pyrate Tin Miner", 565, 237);
g.setFont(new Font("southpark", Font.PLAIN, 10));
g.drawString("Script by Pyratepig" , 578, 253);
g.drawString("Gained : " + levelsGained+" Level(s)" , 580, 272);
g.setFont(new Font("southpark", Font.PLAIN, 10));
g.drawString("Time running:"+hours+":"+minutes+":"+seconds+"." , 566, 309);
g.drawString("EXP Gained:"+expGained , 566, 349);
g.drawString("Tin Mined: "+ expGained / 175 + "Tin Mined" , 569, 443);
g.drawString("Status:"+ status , 566, 410);
g.setFont(new Font("southpark", Font.PLAIN, 10));
g.setColor(Color.RED);
g.fill3DRect(566, 386, 150, 11, true);
g.setColor(Color.GREEN);
g.fill3DRect(566, 386, skills.getPercentToNextLevel(Constants.STAT_MINING), 11, true);
g.setColor(Color.BLACK);
g.drawString(skills.getPercentToNextLevel(Constants.STAT_MINING) + "% to " +
(skills.getCurrentSkillLevel
(Constants.STAT_MINING) + 1), 586, 396);
}
}
}