Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.Script;
- import java.util.Random;
- import org.rsbot.script.wrappers.RSPlayer;
- import java.awt.*;
- import javax.imageio.ImageIO;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JSlider;
- import java.io.IOException;
- import java.net.URL;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSPath;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "Wei Su" }, name = "Ultimate Spider Killer", version = 0.1, description = "Kills giant spider", keywords = {
- "", "", "" })
- /* Save as script.java - who could get that wrong! :) */
- public class UltimateSpiderKiller extends Script implements PaintListener,
- MessageListener, ActionListener, MouseMotionListener, MouseListener {
- public int[] giantID = { 4400 };
- public int[] foodID = { 7946 };
- public int[] doorID = { 16090 };
- public int teleID = 8007;
- RSArea spiderArea1 = new RSArea(2144, 5302, 2156, 5310);
- RSArea spiderArea2 = new RSArea(2115, 5260, 2135, 5278);
- RSArea firstArea = new RSArea(2148, 5299, 2149, 5301);
- RSArea secondArea = new RSArea(2141, 5294, 2158, 5298);
- RSTile secondTile = new RSTile(2141, 5294);
- RSArea thirdArea = new RSArea(2138, 5294, 2140, 5295);
- RSArea fourthArea = new RSArea(2127, 5282, 2137, 5295);
- RSTile fourthTile = new RSTile(2132, 5282);
- RSArea fifthArea = new RSArea(2132, 5279, 2133, 5281);
- RSArea sixthArea = new RSArea(2117, 5261, 2137, 5278);
- RSTile sixthTile = new RSTile(2132, 5262);
- RSArea seventhArea = new RSArea(2132, 5257, 2133, 5259);
- RSArea eighthArea1 = new RSArea(2117, 5251, 2130, 5258);
- RSArea eighthArea2 = new RSArea(2129, 5252, 2132, 5256);
- RSTile eighthTile = new RSTile(2123, 5252);
- private final RSTile doors[] = { new RSTile(2132, 5257),
- new RSTile(2132, 5260), new RSTile(2132, 5278),
- new RSTile(2132, 5281), new RSTile(2138, 5294),
- new RSTile(2141, 5294), new RSTile(2148, 5299),
- new RSTile(2148, 5302) };
- //first is last, last is [7]
- @Override
- public boolean onStart() {
- mouse.setSpeed(3);
- return true;
- }
- public int loop() {
- RSObject ladder2 = objects.getNearest(16080);
- RSObject ladder3 = objects.getTopAt(new RSTile(1859, 5244));
- try {
- if (checkAttack() && !checkEat() && atSpiders() && canEat()) {
- attack();
- log("Debugging: Attacking");
- }
- if (checkEat() && canEat()) {
- eat();
- log("Debugging:Eating");
- }
- if (spiderFloor() && !canEat()) {
- doBankingWalk();
- }
- if (!canEat() && ladder2.isOnScreen()){
- ladder2.doAction("Climb");
- sleep(random(2000,3000));
- }
- if (!canEat() && ladder3.isOnScreen()){
- ladder3.doAction("Climb");
- sleep(random(2000,3000));
- }
- } catch (Exception ignore) {
- }
- return random(50, 100);
- }
- public void doBankingWalk() {
- RSItem teleTab = inventory.getItem(teleID);
- if (inventory.contains(teleID)) {
- teleTab.doAction("Break");
- } else {
- walkToBank();
- }
- }
- public void walkToBank() {
- RSObject door7 = objects.getTopAt(doors[7]);
- RSObject door6 = objects.getTopAt(doors[6]);
- RSObject door5 = objects.getTopAt(doors[5]);
- RSObject door4 = objects.getTopAt(doors[4]);
- RSObject door3 = objects.getTopAt(doors[3]);
- RSObject door2 = objects.getTopAt(doors[2]);
- RSObject door1 = objects.getTopAt(doors[1]);
- RSObject door0 = objects.getTopAt(doors[0]);
- if(spiderArea1.contains(getMyPlayer().getLocation())){
- door7.doAction("Open");
- sleep(random(3000,3200));
- }
- if(firstArea.contains(getMyPlayer().getLocation())){
- door6.doAction("Open");
- sleep(random(3000,3200));
- }
- if(secondArea.contains(getMyPlayer().getLocation())){
- if(calc.distanceTo(door5) > 5){
- RSPath path = null;
- if (path == null) {
- path = walking.getPath(secondTile);
- }
- path.traverse();
- } else {
- door5.doAction("Open");
- sleep(random(3000,3200));
- }
- }
- if(thirdArea.contains(getMyPlayer().getLocation())){
- door4.doAction("Open");
- sleep(random(3000,3200));
- }
- if(fourthArea.contains(getMyPlayer().getLocation())){
- if(calc.distanceTo(door3) > 5){
- RSPath path = null;
- if (path == null) {
- path = walking.getPath(fourthTile);
- }
- path.traverse();
- } else {
- door3.doAction("Open");
- sleep(random(3000,3200));
- }
- }
- if(fifthArea.contains(getMyPlayer().getLocation())){
- door2.doAction("Open");
- sleep(random(3000,3200));
- }
- if(sixthArea.contains(getMyPlayer().getLocation())){
- if(calc.distanceTo(door1) > 5){
- RSPath path = null;
- if (path == null) {
- path = walking.getPath(sixthTile);
- }
- path.traverse();
- } else {
- door1.doAction("Open");
- sleep(random(3000,3200));
- }
- }
- if(seventhArea.contains(getMyPlayer().getLocation())){
- door0.doAction("Open");
- sleep(random(3000,3200));
- }
- if(eighthArea1.contains(getMyPlayer().getLocation()) || eighthArea2.contains(getMyPlayer().getLocation()) || getMyPlayer().getLocation() == new RSTile(2133, 5256)){
- RSObject ladder = objects.getTopAt(new RSTile(2123, 5251));
- if (calc.distanceTo(ladder) > 5){
- RSPath path = null;
- if (path == null) {
- path = walking.getPath(new RSTile(2125, 5253));
- }
- path.traverse();
- } else {
- ladder.doAction("Climb");
- sleep(random(2100,2300));
- }
- }
- }
- public void walkToSecondRoom() {
- }
- public boolean spiderFloor() {
- RSNPC spiders = getNpc();
- if (spiders != null) {
- return true;
- } else {
- return false;
- }
- }
- public boolean atSpiders() {
- if (spiderArea1.contains(getMyPlayer().getLocation())
- || spiderArea2.contains(getMyPlayer().getLocation())) {
- return true;
- } else {
- return false;
- }
- }
- public boolean canEat() {
- if (inventory.containsOneOf(foodID)) {
- return true;
- } else {
- return false;
- }
- }
- public void eat() {
- RSItem food = inventory.getItem(foodID);
- food.doAction("Eat");
- sleep(random(100, 200));
- }
- public int getLifePoints() {
- try {
- return ((int) ((Integer.parseInt(interfaces.get(748)
- .getComponent(8).getText().trim()) / (double) (skills
- .getRealLevel(Skills.CONSTITUTION) * 10)) * 100));
- } catch (Exception e) {
- return 100;
- }
- }
- public boolean checkEat() {
- if (getLifePoints() <= 100) {
- return true;
- } else {
- return false;
- }
- }
- public boolean checkAttack() {
- if (getMyPlayer().getAnimation() == -1
- && getMyPlayer().getInteracting() == null
- && !getMyPlayer().isInCombat()) {
- return true;
- } else {
- return false;
- }
- }
- public void attack() {
- RSNPC spider = getNpc();
- spider.doAction("Attack");
- }
- public RSNPC getNpc() {
- final Filter<RSNPC> filter = new Filter<RSNPC>() {
- public boolean accept(RSNPC n) {
- return (validNpc(n) && (!n.isInCombat() && n.getInteracting() == null))
- && n.getHPPercent() != 0;
- }
- };
- return npcs.getNearest(filter);
- }
- public boolean validNpc(RSNPC n) {
- if (n != null) {
- for (int id : giantID) {
- if (id == n.getID())
- return true;
- }
- if (n.getName().toLowerCase().contains("giant".toLowerCase()))
- return true;
- }
- return false;
- }
- @Override
- public void onFinish() {
- }
- // START: Code generated using Enfilade's Easel
- public void mouseClicked(MouseEvent e) {// this is the mouse listener, it
- // listen's for the click.
- }
- // END: Code generated using Enfilade's Easel
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseDragged(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseMoved(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void actionPerformed(ActionEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void messageReceived(MessageEvent arg0) {
- }
- @Override
- public void onRepaint(Graphics arg0) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement