Advertisement
LucasSousa

Untitled

Mar 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.Color;
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Graphics2D;
  5. import java.awt.Image;
  6. import java.awt.Point;
  7. import java.io.IOException;
  8. import java.net.URL;
  9. import java.util.ArrayList;
  10.  
  11. import javax.imageio.ImageIO;
  12.  
  13. import com.rarebot.event.listeners.PaintListener;
  14. import com.rarebot.script.Script;
  15. import com.rarebot.script.ScriptManifest;
  16. import com.rarebot.script.methods.Skills;
  17. import com.rarebot.script.util.Timer;
  18. import com.rarebot.script.wrappers.RSArea;
  19. import com.rarebot.script.wrappers.RSGroundItem;
  20. import com.rarebot.script.wrappers.RSNPC;
  21. import com.rarebot.script.wrappers.RSTile;
  22.  
  23. @ScriptManifest(authors = { "Swipe" }, name = "ExtremeHunter")
  24. public class ExtremeHunter extends Script implements PaintListener {
  25.     // START: Code generated using Enfilade's Easel
  26.     private Image getImage(String url) {
  27.         try {
  28.             return ImageIO.read(new URL(url));
  29.         } catch (IOException e) {
  30.             return null;
  31.         }
  32.     }
  33.  
  34.     private final int GREY_CHIN = 5079;
  35.     private final int trapItem = 10008;
  36.     private final int trapFailed = 19192;
  37.     private final int trapCaught = 19190;
  38.     private final int trapSetup = 19187;
  39.     public final RSArea maBANK = new RSArea(new RSTile[] {
  40.             new RSTile(2399, 2845), new RSTile(2399, 2838),
  41.             new RSTile(2405, 2838), new RSTile(2405, 2844) });
  42.     public final RSArea C_SWIFT = new RSArea(new RSTile[] {
  43.             new RSTile(2606, 2933), new RSTile(2602, 2914),
  44.             new RSTile(2606, 2910), new RSTile(2616, 2918),
  45.             new RSTile(2622, 2927), new RSTile(2615, 2935) });
  46.     public final RSArea T_WAGTAIL = new RSArea(new RSTile[] {
  47.             new RSTile(2518, 2901), new RSTile(2520, 2917),
  48.             new RSTile(2507, 2917), new RSTile(2507, 2904) });
  49.     public final RSArea G_CHIN = new RSArea(new RSTile[] {
  50.             new RSTile(2345, 3540), new RSTile(2345, 3540),
  51.             new RSTile(2345, 3526), new RSTile(2357, 3526),
  52.             new RSTile(2353, 3533), new RSTile(2358, 3540) });
  53.     public final RSArea R_CHIN = new RSArea(new RSTile[] {
  54.             new RSTile(2517, 2905), new RSTile(2516, 2886),
  55.             new RSTile(2542, 2886), new RSTile(2539, 2902) });
  56.     private final Image img1 = getImage("http://i.imgur.com/JlOte.png");
  57.     // private final Image troll =
  58.     // getImage("http://revolushii.ro/forum/Smileys/smileys/trollface.png");
  59.     private String status = "Hunting";
  60.     private int expGain = 0;
  61.     private final int raw_meat = 9978;
  62.     private final int BIRD_SNARE = 10006;
  63.     private final int SET_SNARE = 19175;
  64.     private final int[] DONE_SNARE = { 19180, 19178 };
  65.     private final int C_SWIFT_ID = 5073;
  66.     private final int T_WAG_ID = 5072;
  67.     private final int trapID = 10008;
  68.  
  69.     int startLevel;
  70.     private int fail = 300;
  71.  
  72.     private boolean banking;
  73.     private ArrayList<RSTile> mySnares = new ArrayList<RSTile>();
  74.     private long startTime;
  75.     RSTile mainTrap;
  76.     int startExp;
  77.     public Job[] jobs = getJobs();
  78.     final int butterflyJar = 10012;
  79.     final int[] dropIDs = { 9978, 10115, 10125, 10127 }, buryIDs = { 526 },
  80.             releaseIDs = { 10149, 10146, 10147, 10148, 10092 }, trapIDs = {
  81.                     10006, 10008, 303, 954, 19965 }, layedTraps = { 19187,
  82.                     19175, 19678, 19650, 19662 }, failedTraps = { 19192, 19174,
  83.                     56813 }, layTrapHere = { 19679, 19652, 19663 },
  84.             collapsedTraps = { 19190, 19180, 19178, 19182, 19189, 19675, 19186,
  85.                     19654, 19659, 19184, 56819, 19191, 56821 },
  86.             catchedButterflies = { 10014, 10016, 10018, 10020 },
  87.             falconTargets = { 5098, 5099, 5100 }, falconSuccessful = { 5094,
  88.                     5095, 5096 };
  89.     RSTile startLoc, clickedFalcon;
  90.     Image Background, Background2, Show, turnOffImage, startImg;
  91.     boolean[] huntTrap = { false, false, false, false, true, false, false,
  92.             false, false };
  93.     RSTile[] traps = { null, null, null, null, null }, notMyFalcons = { null,
  94.             null, null, null, null };
  95.     int[] objAt = { 0, 0, 0, 0, 0 }, trapsX = { 0, 0, 0, 0, 0 }, trapsY = { 0,
  96.             0, 0, 0, 0 }, butterflyIDs = { 5082, 5084, 5085 },
  97.             butterflyIDs2 = { 5082, 5083, 5084, 5085 };
  98.     int[] jujuPot = { 20026, 20025, 20024, 20023 };
  99.     /* Defining areas */
  100.     final int[] bankArea = { 3507, 3475, 3513, 3483 }, swampLizardArea = {
  101.             3533, 3432, 3581, 3454 }, orangeSalamanderArea = { 3398, 3072,
  102.             3422, 3151 }, redSalamanderArea = { 2440, 3210, 2482, 3261 },
  103.             falconryArea = { 2364, 3573, 2392, 3619 };
  104.     final int[][] swampLizard = { { 3546, 3437, 3555, 3443 },
  105.             { 3547, 3448, 3558, 3454 }, { 3535, 3450, 3539, 3452 } },
  106.             orangeSalamander = { { 3410, 3072, 3417, 3079 },
  107.                     { 3408, 3080, 3413, 3083 }, { 3402, 3086, 3412, 3094 },
  108.                     { 3400, 3099, 3406, 3102 }, { 3401, 3131, 3410, 3136 } },
  109.             redSalamander = { { 2466, 3234, 2480, 3246 },
  110.                     { 2445, 3220, 2452, 3228 }, { 2450, 3216, 2456, 3222 } },
  111.             butterflyAreas = { { 2537, 2898, 2570, 2917 },
  112.                     { 2306, 3506, 2361, 3621 }, { 2690, 3758, 2747, 3802 },
  113.                     { 2702, 3803, 2740, 3838 } },
  114.             butterflyStartingLocations = { { 2558, 2910 }, { 2322, 3600 },
  115.                     { 2714, 3792 }, { 2711, 3822 } };
  116.  
  117.     private void drawTile(Graphics render, RSTile tile, Color color) {
  118.         Point southwest = calc.tileToScreen(tile, 0, 0, 0);
  119.         Point southeast = calc.tileToScreen(
  120.                 new RSTile(tile.getX() + 1, tile.getY()), 0, 0, 0);
  121.         Point northwest = calc.tileToScreen(new RSTile(tile.getX(),
  122.                 tile.getY() + 1), 0, 0, 0);
  123.         Point northeast = calc.tileToScreen(
  124.                 new RSTile(tile.getX() + 1, tile.getY() + 1), 0, 0, 0);
  125.  
  126.         if (calc.pointOnScreen(southwest) && calc.pointOnScreen(southeast)
  127.                 && calc.pointOnScreen(northwest)
  128.                 && calc.pointOnScreen(northeast)) {
  129.             render.setColor(Color.BLACK);
  130.             render.drawPolygon(new int[] { (int) northwest.getX(),
  131.                     (int) northeast.getX(), (int) southeast.getX(),
  132.                     (int) southwest.getX() },
  133.                     new int[] { (int) northwest.getY(), (int) northeast.getY(),
  134.                             (int) southeast.getY(), (int) southwest.getY() }, 4);
  135.             render.setColor(color);
  136.             render.fillPolygon(new int[] { (int) northwest.getX(),
  137.                     (int) northeast.getX(), (int) southeast.getX(),
  138.                     (int) southwest.getX() },
  139.                     new int[] { (int) northwest.getY(), (int) northeast.getY(),
  140.                             (int) southeast.getY(), (int) southwest.getY() }, 4);
  141.         }
  142.     }
  143.  
  144.     public void onRepaint(Graphics g1) {
  145.         Graphics2D g = (Graphics2D) g1;
  146.         g.drawImage(img1, 0, 336, null);
  147.         g.setColor(Color.black);
  148.         g.setFont(new Font("Arial", 0, 12));
  149.         g.drawString(status, 108, 395);
  150.         expGain = skills.getCurrentExp(Skills.HUNTER) - startExp;
  151.         g.drawString(expGain + " (+"
  152.                 + (skills.getRealLevel(Skills.HUNTER) - startLevel) + ") ",
  153.                 148, 418);
  154.         if (ChinTraps != null) {
  155.             if (getCurrentJob().reqLevel() == 53) {
  156.                 g.drawString(
  157.                         (skills.getCurrentExp(Skills.HUNTER) - startExp)
  158.                                 / 198
  159.                                 + " Chins = "
  160.                                 + ((skills.getCurrentExp(Skills.HUNTER) - startExp) / 198)
  161.                                 * 655 + " gp", 250, 410);
  162.             } else {
  163.                 g.drawString(
  164.                         (skills.getCurrentExp(Skills.HUNTER) - startExp)
  165.                                 / 255
  166.                                 + " Chins = "
  167.                                 + ((skills.getCurrentExp(Skills.HUNTER) - startExp) / 255)
  168.                                 * 905 + " gp", 250, 410);
  169.             }
  170.         }
  171.         g.drawString(
  172.                 ""
  173.                         + (int) (((expGain)) * 3600000D / (System
  174.                                 .currentTimeMillis() - startTime)) + " (+"
  175.                         + (skills.getRealLevel(Skills.HUNTER) - startLevel)
  176.                         * 3600000D / (System.currentTimeMillis() - startTime)
  177.                         + ") ", 112, 435);
  178.         g.drawString(
  179.                 Timer.format(skills.getTimeTillNextLevel(Skills.HUNTER,
  180.                         (int) ((skills.getRealLevel(Skills.HUNTER) - startLevel) * 3600000D / (System
  181.                                 .currentTimeMillis() - startTime)), System.currentTimeMillis() - startTime))
  182.                         + "  ||  Total Time: "
  183.                         + Timer.format(System.currentTimeMillis() - startTime),
  184.                 180, 454);
  185.         g.setColor(new Color(250, 20, 20, 180));
  186.         g.fillRoundRect(245, 385, 196, 12, 16, 16);
  187.         g.setColor(new Color(20, 220, 20, 180));
  188.         g.fillRoundRect(
  189.                 245,
  190.                 385,
  191.                 (int) ((int) skills.getPercentToNextLevel(Skills.HUNTER) * 1.96),
  192.                 12, 16, 16);
  193.         g.setColor(Color.BLACK);
  194.         g.drawString(
  195.                 skills.getPercentToNextLevel(Skills.HUNTER) + "% to Level "
  196.                         + (skills.getCurrentLevel(Skills.HUNTER) + 1)
  197.                         + " Hunter - ("
  198.                         + skills.getExpToNextLevel(Skills.HUNTER) + ")", 250,
  199.                 395);
  200.         Point mLoc = mouse.getLocation();
  201.         g.setColor(new Color(20, 230, 40, 180));
  202.         g.drawLine(mLoc.x, 0, mLoc.x, 502);
  203.         g.drawLine(0, mLoc.y, 764, mLoc.y);
  204.         for (RSTile t : mySnares) {
  205.             drawTile(g, t, new Color(200, 200, 200, 100));
  206.             g.fillRect(calc.tileToMinimap(t).x, calc.tileToMinimap(t).y, 4, 4);
  207.             g.setColor(new Color(30, 220, 80, 120));
  208.             // objects.getTopAt(t).getModel().drawWireFrame(g);
  209.         }
  210.         RSNPC[] bird = npcs.getAll(C_SWIFT_ID, T_WAG_ID);
  211.         for (int i = 0; i < mySnares.size(); i++) {
  212.             for (RSNPC npc : bird) {
  213.                 g.drawLine(calc.tileToMinimap(npc.getLocation()).x,
  214.                         calc.tileToMinimap(npc.getLocation()).y,
  215.                         calc.tileToMinimap(mySnares.get(i)).x,
  216.                         calc.tileToMinimap(mySnares.get(i)).y);
  217.                 g.setColor(Color.WHITE);
  218.                 if (npc.isOnScreen()) {
  219.                     // g.drawImage(troll, npc.getModel().getPointOnScreen().x,
  220.                     // npc
  221.                     // .getModel().getPointOnScreen().y, null);
  222.                     g.drawString(
  223.                             "Distance (Trap "
  224.                                     + (i + 1)
  225.                                     + ")"
  226.                                     + ": "
  227.                                     + calc.distanceBetween(npc.getLocation(),
  228.                                             mySnares.get(i)), npc.getModel()
  229.                                     .getPointOnScreen().x, npc.getModel()
  230.                                     .getPointOnScreen().y + (i * 8));
  231.                 }
  232.             }
  233.         }
  234.         if (fail < 300) {
  235.             g.drawString("FUCK! WE FAILED", 10, 10);
  236.             fail++;
  237.         }
  238.         if (ChinTraps != null) {
  239.             for (RSTile t : ChinTraps) {
  240.                 switch (objects.getTopAt(t).getID()) {
  241.                 case trapSetup:
  242.                     drawTile(g, t, Transparent(Color.YELLOW, 80));
  243.                     break;
  244.                 case trapFailed:
  245.                     drawTile(g, t, Transparent(Color.RED, 80));
  246.                     break;
  247.                 case 19189:
  248.                     drawTile(g, t, Transparent(Color.GREEN, 80));
  249.                     break;
  250.                 case 19190:
  251.                     drawTile(g, t, Transparent(Color.GREEN, 80));
  252.                     break;
  253.                 }
  254.             }
  255.         }
  256.     }
  257.  
  258.     private Color Transparent(Color c, int trans) {
  259.         return new Color(c.getRed(), c.getGreen(), c.getBlue(), trans);
  260.     }
  261.  
  262.     private int getMaxTrapAmount() {
  263.         int lvl = skills.getRealLevel(skills.HUNTER);
  264.         if (lvl >= 80) {
  265.             return 5;
  266.         } else if (lvl >= 60) {
  267.             return 4;
  268.         } else if (lvl >= 40) {
  269.             return 3;
  270.         } else if (lvl >= 20) {
  271.             return 2;
  272.         }
  273.         return 1;
  274.     }
  275.  
  276.     private RSTile MainTrap;
  277.  
  278.     private RSTile[] getWagTraps() {
  279.         switch (getMaxTrapAmount()) {
  280.         case 2:
  281.             return new RSTile[] {
  282.                     getMyPlayer().getLocation(),
  283.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  284.                             getMyPlayer().getLocation().getY() - 1) };
  285.         case 3:
  286.             return new RSTile[] {
  287.                     getMyPlayer().getLocation(),
  288.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  289.                             getMyPlayer().getLocation().getY() + 1),
  290.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  291.                             getMyPlayer().getLocation().getY() - 1) };
  292.         }
  293.         return null;
  294.     }
  295.  
  296.     private RSTile[] getChinTraps() {
  297.         switch (getMaxTrapAmount()) {
  298.         case 3:
  299.             return new RSTile[] {
  300.                     getMyPlayer().getLocation(),
  301.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  302.                             getMyPlayer().getLocation().getY() + 1),
  303.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  304.                             getMyPlayer().getLocation().getY() - 1) };
  305.         case 4:
  306.             return new RSTile[] {
  307.                     getMyPlayer().getLocation(),
  308.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  309.                             getMyPlayer().getLocation().getY() + 1),
  310.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  311.                             getMyPlayer().getLocation().getY() - 1),
  312.                     new RSTile(getMyPlayer().getLocation().getX() - 2,
  313.                             getMyPlayer().getLocation().getY()) };
  314.         case 5:
  315.             return new RSTile[] {
  316.                     getMyPlayer().getLocation(),
  317.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  318.                             getMyPlayer().getLocation().getY() - 1),
  319.                     new RSTile(getMyPlayer().getLocation().getX() - 1,
  320.                             getMyPlayer().getLocation().getY() + 1),
  321.                     new RSTile(getMyPlayer().getLocation().getX() + 1,
  322.                             getMyPlayer().getLocation().getY() + 1),
  323.                     new RSTile(getMyPlayer().getLocation().getX() + 1,
  324.                             getMyPlayer().getLocation().getY() - 1) };
  325.         }
  326.         return null;
  327.     }
  328.  
  329.     private RSTile[] WagTraps;
  330.     private RSTile[] ChinTraps;
  331.  
  332.     private Job[] getJobs() {
  333.         Action snareWalkBank = new Action() {
  334.             private int DUEL_RING;
  335.  
  336.             boolean activate() {
  337.                 return inventory.getCount(BIRD_SNARE) == 0;
  338.             }
  339.  
  340.             void run() {
  341.                 banking = true;
  342.                 equipment.getItem(DUEL_RING).interact("rub");
  343.                 mouse.click(
  344.                         interfaces.getAllContaining("Mobil")[0].getLocation(),
  345.                         true);
  346.                 web.getWeb(maBANK.getCentralTile()).step();
  347.             }
  348.         };
  349.         Action snareBank = new Action() {
  350.             boolean activate() {
  351.                 return banking == true
  352.                         && maBANK.contains(getMyPlayer().getLocation());
  353.             }
  354.  
  355.             void run() {
  356.                 if (!bank.isOpen()) {
  357.                     bank.open();
  358.                 } else if (bank.isOpen()) {
  359.                     // If the bone is not null, withdraw it
  360.                     if (bank.getItem(BIRD_SNARE) != null) {
  361.                         bank.withdraw(BIRD_SNARE, 24);
  362.                         bank.close();
  363.                     }
  364.                     // If the bird snare is null, stop the script
  365.                     else {
  366.                         log("You have no snares in the bank, stopping script!");
  367.                         env.saveScreenshot(true);
  368.                         stopScript();
  369.                     }
  370.                 }
  371.             }
  372.         };
  373.         Action placeSnare = new Action() {
  374.             boolean activate() {
  375.                 return mySnares.size() < getMaxTrapAmount();
  376.             }
  377.  
  378.             void run() {
  379.                 if (MainTrap == null
  380.                         || !getCurrentJob().mainArea().contains(MainTrap)) {
  381.                     MainTrap = getMyPlayer().getLocation();
  382.                 }
  383.                 while (calc.distanceTo(MainTrap) > 0) {
  384.                     walking.walkTileOnScreen(MainTrap);
  385.                 }
  386.                 mySnares.add(MainTrap);
  387.                 inventory.getItem(BIRD_SNARE).doClick(true);
  388.                 sleep(5000);
  389.  
  390.             }
  391.         };
  392.         Action collectSnare = new Action() {
  393.  
  394.             boolean activate() {
  395.                 for (RSTile t : mySnares) {
  396.                     if (objects.getTopAt(t) != null
  397.                             && objects.getTopAt(t).getID() == DONE_SNARE[0]) {
  398.                         MainTrap = t;
  399.                         return true;
  400.                     }
  401.                 }
  402.                 return false;// TODO
  403.             }
  404.  
  405.             void run() {
  406.                 objects.getTopAt(MainTrap).doClick();
  407.                 sleep(500);
  408.                 expGain += 34;
  409.                 mySnares.remove(MainTrap);
  410.             }
  411.         };
  412.  
  413.         Action fallenSnare = new Action() {
  414.             boolean activate() {
  415.                 RSGroundItem g = groundItems.getNearest(BIRD_SNARE);
  416.                 if (g != null) {
  417.                     for (RSTile t : mySnares) {
  418.                         if (g.getLocation().equals(t))
  419.                             return true;
  420.                     }
  421.                 }
  422.                 return false;
  423.             }
  424.  
  425.             void run() {
  426.                 RSGroundItem k = groundItems.getNearest(BIRD_SNARE);
  427.                 if (k != null)
  428.                     k.interact("Lay");
  429.                 sleep(2000);
  430.             }
  431.         };
  432.  
  433.         Job CRIMSON_SWIFTS = new Job() {
  434.             int reqLevel() {
  435.                 return 1;
  436.             }
  437.  
  438.             int endLevel() {
  439.                 return 20;
  440.             }
  441.  
  442.             public RSArea mainArea() {
  443.                 return C_SWIFT;
  444.  
  445.             }
  446.         };
  447.         CRIMSON_SWIFTS.Steps.add(placeSnare);
  448.         CRIMSON_SWIFTS.Steps.add(collectSnare);
  449.         CRIMSON_SWIFTS.Steps.add(fallenSnare);
  450.         // //////////////////////////////////////////////////////////////////
  451.         Action fallenWagSnare = new Action() {
  452.             RSTile Next;
  453.  
  454.             boolean activate() {
  455.                 RSGroundItem g = groundItems.getNearest(BIRD_SNARE);
  456.                 if (g != null) {
  457.                     for (RSTile t : mySnares) {
  458.                         if (g.getLocation().equals(t)) {
  459.                             if (objects.getTopAt(t) == null) {
  460.                                 if (mySnares.size() == getMaxTrapAmount()) {
  461.                                     Next = t;
  462.                                     return true;
  463.                                 }
  464.                             }
  465.                         }
  466.                     }
  467.                 }
  468.                 return false;
  469.             }
  470.  
  471.             void run() {
  472.                 RSGroundItem k = groundItems.getNearest(BIRD_SNARE);
  473.                 if (k != null)
  474.                     k.interact("Lay");
  475.                 sleep(2000);
  476.             }
  477.         };
  478.         Action placeWagSnare = new Action() {
  479.             boolean activate() {
  480.                 return mySnares.size() < getMaxTrapAmount();
  481.             }
  482.  
  483.             void run() {
  484.                 RSTile Next = null;
  485.                 if (WagTraps == null || WagTraps.length < getMaxTrapAmount()) {
  486.                     WagTraps = getWagTraps();
  487.                 }
  488.                 for (RSTile t : WagTraps) {
  489.                     if (objects.getTopAt(t) == null) {
  490.                         Next = t;
  491.                         break;
  492.                     }
  493.                 }
  494.                 if (Next != null) {
  495.                     while (calc.distanceTo(Next) > 0) {
  496.                         walking.walkTileOnScreen(Next);
  497.                         sleep(1000);
  498.                     }
  499.                     mySnares.add(Next);
  500.                     inventory.getItem(BIRD_SNARE).doClick(true);
  501.                     sleep(6000);
  502.                 }
  503.             }
  504.         };
  505.         Action collectWagSnare = new Action() {
  506.             RSTile Next;
  507.  
  508.             boolean activate() {
  509.                 for (RSTile t : WagTraps) {
  510.                     if (objects.getTopAt(t) != null
  511.                             && objects.getTopAt(t).getID() == DONE_SNARE[1]) {
  512.                         Next = t;
  513.                         return true;
  514.                     }
  515.                 }
  516.                 return false;// TODO
  517.             }
  518.  
  519.             void run() {
  520.                 objects.getTopAt(Next).doClick();
  521.                 sleep(500);
  522.                 expGain += 96;
  523.                 sleep(500);
  524.                 mySnares.remove(Next);
  525.             }
  526.         };
  527.         Action dropJunk = new Action() {
  528.  
  529.             boolean activate() {
  530.                 return inventory.containsOneOf(526, raw_meat);
  531.             }
  532.  
  533.             void run() {
  534.                 inventory.dropItem(526);
  535.                 inventory.dropItem(raw_meat);
  536.                 sleep(500);
  537.             }
  538.         };
  539.         Action failSafe = new Action() {
  540.  
  541.             boolean activate() {
  542.                 for (RSTile t : WagTraps) {
  543.                     for (RSGroundItem rg : groundItems.getAllAt(t)) {
  544.                         if (rg.getItem().getID() == BIRD_SNARE) {
  545.                             if (objects.getTopAt(t) != null) {
  546.                                 rg.interact("take");
  547.                             }
  548.                         }
  549.                     }
  550.                 }
  551.                 return false;
  552.             }
  553.  
  554.             void run() {
  555.                 log("We fucking failed. Probabaly going crazy with the traps...");
  556.                 fail = 0;
  557.             }
  558.         };
  559.         Job TROPICAL_WAGTAIL = new Job() {
  560.             int reqLevel() {
  561.                 return 20;
  562.             }
  563.  
  564.             int endLevel() {
  565.                 return 53;
  566.             }
  567.  
  568.             public RSArea mainArea() {
  569.                 return T_WAGTAIL;
  570.  
  571.             }
  572.         };
  573.         TROPICAL_WAGTAIL.Steps.add(placeWagSnare);
  574.         TROPICAL_WAGTAIL.Steps.add(collectWagSnare);
  575.         TROPICAL_WAGTAIL.Steps.add(fallenWagSnare);
  576.         TROPICAL_WAGTAIL.Steps.add(dropJunk);
  577.         TROPICAL_WAGTAIL.Steps.add(failSafe);
  578.         CRIMSON_SWIFTS.Steps.add(dropJunk);
  579.         Action setTrap = new Action() {
  580.             RSTile Next = null;
  581.  
  582.             boolean activate() {
  583.                 if (ChinTraps == null) {
  584.                     ChinTraps = getChinTraps();
  585.                 }
  586.                 for (RSTile t : ChinTraps) {
  587.                     if (objects.getTopAt(t) == null) {
  588.                         Next = t;
  589.                         return true;
  590.                     }
  591.                 }
  592.                 return false;
  593.             }
  594.  
  595.             void run() {
  596.                 if (Next != null) {
  597.                     while (calc.distanceTo(Next) > 0) {
  598.                         walking.walkTileOnScreen(Next);
  599.                         sleep(1000);
  600.                     }
  601.                     if (groundItems.getAllAt(Next).length == 0) {
  602.                         inventory.getItem(trapItem).doClick(true);
  603.                     } else {
  604.                         groundItems.getAllAt(Next)[0].interact("Lay");
  605.                     }
  606.                     sleep(6000);
  607.                 }
  608.             }
  609.         };
  610.         Action takeTrap = new Action() {
  611.             RSTile Next = null;
  612.  
  613.             boolean activate() {
  614.                 for (RSTile t : ChinTraps) {
  615.                     if (objects.getTopAt(t) != null) {
  616.                         if (objects.getTopAt(t).getID() == 19189) {
  617.                             Next = t;
  618.                             return true;
  619.                         }
  620.                     }
  621.                 }
  622.                 return false;
  623.             }
  624.  
  625.             void run() {
  626.                 if (Next != null) {
  627.                     if (objects.getTopAt(Next).getID() == 19189) {
  628.                         objects.getTopAt(Next).doClick();
  629.                         sleep(2000);
  630.                     }
  631.                 }
  632.             }
  633.         };
  634.         Action takefailTrap = new Action() {
  635.             RSTile Next = null;
  636.  
  637.             boolean activate() {
  638.                 for (RSTile t : ChinTraps) {
  639.                     if (objects.getTopAt(t) != null) {
  640.                         if (objects.getTopAt(t).getID() == trapFailed) {
  641.                             Next = t;
  642.                             return true;
  643.                         }
  644.                     }
  645.                 }
  646.                 return false;
  647.             }
  648.  
  649.             void run() {
  650.                 if (Next != null) {
  651.                     if (objects.getTopAt(Next).getID() == trapFailed) {
  652.                         objects.getTopAt(Next).doClick();
  653.                         sleep(2000);
  654.                     }
  655.                 }
  656.             }
  657.         };
  658.         //
  659.         Action takefail = new Action() {
  660.             RSTile Next = null;
  661.  
  662.             boolean activate() {
  663.                 for (RSTile t : ChinTraps) {
  664.                     if (groundItems.getAllAt(t) != null) {
  665.                         if (groundItems.getAllAt(t).length > 0) {
  666.                             if (groundItems.getAllAt(t)[0].getItem().getID() == trapSetup) {
  667.                                 Next = t;
  668.                                 return true;
  669.                             }
  670.                         }
  671.                     }
  672.                 }
  673.                 return false;
  674.             }
  675.  
  676.             void run() {
  677.                 if (Next != null) {
  678.                     if (groundItems.getAllAt(Next) != null
  679.                             && groundItems.getAllAt(Next)[0] != null) {
  680.                         groundItems.getAllAt(Next)[0].interact("take");
  681.                     }
  682.                 }
  683.  
  684.             }
  685.         };
  686.         Job GREY_CHIN = new Job() {
  687.             int reqLevel() {
  688.                 return 53;
  689.             }
  690.  
  691.             int endLevel() {
  692.                 return 63;// change once red is coded
  693.             }
  694.  
  695.             public RSArea mainArea() {
  696.                 return G_CHIN;
  697.  
  698.             }
  699.         };
  700.         GREY_CHIN.Steps.add(setTrap);
  701.         GREY_CHIN.Steps.add(takeTrap);
  702.         GREY_CHIN.Steps.add(takefail);
  703.         GREY_CHIN.Steps.add(takefailTrap);
  704.         // ////////////////////////////////////////
  705.         Action setRTrap = new Action() {
  706.             RSTile Next = null;
  707.  
  708.             boolean activate() {
  709.                 if (ChinTraps == null) {
  710.                     ChinTraps = getChinTraps();
  711.                 }
  712.                 for (RSTile t : ChinTraps) {
  713.                     if (objects.getTopAt(t) == null) {
  714.                         Next = t;
  715.                         return true;
  716.                     }
  717.                 }
  718.                 return false;
  719.             }
  720.  
  721.             void run() {
  722.                 if (Next != null) {
  723.                     while (calc.distanceTo(Next) > 0) {
  724.                         walking.walkTileOnScreen(Next);
  725.                         sleep(1000);
  726.                     }
  727.                     if (groundItems.getAllAt(Next).length == 0) {
  728.                         inventory.getItem(trapItem).doClick(true);
  729.                     } else {
  730.                         groundItems.getAllAt(Next)[0].interact("Lay");
  731.                     }
  732.                     sleep(6000);
  733.                 }
  734.             }
  735.         };
  736.         Action takeRTrap = new Action() {
  737.             RSTile Next = null;
  738.  
  739.             boolean activate() {
  740.                 for (RSTile t : ChinTraps) {
  741.                     if (objects.getTopAt(t) != null) {
  742.                         if (objects.getTopAt(t).getID() == 19190) {
  743.                             Next = t;
  744.                             return true;
  745.                         }
  746.                     }
  747.                 }
  748.                 return false;
  749.             }
  750.  
  751.             void run() {
  752.                 if (Next != null) {
  753.                     if (objects.getTopAt(Next).getID() == 19190) {
  754.                         objects.getTopAt(Next).doClick();
  755.                         sleep(2000);
  756.                     }
  757.                 }
  758.             }
  759.         };
  760.         Action takeRfailTrap = new Action() {
  761.             RSTile Next = null;
  762.  
  763.             boolean activate() {
  764.                 for (RSTile t : ChinTraps) {
  765.                     if (objects.getTopAt(t) != null) {
  766.                         if (objects.getTopAt(t).getID() == trapFailed) {
  767.                             Next = t;
  768.                             return true;
  769.                         }
  770.                     }
  771.                 }
  772.                 return false;
  773.             }
  774.  
  775.             void run() {
  776.                 if (Next != null) {
  777.                     if (objects.getTopAt(Next).getID() == trapFailed) {
  778.                         objects.getTopAt(Next).doClick();
  779.                         sleep(2000);
  780.                     }
  781.                 }
  782.             }
  783.         };
  784.         //
  785.         Action takeRfail = new Action() {
  786.             RSTile Next = null;
  787.  
  788.             boolean activate() {
  789.                 for (RSTile t : ChinTraps) {
  790.                     if (groundItems.getAllAt(t) != null) {
  791.                         if (groundItems.getAllAt(t).length > 0) {
  792.                             if (groundItems.getAllAt(t)[0].getItem().getID() == trapSetup) {
  793.                                 Next = t;
  794.                                 return true;
  795.                             }
  796.                         }
  797.                     }
  798.                 }
  799.                 return false;
  800.             }
  801.  
  802.             void run() {
  803.                 if (Next != null) {
  804.                     if (groundItems.getAllAt(Next) != null
  805.                             && groundItems.getAllAt(Next)[0] != null) {
  806.                         groundItems.getAllAt(Next)[0].interact("take");
  807.                     }
  808.                 }
  809.  
  810.             }
  811.         };
  812.         Job RED_CHIN = new Job() {
  813.             int reqLevel() {
  814.                 return 63;
  815.             }
  816.  
  817.             int endLevel() {
  818.                 return 99;// change once red is coded
  819.             }
  820.  
  821.             public RSArea mainArea() {
  822.                 return R_CHIN;
  823.  
  824.             }
  825.         };
  826.         RED_CHIN.Steps.add(setRTrap);
  827.         RED_CHIN.Steps.add(takeRTrap);
  828.         RED_CHIN.Steps.add(takeRfail);
  829.         RED_CHIN.Steps.add(takeRfailTrap);
  830.         Job[] temp = { CRIMSON_SWIFTS, TROPICAL_WAGTAIL, GREY_CHIN, RED_CHIN };
  831.         return temp;
  832.     }
  833.  
  834.     // END: Code generated using Enfilade's Easel
  835.     public boolean onStart() {
  836.         startTime = System.currentTimeMillis();
  837.         startLevel = skills.getRealLevel(Skills.HUNTER);
  838.         startExp = skills.getCurrentExp(Skills.HUNTER);
  839.         // new Scanner();
  840.         return true;
  841.     }
  842.  
  843.     @Override
  844.     public int loop() {
  845.         try {
  846.             Job cur = getCurrentJob();
  847.             if (cur.mainArea() != null
  848.                     && cur.mainArea().contains(getMyPlayer().getLocation())) {
  849.                 for (Action a : cur.Steps) {
  850.                     if (a.activate()) {
  851.                         a.run();
  852.                         break;
  853.                     }
  854.                 }
  855.             } else {
  856.                 if (!banking)
  857.                     web.getWeb(cur.mainArea().getCentralTile()).step();
  858.             }
  859.         } catch (Exception e) {
  860.             log(e.getMessage());
  861.         }
  862.         return 100;
  863.     }
  864.  
  865.     private Job getCurrentJob() {
  866.         for (Job job : getJobs()) {
  867.             if (job.reqLevel() <= skills.getRealLevel(Skills.HUNTER)
  868.                     && job.endLevel() > skills.getRealLevel(Skills.HUNTER)) {
  869.                 return job;
  870.             }
  871.         }
  872.         return null;
  873.  
  874.     }
  875.  
  876.     class Action {
  877.         boolean activate() {
  878.             return false;
  879.         }
  880.  
  881.         void run() {
  882.  
  883.         }
  884.     }
  885.  
  886.     class Job {
  887.         private long startTime;
  888.  
  889.         public RSArea mainArea() {
  890.             return null;
  891.         }
  892.  
  893.         int reqLevel() {
  894.             return -1;
  895.         }
  896.  
  897.         int endLevel() {
  898.             return -1;
  899.         }
  900.  
  901.         ArrayList<Action> Steps = new ArrayList<Action>();
  902.     }
  903.  
  904. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement