Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * TODO: Nothing atm
- */
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import org.rsbot.bot.Bot;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- @ScriptManifest(authors = { "Nobody" }, category = "Combat", name = "Ogre Cage Ranger", version = 2.0, description =
- "<html><body bgcolor =\"#AAAAAAAA\"><font color =\"#3333FF\"><center><h2>Nobody's Ogre Cage Ranger</h2><BR>"
- + "<font size =\"3\">Start in Traning Ground with Range Equipment,airs & laws<br />"
- + "<tr><td>Tele - Grab Seeds: </td><td><center><input type='checkbox' name='Seed' value='true'></font><br />"
- + "</font></body></html>")
- public class OgreCageRanger extends Script implements ServerMessageListener, PaintListener {
- long startTime;
- long minutes;
- long seconds;
- long hours;
- long runTime;
- RSTile StartSpot;
- public int speed = 300;
- public int walkSpeed = 300;
- public long lastCheck = -1, lastcheck1 = -1, lastCheck2, lastCheck3 = System.currentTimeMillis();
- public Point mousePos;
- boolean Seed = false;
- int seed;
- int MONSTER = 2801;
- int LawRune = 563;
- int AirRune = 556;
- int expGained;
- int levelsGained;
- int startXp;
- int startLevel;
- int amountleft;
- int RanarrID = 5295;
- int WaterID = 5321;
- int SnapeID = 5300;
- int KwuarmID = 5299;
- int LimpID = 5100;
- int StrawbID = 5323;
- int LoopkID = 987;
- int ToothkID = 985;
- int ToadfID = 5296;
- int[] totalSeeds = {RanarrID, WaterID, SnapeID, KwuarmID, LimpID, StrawbID, LoopkID, ToothkID, ToadfID};
- @Override
- protected int getMouseSpeed() {
- return random(5, 7);
- }
- public boolean onStart(Map<String, String> args) {
- StartSpot = getMyPlayer().getLocation();
- if (args.get("Seed") != null && inventoryContains(LawRune)
- && inventoryContains(AirRune)) {
- Seed = true;
- }
- seed = 0;
- startTime = System.currentTimeMillis();
- startXp = skills.getCurrentSkillExp(STAT_RANGE);
- startLevel = skills.getCurrentSkillLevel(STAT_RANGE);
- return true;
- }
- public void onFinish() {
- Bot.getEventManager().removeListener(PaintListener.class, this);
- Bot.getEventManager().removeListener(ServerMessageListener.class, this);
- }
- @Override
- public RSInterfaceChild getInventoryInterface() {
- if (getInterface(Constants.INVENTORY_COM_X).isValid()) {
- return RSInterface.getChildInterface(Constants.INVENTORY_COM_X,
- Constants.INVENTORY_COM_Y);
- }
- return RSInterface.getChildInterface(Constants.INVENTORY_X,
- Constants.INVENTORY_Y);
- }
- @SuppressWarnings("unused")
- private boolean clickInventoryArray(int[] itemID, String option) {
- 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 X = 0; X < itemID.length; X++) {
- for (int i = 0; i < items.length; i++) {
- if (items[i] == itemID[X]) {
- possible.add(i);
- }
- }
- }
- if (possible.size() == 0) {
- return false;
- } else {
- int IDE = random(0, possible.size());
- int idx = possible.get(IDE);
- Point t = getInventoryItemPoint(idx);
- clickMouse(t, 5, 5, false);
- return atMenu(option);
- }
- }
- public void checkForLevelUpMessage() {
- if (RSInterface.getInterface(INTERFACE_LEVELUP).isValid()) {
- wait(random(800, 2000));
- atInterface(INTERFACE_LEVELUP, 3);
- wait(random(1000, 2000));
- }
- }
- public boolean CheckSeed() {
- RSTile Ranarr = getGroundItemByID(5295);
- RSTile Water = getGroundItemByID(5321);
- RSTile Snape = getGroundItemByID(5300);
- RSTile Kwuarm = getGroundItemByID(5299);
- RSTile Strawb = getGroundItemByID(5323);
- RSTile Toothk = getGroundItemByID(985);
- RSTile Loopk = getGroundItemByID(987);
- RSTile Limp = getGroundItemByID(5100);
- RSTile Toadf = getGroundItemByID(5296);
- if (Seed) {
- if (Ranarr != null || Water != null || Snape != null
- || Kwuarm != null || Limp != null || Strawb != null
- || Toothk != null || Loopk != null || Limp != null
- || Toadf != null) {
- return false;
- }
- }
- return true;
- }
- public boolean rightClickTile(RSTile tile, String action) {
- Point p = Calculations.tileToScreen(tile);
- clickMouse(p, false);
- wait(random(500, 800));
- return atMenu(action);
- }
- @Override
- public int loop() {
- if (distanceTo(StartSpot) > 3) {
- walkTileMM(StartSpot);
- }
- {
- checkForLevelUpMessage();
- }
- if (Seed) {
- RSTile Ranarr = getGroundItemByID(RanarrID);
- RSTile Water = getGroundItemByID(WaterID);
- RSTile Snape = getGroundItemByID(SnapeID);
- RSTile Kwuarm = getGroundItemByID(KwuarmID);
- RSTile Limp = getGroundItemByID(LimpID);
- RSTile Strawb = getGroundItemByID(StrawbID);
- RSTile Toothk = getGroundItemByID(ToothkID);
- RSTile Loopk = getGroundItemByID(LoopkID);
- RSTile Toadf = getGroundItemByID(ToadfID);
- if (Toadf != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Toadf, "Grab -> Toadflax");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Ranarr != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Ranarr, "Grab -> Ranarr");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Loopk != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Loopk, "Grab -> Loop");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Toothk != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Toothk, "Grab -> Tooth");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Strawb != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Strawb, "Grab -> Strawberry");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Water != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Water, "Grab -> Watermelon");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Snape != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Snape, "Grab -> Snapdragon");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Kwuarm != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Kwuarm, "Grab -> Kwuarm");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- if (Limp != null) {
- openTab(Constants.TAB_MAGIC);
- if (getCurrentTab() == Constants.TAB_MAGIC) {
- castSpell(Constants.SPELL_TELEKINETIC_GRAB);
- rightClickTile(Limp, "Grab -> Limp");
- seed++;
- openTab(Constants.TAB_INVENTORY);
- wait(random(1400, 2200));
- }
- }
- }
- if (CheckSeed() && getMyPlayer().getInteracting() == null
- && getNearestFreeNPCByID(MONSTER) != null) {
- clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
- }/* else {
- if (npc.getInteracting() != null
- && !npc.isInteractingWithLocalPlayer()
- && getMyPlayer().getInteracting() == null)
- atNPC(getNearestNPCByID(MONSTER), "Attack");
- }*/
- return 800;
- }
- public void serverMessageRecieved(ServerMessageEvent e) {
- String message = e.getMessage();
- if (message.contains("There is no ammo left in your quiver.")) {
- log("No Arrows!!");
- stopScript();
- }
- if (message.contains("That was your last one!")) {
- log("No knives!!");
- stopScript();
- }
- }
- public boolean activateCondition() {
- if (getMyPlayer().isMoving()) {
- return random(1, walkSpeed) == 1;
- } else {
- return random(1, speed) == 1;
- }
- }
- public boolean someNPC(RSNPC npc, String action) {
- try {
- int a;
- StringBuffer npcCommandBuf = new StringBuffer();
- npcCommandBuf.append(action);
- npcCommandBuf.append(" ");
- npcCommandBuf.append(npc.getName());
- String npcCommand = npcCommandBuf.toString();
- for (a = 10; a-- >= 0;) {
- if (npc.getInteracting() != null
- && !npc.isInteractingWithLocalPlayer()) {
- return false;
- }
- List<String> menuItems = getMenuItems();
- if (menuItems.size() > 1) {
- if (listContainsString(menuItems, npcCommand)) {
- if (menuItems.get(0).contains(npcCommand)) {
- clickMouse(true);
- return true;
- } else {
- clickMouse(false);
- wait(random(230, 520));
- return atMenu(npcCommand);
- }
- }
- }
- Point screenLoc = npc.getScreenLocation();
- if (!pointOnScreen(screenLoc)) {
- return false;
- }
- Point randomP = new Point(random(screenLoc.x - 15,
- screenLoc.x + 15), random(screenLoc.y - 15,
- screenLoc.y + 15));
- if (randomP.x >= 0 && randomP.y >= 0) {
- moveMouse(randomP);
- }
- }
- return false;
- } catch (Exception e) {
- System.out.print("clickNPC(RSNPC, String) error: " + e);
- return false;
- }
- }
- public boolean listContainsString(List<String> list, String string) {
- try {
- int a;
- for (a = list.size() - 1; a-- >= 0;) {
- if (list.get(a).contains(string)) {
- return true;
- }
- }
- } catch (Exception e) {
- }
- return false;
- }
- public void onRepaint(Graphics g) {
- runTime = System.currentTimeMillis( ) - startTime;
- seconds = runTime / 1000;
- if ( seconds >= 60 ) {
- minutes = seconds / 60;
- seconds -= (minutes * 60);
- }
- if ( minutes >= 60 ) {
- hours = minutes / 60;
- minutes -= (hours * 60);
- }
- expGained = skills.getCurrentSkillExp(STAT_RANGE) - startXp;
- g.setColor( new Color(0, 0, 0, 50) );
- g.fillRoundRect(3, 180, 155, 130, 5, 5);
- levelsGained = skills.getCurrentSkillLevel(STAT_RANGE) - startLevel;
- g.setColor( Color.WHITE );
- g.drawString("Ogre Cage Ranger V 2.0", 12, 216);
- g.drawString("Run time: " + hours + ":" + minutes + ":" + seconds, 12, 232);
- g.drawString("Seeds Collected: " + seed + " seeds.", 12, 248);
- g.drawString("XP Gained: " + expGained, 12, 264);
- g.drawString("Levels Gained: " + levelsGained, 12, 280);
- g.drawString("Percent to next level: " + skills.getPercentToNextLevel(STAT_RANGE), 12, 296);
- }
- public boolean isRanging() {
- final int id = getMyPlayer().getAnimation();
- return id == 426 || id == 4230 || id == 1074;
- }
- private boolean clickNPC(final RSNPC npc, final String action) {
- final RSTile tile = npc.getLocation();
- tile.randomizeTile(1, 1);
- try {
- final int hoverRand = random(8, 13);
- for (int i = 0; i < hoverRand; i++) {
- final Point screenLoc = npc.getScreenLocation();
- if (!pointOnScreen(screenLoc)) {
- setCameraRotation(getCameraAngle() + random(-35, 150));
- return true;
- }
- moveMouse(screenLoc, 15, 15);
- final List<String> menuItems = getMenuItems();
- if (menuItems.isEmpty() || menuItems.size() <= 1) {
- continue;
- }
- if (menuItems.get(0).toLowerCase().contains(
- npc.getName().toLowerCase())
- && getMyPlayer().getInteracting() == null) {
- clickMouse(true);
- return true;
- } else {
- for (int a = 1; a < menuItems.size(); a++) {
- if (menuItems.get(a).toLowerCase().contains(
- npc.getName().toLowerCase())
- && getMyPlayer().getInteracting() == null) {
- clickMouse(false);
- return atMenu(action);
- }
- }
- }
- }
- } catch (final Exception e) {
- log.warning("ATTACKNPC(RSNPC, String) error: " + e);
- return false;
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment