Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.scripts;
- import com.kbot2.scriptable.methods.Calculations;
- import com.kbot2.scriptable.Script;
- import com.kbot2.scriptable.methods.data.Skills;
- import com.kbot2.scriptable.methods.data.GameScreen;
- import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
- import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
- import com.kbot2.scriptable.methods.wrappers.GroundItem;
- import com.kbot2.scriptable.methods.wrappers.NPC;
- import com.kbot2.scriptable.methods.wrappers.Interface;
- import com.kbot2.scriptable.methods.wrappers.Tile;
- import java.awt.*;
- import java.awt.Color;
- /**
- * Created by IntelliJ IDEA.
- * User: Koh-Koh
- * Date: 12/06/2009
- * Time: 9:25:03 AM
- * To change this template use File | Settings | File Templates.
- */
- public class KohtaOgreRanger extends Script implements PaintListener, ServerMessageListener {
- int hitpointStartExp = 0;
- int rangeStartExp = 0;
- final int[] OGRE_ID = new int[]{2801};
- int snappy = 0;
- int ranarry = 0;
- int watery = 0;
- int strawy = 0;
- int dwarfey = 0;
- int kwuarmy = 0;
- int latadymey = 0;
- int state=1;
- int prev=0;
- private long nextABTime = 0;
- private NPC currentNPC = null;
- boolean snap = false;
- boolean ranar = false;
- boolean watermelo = false;
- boolean strawberr = false;
- boolean dwar = false;
- boolean kwuar = false;
- boolean latadym = false;
- boolean bigBoner = false;
- int [] itemIDs = new int[] {5259, 5300, 5321, 5323, 5303, 5299, 5302};
- private final static Rectangle trainingArea = new Rectangle(2523, 3371, 8, 1);
- Tile walkToCage = new Tile(2523 + random(0,8), 3371 + random(0,1));
- long startTime = System.currentTimeMillis();
- public boolean itemsOnFloor() {
- Interface i;
- GroundItem itemTile = groundItems.getClosestItem(25, itemIDs);
- if (itemTile != null) {
- final Point itemScreen = itemTile.getScreenPos();
- if (Calculations.onScreen(itemScreen)) {
- Point magTab = new Point(random(730, 751), random(173, 194));
- clickMouse(magTab, true);
- i = interfaces.getInterface(192, 19);
- if (i != null) {
- i.doClick();
- }
- itemTile.doAction("Telekinetic Grab");
- try {
- Thread.sleep(random(1500,2300));
- }
- catch (InterruptedException ie) { }
- return true;
- }
- }
- return false;
- }
- public int loop() {
- interfaces.clickContinue();
- if(!trainingArea.contains(new Point(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY())) && !getMyPlayer().isInCombat())
- walking.walkToMM(walkToCage);
- switch(state){
- case 0:
- if(getAnimation2()) { }
- else {
- state = prev;
- }
- return random(20,100);
- case 1:
- if (itemsOnFloor()) {
- state = 2;
- return random(300, 1000);
- }
- state = 2;
- return random(20, 100);
- case 2:
- NPC Ogre = getClosestFree(256, OGRE_ID);
- if (Ogre != null && !Ogre.isInCombat()) {
- if(Ogre.doAction("Attack")) {
- currentNPC = Ogre;
- state = 0;
- prev = 1;
- return random(25, 50);
- } else
- state = 2;
- return random(25, 50);
- }
- return random(25, 50);
- }
- return random(25, 50);
- }
- boolean getAnimation2() {
- long timer = System.currentTimeMillis();
- while(System.currentTimeMillis() - timer < 1300) {
- if (System.currentTimeMillis() >= nextABTime)
- antiBan();
- if(getMyPlayer().getAnimation() != -1 || getMyPlayer().getInteracting() != null)
- timer = System.currentTimeMillis();
- if(System.currentTimeMillis() - timer > 1300)
- return false;
- }
- return true;
- }
- public NPC getClosestFree(int range, int... ids) {
- Tile myLoc = players.getMyPlayer().getLocation();
- double closestDist = 256;
- NPC[] allNPCs = npcs.getNPCs();
- NPC closestNPC = null;
- try {
- mainLoop: for(NPC tempNPC : allNPCs) {
- for(int i : ids) {
- if (tempNPC.isInCombat())
- continue;
- int tempDist = tempNPC.getLocation().distanceTo(myLoc);
- if(i == tempNPC.getID() && tempDist <= range && tempDist < closestDist) {
- closestNPC = tempNPC;
- closestDist = tempDist;
- continue mainLoop;
- }
- }
- }
- } catch (Exception betterSafeThanSorry) {
- return null;
- }
- return closestNPC;
- }
- private int antiBan() {
- nextABTime = System.currentTimeMillis() + (1000 * random(2, 40) + random(0, 1000));
- final int randomAction = random(0, 5);
- switch (randomAction) {
- case 0:
- if (gameScreen.getCurrentTab() != GameScreen.TAB_INVENTORY) {
- gameScreen.openTab(GameScreen.TAB_INVENTORY);
- sleep(random(310, 610));
- final Point invPoint = new Point(random(558, 723), random(215, 440));
- moveMouse(invPoint);
- return random(510, 1300);
- } else {
- final int random = random(0, 10);
- final Point rndPoint = new Point(random(558, 723), random(215, 440));
- if (random == 0) {
- if (gameScreen.getCurrentTab() != GameScreen.TAB_STATS) {
- gameScreen.openTab(GameScreen.TAB_STATS);
- sleep(random(310, 610));
- }
- moveMouse(rndPoint);
- return random(200, 2300);
- } else if (random >= 1 && random <= 6) {
- final int randomTab = random(0, 13);
- if (randomTab != gameScreen.getCurrentTab()) {
- gameScreen.openTab(random(0, 13));
- sleep(random(310, 610));
- }
- moveMouse(rndPoint);
- return random(300, 1200);
- } else {
- final int randomTab = random(0, 13);
- if (randomTab != gameScreen.getCurrentTab()) {
- gameScreen.openTab(random(0, 13));
- return random(310, 1200);
- }
- }
- }
- case 1:
- Point randomMouse = null;
- final int rndMovement = random(1, 5);
- for (int a = 0; a < rndMovement; a++) {
- randomMouse = new Point(random(15, 730), random(15, 465));
- moveMouse(randomMouse);
- sleep(random(50, 800));
- }
- return random(130, 810);
- case 2:
- final int currentAngle = botEnv.camera.getAngle();
- switch (random(0, 1)) {
- case 0:
- botEnv.camera.setAngle(currentAngle + random(0, 650));
- return random(710, 1100);
- case 1:
- botEnv.camera.setAngle(currentAngle - random(0, 650));
- return random(710, 1100);
- }
- case 3:
- int currentAngle2 = botEnv.camera.getAngle();
- switch (random(0, 1)) {
- case 0:
- botEnv.camera.setAngle(currentAngle2 + random(0, 650));
- return random(410, 1130);
- case 1:
- botEnv.camera.setAngle(currentAngle2 - random(0, 650));
- return random(410, 1130);
- }
- case 4:
- return random(310, 1400);
- case 5:
- if (currentNPC != null && getMyPlayer().getInteracting() != null) {
- botEnv.camera.setAngleTo(currentNPC.getLocation());
- return random(120, 1300);
- } else {
- currentAngle2 = botEnv.camera.getAngle();
- switch (random(0, 1)) {
- case 0:
- botEnv.camera.setAngle(currentAngle2 + random(0, 650));
- return random(410, 1130);
- case 1:
- botEnv.camera.setAngle(currentAngle2 - random(0, 650));
- return random(410, 1130);
- }
- }
- }
- return random(100, 200);
- }
- public boolean onStart() {
- rangeStartExp = skills.getExperience(Skills.SKILL_RANGE);
- hitpointStartExp = skills.getExperience(Skills.SKILL_HITPOINTS);
- return true;
- }
- public String getName() {
- return "King Lathas Orge Ranger";
- }
- public String getAuthor() {
- return "Kohta && Fatality";
- }
- public String getDescription() {
- return "Kills Orges using range at the training camp.";
- }
- public int getRealLevel(int skill) {
- int exp = skills.getExperience(skill);
- for(int i = 0; i < expTable.length; i++)
- if(exp < expTable[i])
- return i-1;
- return 99;
- }
- public int getRealExperienceToNextLevel(int skill) {
- int level = getRealLevel(skill);
- if(level == -1)
- return -1;
- if(level == 99)
- return 0;
- int experience = skills.getExperience(skill);
- int needed = expTable[level+1];
- return needed - experience;
- }
- private static final int[] expTable = {
- 0 , 0, 83, 174, 276, 388, 512, 650, 801,
- 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973,
- 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031,
- 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408,
- 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127,
- 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636,
- 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599,
- 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445,
- 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200,
- 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594,
- 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253,
- 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431
- };
- public int getPercentageToNextLevel2(int skill){
- int level = skills.getLevel(skill);
- if(level == -1)
- return -1;
- if(level == 99)
- return 0;
- int experience = skills.getExperience(skill);
- int needed = expTable[level+1];
- int lastLvl = expTable[level];
- double notYet = (double)(needed - experience) / (double)(experience - lastLvl)* (double)100;
- return (int)notYet;
- }
- public void onRepaint(Graphics g) {
- long runTime = System.currentTimeMillis() - startTime;
- int secs = ((int) ((runTime / 1000) % 60));
- int mins = ((int) (((runTime / 1000) / 60) % 60));
- int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
- int RANGE_CUR_LEVEL = skills.getLevel(Skills.SKILL_RANGE);
- int rangeNegativeExp = skills.getExperience(Skills.SKILL_RANGE);
- int RNGXP_TO_LVL = skills.getExperienceToNextLevel(Skills.SKILL_RANGE);
- int RANGE_GAINED_XP = rangeNegativeExp - rangeStartExp;
- if (rangeStartExp == 0)
- rangeStartExp = skills.getExperience(Skills.SKILL_RANGE);
- int hpNegativeExp = skills.getExperience(Skills.SKILL_HITPOINTS);
- int HITPOINT_CUR_LEVEL = skills.getLevel(Skills.SKILL_HITPOINTS);
- int HITPOINT_XP_TO_LVL = skills.getExperienceToNextLevel(Skills.SKILL_HITPOINTS);
- int HITPOINT_XP_GAINED = hpNegativeExp - hitpointStartExp;
- if (hitpointStartExp == 0)
- hitpointStartExp = skills.getExperience(Skills.SKILL_HITPOINTS);
- int x = 13;
- int y = 13;
- //g.setColor(new Color(222, 64, 64, 100));
- //g.fill3DRect(x, y, 246, 230, true);
- x += 5;
- y += 15;
- g.setColor(Color.white);
- g.setFont(new Font("Lucida Grande", Font.BOLD, 11));
- y += 11;
- g.drawString("Kohta's Private Orge Ranger v2.0", x, y);
- y += 11;
- g.setColor(Color.black);
- y += 11;
- g.drawString("Run time: " + (hours < 10 ? "0" : "") + hours + ":" + (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs, x, y);
- y += 11;
- g.setColor(Color.blue);
- y += 11;
- g.drawString("Current Hitpoint level: " + HITPOINT_CUR_LEVEL, x, y);
- y += 11;
- g.drawString("Experience till next Hitpoint level: " + HITPOINT_XP_TO_LVL, x, y);
- y += 11;
- g.drawString("Hitpoint experience gained: " + HITPOINT_XP_GAINED, x, y);
- y += 11;
- g.setColor(Color.green);
- y += 11;
- g.drawString("Current Range level: " + RANGE_CUR_LEVEL, x, y);
- y += 11;
- g.drawString("Experience till next Range level: " + RNGXP_TO_LVL, x, y);
- y += 11;
- g.drawString("Range experience gained: " + RANGE_GAINED_XP, x, y);
- y += 11;
- g.drawString ((getRealExperienceToNextLevel(Skills.SKILL_RANGE)/240) + " Ogres Till Level: " + (getRealLevel(Skills.SKILL_RANGE) + 1), x, y);
- y += 11;
- int Rangepercentage = getPercentageToNextLevel2(Skills.SKILL_RANGE);
- int barsize = 15;
- int barheight = 100;
- int transparancy = 160;
- int xBar = 20;
- int yBar = 368;
- g.setColor(new Color(0, 255, 0, transparancy));
- g.fillRect(xBar, yBar, barsize, barheight);
- g.setColor(new Color(255, 0, 0, transparancy));
- g.fillRect(xBar, yBar, barsize, barheight/100*Rangepercentage);
- g.setColor(new Color(255, 255, 255, transparancy));
- g.drawRect(xBar, yBar, barsize, barheight);
- }
- public void onServerMessage(String e) {
- if (e.contains("There is no ammo left in your quiver.")) {
- log("Oh shi-! No ammo logging out!");
- gameScreen.logout();
- stopAllScripts();
- } else if (e.contains("You do not have enough law runes to cast this spell.")) {
- log("Oh shi-! Out of runes, logging out!");
- gameScreen.logout();
- stopAllScripts();
- } else if (e.contains("I can't reach that!")) {
- log("We are lost. Logging out.");
- gameScreen.logout();
- stopAllScripts();
- }
- }
- }
Add Comment
Please, Sign In to add comment