Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.scripts;
- import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
- import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
- import com.kbot2.scriptable.Script;
- import com.kbot2.scriptable.methods.Calculations;
- import com.kbot2.scriptable.methods.data.Skills;
- import com.kbot2.scriptable.methods.wrappers.Obj;
- import java.awt.*;
- /**
- * Created by IntelliJ IDEA.
- * User: Koh-Koh
- * Date: 08/06/2009
- * Time: 11:37:54 AM
- * To change this template use File | Settings | File Templates.
- */
- public class KohtaGraniteMiner extends Script implements PaintListener, ServerMessageListener {
- int NUMMINED = 0;
- int miningStartXp = 0;
- final int[] WATER_SKIN_IDS = new int[] {1823, 1825, 1827, 1829, 1831};
- long startTime = System.currentTimeMillis();
- public int loop() {
- if (getMyPlayer().getAnimation() != -1) return 100;
- if (!inventory.contains(WATER_SKIN_IDS))
- stopAllScripts();
- {
- if (inventory.getCount() == 28) {
- inventory.dropAllExcept(WATER_SKIN_IDS);
- }
- Obj rock = objects.getClosestObject(15, 10947);
- if (rock != null) {
- if (Calculations.onScreen(rock.getScreenPos())) {
- rock.doAction("mine");
- } else
- walking.walkToMM(rock.getLocation());
- }
- }
- return random(1000, 1500);
- }
- public boolean onStart() {
- miningStartXp = skills.getExperience(Skills.SKILL_MINING);
- return true;
- }
- public String getName() {
- return "Granite Smasher";
- }
- public String getAuthor() {
- return "Kohta";
- }
- public String getDescription() {
- return "Mines Granite in the desert.";
- }
- public double getVersion() { return 1.6; }
- public void onServerMessage(String e) {
- if (e.contains("You manage to quarry some granite.")) {
- NUMMINED++;
- }
- else if (e.contains("Blah blah blah")) {
- log("Oh noes we are dying! Logging out!");
- gameScreen.logout();
- stopAllScripts();
- }
- }
- 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)(experience - lastLvl) / (double)(needed - experience)* (double)100;
- log(" " +(int)notYet);
- return (int)notYet;
- }
- public void onRepaint(Graphics g) {
- if (isLoggedIn()) {
- }
- 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 miningNegativeXp = skills.getExperience(Skills.SKILL_MINING);
- int CUR_LVL = skills.getLevel(Skills.SKILL_MINING);
- int XP_TO_LVL = skills.getExperienceToNextLevel(Skills.SKILL_MINING);
- int GAINED_XP = miningStartXp - miningNegativeXp;
- int x = 13;
- int y = 210;
- //g.setColor (new Color(222, 64, 64, 100));
- //g.fill3DRect(x, y, 246, 102, true);
- x += 5;
- y += 15;
- g.setColor(Color.white);
- g.setFont(new Font("Comic Sans", Font.BOLD, 11));
- y += 11;
- g.drawString("Granite Smasher by Kohta v1.6", 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.drawString("Granite mined: " + NUMMINED, x, y);
- y += 11;
- g.drawString("Current level: " + CUR_LVL, x, y);
- y += 11;
- g.drawString("Experience till next level: " + XP_TO_LVL, x, y);
- y += 12;
- g.drawString("Experience gained: " + GAINED_XP, x, y);
- y += 12;
- g.drawString ((getRealExperienceToNextLevel(Skills.SKILL_MINING)/240) + " Granite till next level: " + (getRealLevel(Skills.SKILL_MINING) + 1), x, y);
- y += 11;
- int Rangepercentage = getPercentageToNextLevel2(Skills.SKILL_MINING);
- int barsize = 15;
- int barheight = 100;
- int transparancy = 160;
- int xBar = 25;
- int yBar = 70;
- 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, Rangepercentage);
- g.setColor(new Color(255, 255, 255, transparancy));
- g.drawRect(xBar, yBar, barsize, barheight);
- }
- }
Add Comment
Please, Sign In to add comment