Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.GiantSpiderFighter;
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSModel;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "jdezzy" }, category = "Combat", name = "FlawLess Spiderkiller")
- public class GiantSpiders extends Script implements Painting{
- //Values
- public int xphour;
- public int Entrance_ID = 11798;
- public int bankTrips = 0;
- public int startLevel;
- public int startXP;
- public long TimeRan;
- public long start;
- public long end;
- public String FOOD = "Lobster";
- //Values
- //Tiles && Paths
- public RSTile[] BarbVillage = {rt(3089, 3418), rt(3080, 3416), rt(3084, 3418), rt(3081, 3418), rt(3082, 3424), rt(3085, 3424), rt(3083, 3426), rt(3078, 3424), rt(3079, 3422)};
- public RSTile[] Spiders = {rt(2132, 5263), rt(2130, 5267), rt(2128, 5269), rt(2126, 5269), rt(2124, 5269), rt(2125, 5272), rt(2123, 5272), rt(2121, 5274), rt(2120, 5273), rt(2125, 5274), rt(2127, 5273), rt(2129, 5273), rt(2129, 5270)};
- public RSTile[] Floor2 = {rt(2042, 5245), rt(2042, 5244), rt(2042, 5243), rt(2041, 5243), rt(2041, 5241)};
- public RSTile[] Floor3 = {rt(2123 , 5252), rt(2124, 5254), rt(2122, 5254), rt(5129, 5254) };
- public RSTile[] PrizeRoom = {rt(1914, 5222), rt(1912, 5221) , rt(1909, 5222), rt(1907, 5224), rt(1904, 5221), rt(1902, 5220), rt(1902, 5224), rt(2021, 5223), rt(2021, 5220), rt(2019, 5220), rt(2022, 5218), rt(2020, 5220), rt(2024, 5217), rt(2027, 5217), rt(2026, 5215), rt(2025, 5215) };
- public RSTile Stronghold[] = {rt(1859, 5243) ,rt(1862, 5242)};
- public RSTile Varrock[] = {rt(3210, 3424), rt(3213, 3424), rt(3218, 3424)};
- //Tiles && Paths
- public boolean botIsRunning = true;
- @Override
- public void run() {
- startLevel = Skills.getXP(SKILLS.STRENGTH);
- startXP = Skills.getXP(SKILLS.STRENGTH);
- start = System.currentTimeMillis();
- //paint values
- if(botIsRunning)
- GetStartingAction();
- }
- private void GetStartingAction() {
- //gets starting action than sends in a loop
- if(IsOnScreen(Varrock))
- GetToTheBank();
- else if(IsOnScreen(BarbVillage))
- { EnterStronghold();
- GetToFloor3();
- DoorHandeler();
- Fight(); }
- else if(AtFloor("Three"))
- { DoorHandeler();
- Fight(); }
- else if(IsOnScreen(Spiders))
- Fight();
- }
- private void Fight() {
- while(IsOnScreen(Spiders))
- { CheckHealth();
- CheckPots();
- Attack();
- sleep(0, 2603); }
- }
- private void AntiBan() {
- int x = General.random(0, 75);
- int y = General.random(0, 150);
- if(x == 47 || x == 74 )
- { GameTab.open(TABS.STATS);
- sleep(800, 1200);
- Mouse.move(General.random(561, 598), General.random(244, 257));
- sleep(800, 3000);
- GameTab.open(TABS.INVENTORY); }
- if(y == 34 || y == 86 || y == 22)
- Camera.setCameraRotation(General.random(22, 300));
- }
- private void CheckPots() {
- DrinkStr();
- DrinkAtk();
- DrinkDef();
- }
- private void DrinkDef() {
- if(Skills.getCurrentLevel(SKILLS.DEFENCE) == (Skills.getActualLevel(SKILLS.DEFENCE)))
- for(int z = 4; z <= 1 ; z--)
- if(Inventory.find("Super attack("+ z +")").length > 0)
- { Inventory.find("Super attack("+ z +")")[0].click();
- sleep(2000, 4000); }
- }
- private void DrinkAtk() {
- if(Skills.getCurrentLevel(SKILLS.ATTACK) == (Skills.getActualLevel(SKILLS.ATTACK)))
- for(int y = 4; y <= 1 ; y--)
- if(Inventory.find("Super attack("+ y +")").length > 0)
- { Inventory.find("Super attack("+ y +")")[0].click();
- sleep(2000, 4000); }
- }
- private void DrinkStr() {
- if(Skills.getCurrentLevel(SKILLS.STRENGTH) == (Skills.getActualLevel(SKILLS.STRENGTH)))
- for(int x = 4; x <= 1 ; x--)
- if(Inventory.find("Super strength("+ x +")").length > 0)
- { Inventory.find("Super strength("+ x +")")[0].click();
- sleep(2000, 4000); }
- }
- private void CheckHealth() {
- OpenInventory();
- if(WeNeedFood())
- EatFood();
- }
- private void OpenInventory() {
- if(!GameTab.getOpen().equals(GameTab.TABS.INVENTORY))
- GameTab.open(TABS.INVENTORY);
- }
- private void EatFood() {
- RSItem[] Food = Inventory.find(FOOD);
- if(WeHaveFoodToEat())
- { Food[0].click();
- sleep(2000,3000); }
- if (!WeHaveFoodToEat())
- { if(Player.getRSPlayer().getHealth() < 60 && Food.length > 0) //saves a food as a failsafe --> WeHaveAnExtra()
- Food[0].click();
- GetToTheBank(); }
- }
- private boolean WeHaveFoodToEat() {
- RSItem[] Food = Inventory.find(FOOD);
- if(Food.length >= 2 && Player.getRSPlayer().getHealth() < 40)
- return true;
- else if(Food.length <= 1)
- return false;
- else
- return false;
- }
- private boolean WeNeedFood() {
- if(Player.getRSPlayer().getHealth() < 40)
- return true;
- else return false;
- }
- private void GetToTheBank() {
- println("Leaving");
- if(!IsOnScreen(Varrock))
- TeleportOut();
- if(IsOnScreen(Varrock))
- WalkToBank();
- else
- GetToTheBank();
- }
- private void WalkBack() {
- WalkToVillage();
- EnterStronghold();
- GetToFloor3();
- DoorHandeler();
- Fight();
- }
- private void WalkToVillage() {
- if(!IsOnScreen(BarbVillage))
- { WebWalking.walkTo(new RSTile(General.random(3155, 3161), General.random(3419, 3423)));
- sleep(0,600);
- WebWalking.walkTo(new RSTile(General.random(3128, 3133), General.random(3413, 3415)));
- sleep(0,1000);
- WebWalking.walkTo(new RSTile(General.random(3110, 3114), General.random(3419, 3421)));
- sleep(0,400);
- WebWalking.walkTo(new RSTile(General.random(3084, 3079), General.random(3422, 3425)));
- sleep(3500,7000); }
- else WebWalking.walkTo(new RSTile(General.random(3084, 3079), General.random(3422, 3425))); //Last walk so it doesnt repeat path
- }
- private void GetToFloor3() {
- Floor1();
- Floor2();
- println("At floor 3");
- }
- private void Floor2() {
- if(!IsOnScreen(Floor2))
- while(!IsOnScreen(Floor2))
- sleep(300);
- EnterPortals();
- Walking.walkTo(rt(2022, 5217)); //walks to ladder in prize room
- sleep(1000, 5000);
- ClimbLadders();
- }
- private RSTile rt(int tileX, int tileY) {
- int TileX = tileX + r(2, 5);
- int TileY = tileY + r(2, 5);
- RSTile randomTile = new RSTile(r(tileX, TileX), r(tileY, TileY));
- return randomTile;
- }
- private int r(int min, int max) {
- int randomInt = General.random(min, max);
- return randomInt;
- }
- private void Floor1() {
- Walking.walkTo(rt(1862, 5239)); //walks next to portal
- sleep(1000, 3000);
- EnterPortals();
- Walking.walkTo(rt(1903, 5221)); //walks next to ladder
- sleep(2000, 5000);
- ClimbLadders();
- }
- private void EnterStronghold() {
- WaitForEntrance();
- while(!IsOnScreen(Stronghold))
- { Enter();
- sleep(2000, 5000); }
- }
- private void Enter() {
- RSObject[] Entrance = Objects.findNearest(10, Entrance_ID);
- if(Entrance.length > 0)
- if(Entrance[0].isOnScreen())
- { Entrance[0].hover();
- if(Game.getUptext().contains("Climb"))
- Entrance[0].click("Climb-down");
- else Enter();
- sleep(1000, 4000); }
- else { Camera.turnToTile(Entrance[0].getPosition());
- Enter(); }
- else if(Entrance.length == 0) //failsafe
- { WalkToVillage();
- Enter(); }
- }
- private void WaitForEntrance() {
- RSObject[] Entrance = Objects.findNearest(10, Entrance_ID);
- if(Entrance.length == 0)
- while(Entrance.length == 0)
- { sleep(1000, 3000);
- WalkToVillage(); }
- }
- private void ClimbLadders() {
- RSObject[] Ladder = Objects.find(15, "Ladder");
- if(Ladder.length > 0)
- if(!Ladder[0].isOnScreen())
- { Camera.setCameraRotation(General.random(200,314));
- ClimbLadders(); }
- else if(Ladder[0].isOnScreen())
- while(InPrizeRoom())
- { Ladder[0].click("Climb-down");
- sleep(2000, 4000); }
- else { EnterPortals();
- ClimbLadders(); }
- }
- private boolean InPrizeRoom() {
- for(int x = 0; x <= PrizeRoom.length - 1; x++)
- if(PrizeRoom[x].isOnScreen())
- return true;
- return false;
- }
- private void EnterPortals() {
- RSObject[] Portal = Objects.find(15, "Portal");
- if(Portal.length > 0)
- if(!Portal[0].isOnScreen())
- { Camera.setCameraRotation(General.random(90, 200));
- sleep(3000,5000); EnterPortals(); }
- else if(Portal[0].isOnScreen())
- while(Portal[0].isOnScreen())
- { Portal[0].click();
- sleep(2000, 4000); }
- // else GetStartingAction(); //got lost where i was lol
- }
- private boolean AtFloor(String Floor) {
- if(Floor.equals("Two"))
- { if(IsOnScreen(Floor2))
- return true;
- else
- return false; }
- else if(Floor.equals("Three"))
- { if(IsOnScreen(Floor3))
- return true;
- else
- return false; }
- else
- return false;
- }
- private void GetSupplies() {
- Banking.depositAllExcept(5680, 379, 2440, 8007, 2436);
- Withdraw("Super strength(4)", 1);
- Withdraw("Super atttack(4)", 1);
- Withdraw("Super defence(4)", 1);
- Withdraw(FOOD, 23);
- CloseBank();
- bankTrips++;
- WalkBack();
- }
- private void CloseBank() {
- Banking.close();
- sleep(1000, 2000);
- if(Banking.isBankScreenOpen()){
- while(Banking.isBankScreenOpen())
- { Banking.close();
- sleep(1000, 2000); }
- }
- }
- public boolean IsInBank(String Item){
- if(Banking.find(Item).length > 1)
- return true;
- else return false;
- }
- public void Withdraw(String Item, int Amount){
- Banking.withdraw(Amount, Item);
- sleep(2000, 3500);
- if(Banking.find(Item).length > Amount){
- if(Inventory.find(Item).length < Amount)
- while(Inventory.find(Item).length < Amount)
- { Banking.withdraw(Amount, Item);
- sleep(2000, 3500); }
- } else
- if(Item.equals(FOOD))
- KillScript();
- }
- private void KillScript() {
- System.out.println("Out of food");
- botIsRunning = false;
- run();
- }
- private boolean IsOnScreen(RSTile Place[]) {
- for(int x = 0; x <= Place.length - 1; x++)
- if(Place[x].isOnScreen())
- return true;
- return false;
- }
- private void WalkToBank() {
- WebWalking.walkTo(new RSTile(General.random(3195, 3199), General.random(3427, 3430)));
- sleep(300,600);
- WebWalking.walkTo(new RSTile(General.random(3181, 3183), General.random(3436, 3438)));
- sleep(0, 500);
- WaitForBooth();
- OpenBooth();
- GetSupplies();
- }
- private void OpenBooth() {
- RSObject[] BankBooth = Objects.findNearest(15, "Bank booth");
- if(!BankBooth[0].isOnScreen())
- { Camera.turnToTile(BankBooth[0].getPosition());
- sleep(860, 2031);
- OpenBooth(); }
- else if(BankBooth[0].isOnScreen())
- while(BankBooth[0].isOnScreen() && !Banking.isBankScreenOpen())
- {Banking.openBankBooth();
- sleep(3000,6000);}
- }
- private void WaitForBooth() {
- RSObject[] BankBooth = Objects.findNearest(15, "Bank booth");
- if(BankBooth.length <= 0){
- println("Waiting for booth");
- sleep(300, 1023);
- WaitForBooth(); }
- else { sleep(4304,7305);
- OpenBooth(); }
- }
- private void TeleportOut() {
- OpenInventory();
- RSItem[] VTab = Inventory.find(8007);
- if(VTab.length != 0)
- { VTab[0].click("Varrock teleport");
- sleep(6000, 10000); }
- }
- private void DoorHandeler() {
- Walking.walkTo(new RSTile(General.random(2132, 2133), 5256));
- while(Player.isMoving())
- sleep(300, 1000);
- Door1();
- Door2();
- if(IsOnScreen(Spiders))
- { WebWalking.walkTo(new RSTile(General.random(2123, 2127), General.random(5270, 5274)));
- sleep(1000, 3000);
- Fight(); }
- }
- private void Door2() {
- RSObject[] Door = Objects.findNearest(2, "Oozing barrier");
- if(InDoor())
- { while(!ReadyForDoor2())
- { WebWalking.walkTo(new RSTile(General.random(2132, 2133), 5259)); //Tile infront of door
- sleep(3000, 4000); }
- if(Door.length > 0 && Door[0].isOnScreen()) //else DoorHandeler
- if(ReadyForDoor2())
- while(ReadyForDoor2())
- { ClickDoor();
- if(WeGotThrough())
- WalkUpAndFight(); }
- }
- }
- private void WalkUpAndFight() {
- WebWalking.walkTo(rt(2128, 5269));
- Fight();
- }
- private boolean WeGotThrough() {
- if(!ReadyForDoor2())
- { sleep(2000, 4000);
- if(!ReadyForDoor2())
- return true;
- else return false; }
- else return false;
- }
- private void Door1() {
- RSObject[] Door = Objects.findNearest(10, "Oozing barrier");
- if(Door.length > 0 && Door[0].isOnScreen()) //else DoorHandeler
- if(InFrontOfDoor())
- { while(InFrontOfDoor())
- ClickDoor(); } else DoorHandeler();
- else
- DoorHandeler();
- }
- private boolean ReadyForDoor2() {
- if(Player.getPosition().equals(new RSTile(2132, 5259)) || Player.getPosition().equals(new RSTile(2133, 5259)))
- return true;
- else return false;
- }
- private boolean InDoor() {
- if(Player.getRSPlayer().getPosition().equals(new RSTile(2133, 5257, 0)) ||
- Player.getRSPlayer().getPosition().equals(new RSTile(2132, 5257, 0)))
- return true;
- else return false;
- }
- private void ClickDoor() {
- RSObject[] Door = Objects.findNearest(2, "Oozing barrier");
- Door[0].hover();
- if(Game.getUptext().contains("Open"))
- Door[0].click();
- sleep(500, 600);
- }
- private boolean InFrontOfDoor() {
- RSTile Position = Player.getRSPlayer().getPosition();
- if(Position.equals(new RSTile(2133, 5256, 0)) ||
- Position.equals(new RSTile(2133, 5255, 0)))
- return true;
- else return false;
- }
- private void Attack(){
- RSNPC[] GiantSpider = NPCs.findNearest("Giant spider");
- if(GiantSpider.length == 0)
- sleep(300);
- if(WeCanAttack(GiantSpider))
- Hover(GiantSpider);
- AntiBan1();
- }
- private void AntiBan1() {
- int x = General.random(0, 1000);
- if(x == 23 || x == 465)
- AntiBan();
- }
- private void Hover(RSNPC[] GiantSpider) {
- RSModel GiantSpiderModel = GiantSpider[0].getModel();
- Mouse.setSpeed(General.random(125, 150));
- GiantSpiderModel.hover();
- if(WeCanClick(GiantSpider))
- { GiantSpiderModel.click();
- sleep(4000, 5000); }
- }
- private boolean WeCanClick(RSNPC[] GiantSpider) {
- if(Game.getUptext().contains("Attack") && GiantSpider[0].isOnScreen() && !(GiantSpider[0].isInCombat()))
- return true; else return false;
- }
- private boolean WeCanAttack(RSNPC[] GiantSpider) {
- if(GiantSpider.length > 0 && GiantSpider[0].isOnScreen() && !(Player.getRSPlayer().isInCombat()) && !(GiantSpider[0].isInCombat()))
- return true; else return false;
- }
- private final Color color1 = new Color(0, 0, 0);
- private final Color color2 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 15);
- private static final long startTime = System.currentTimeMillis();
- @Override
- public void onPaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRect(289, 221, 229, 117);
- g.setStroke(stroke1);
- g.drawRect(289, 221, 229, 117);
- g.setFont(font1);
- g.setColor(color2);
- long timeRan = System.currentTimeMillis() - startTime;
- int gainedXP = Skills.getXP(SKILLS.STRENGTH) - startXP;
- long xpPerHour = (long)(gainedXP * 3600000 / timeRan);
- g.drawString("X/P per hour: " + xpPerHour, 305, 246);
- g.drawString("Time ran: " + Timing.msToString(timeRan), 307, 271);
- g.drawString("Bank trips: " +bankTrips, 306, 296);
- g.drawString("Coded by JDezzy", 346, 329);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment