Advertisement
newbount

TehPapaya_Spawner

Jun 10th, 2011
2,248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ProFTPd 19.42 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Image;
  4.  
  5. import org.rsbot.script.Script;
  6. import org.rsbot.script.ScriptManifest;
  7. import org.rsbot.script.wrappers.RSTile;
  8. import org.rsbot.script.wrappers.RSGroundItem;
  9. import org.rsbot.script.wrappers.RSItem;
  10. import org.rsbot.util.GlobalConfiguration;
  11.  
  12. import org.rsbot.event.events.MessageEvent;
  13. import org.rsbot.event.listeners.MessageListener;
  14. import org.rsbot.event.listeners.PaintListener;
  15.  
  16. import java.awt.event.KeyEvent;
  17. import org.rsbot.script.wrappers.*;
  18. import org.rsbot.script.methods.*;
  19. import org.rsbot.script.methods.Game.CHAT_MODE;
  20.  
  21. import java.awt.image.BufferedImage;
  22. import java.awt.image.RenderedImage;
  23. import java.io.*;
  24. import java.net.URL;
  25.  
  26. import javax.imageio.ImageIO;
  27.  
  28.  
  29.  
  30. @ScriptManifest(authors = { "TehNubZ" }, name = "TehPapaya Spawner", description = "Catherby Papaya Fruit Spawner and Noter.")
  31. public class TehPapaya extends Script implements PaintListener, MessageListener
  32. {
  33.     AntiBan ab = new AntiBan();
  34.    
  35.     public static final Summoning.Familiar FRUIT_BAT = null;
  36.    
  37.     int fruitBatPouch = 12033;
  38.     int fruitFallScroll = 12423;
  39.     int obelisk = 29943;
  40.     int leprechaun = 3021;
  41.    
  42.     int notedPapaya = 5973;
  43.     int papaya = 5972;
  44.    
  45.     int orange = 2108;
  46.     int pineapple = 2114;
  47.     int lemon = 2102;
  48.     int banana = 1963;
  49.     int lime = 2120;
  50.    
  51.     int papayaOnStart = 0;
  52.     int papayaCount = 0;
  53.     int newpapaya = 0;
  54.    
  55.     int spawnCount = 0;
  56.     int count = 0;
  57.     int randomCounter = 0;
  58.    
  59.     int mySummoningPoints;
  60.    
  61.    
  62.     private RSTile obeliskTile = new RSTile(2853, 3439);
  63.     private RSTile spawningTile = new RSTile(2855, 3431);
  64.    
  65.     public long timeRunning = 0, hours = 0, minutes = 0, seconds = 0,
  66.     startTime = System.currentTimeMillis();
  67.    
  68.     public boolean onStart()
  69.     {
  70.         log("Welcome to TehPapaya.");
  71.         log("Make millions a day just by spawning fruit!");
  72.         log("Note. Make sure your character is in near the leprichaun in Catherby before starting.");
  73.         mouse.setSpeed(random(7, 10));
  74.         walking.walkTileMM(spawningTile, 1, 4);
  75.         startTime = System.currentTimeMillis();
  76.         sleep(1000, 1300);
  77.         return true;
  78.     }
  79.  
  80.     @Override
  81.     public int loop()
  82.     {
  83.     //    log("Prologue: entering looping");
  84.         if (!isInSpawningArea())
  85.         {
  86.             log("Please move your character near the leprechaun in Catherby and restart script.");
  87.             stopScript(true);
  88.         }
  89.        
  90.         SpawnFruit();
  91.         sleep(400, 500);
  92.        
  93.         summonFamiliar();
  94.         sleep(400, 500);
  95.        
  96.         renewPoints();
  97.         sleep(400, 500);
  98.        
  99.         renewFamiliar();
  100.         sleep(400, 500);
  101.        
  102.     //    log("Epilogue: leaving looping");
  103.         return random(100, 400);
  104.     }
  105.  
  106.    
  107.    
  108.    
  109.     public void SpawnFruit()
  110.     {
  111.     /*    log("Prologue: Entering SpawnFruit");
  112.         log("Creature has "+summoning.getTimeLeft());
  113.         log("Creature has "+ summoning.getFamiliar().getRequiredSpecialPoints()+ " special points left");
  114.         log("You have "+ summoning.getSummoningPoints() + " Summoning points left");*/
  115.                    
  116.         if (isInSpawningArea() && !needSummoningPoints() && summoning.isFamiliarSummoned() && !needNoting() && hasScrolls())
  117.         {      
  118.             if (getMyPlayer() != null && getMyPlayer().isMoving())
  119.             {
  120.                 sleep(1000, 2000);
  121.             }
  122.            
  123.             if(!isInActualSpawningLocation())
  124.             {
  125.                 antiban();
  126.                 sleep(500, 600);
  127.                 walking.walkTileMM(spawningTile);
  128.                 randomCounter++;
  129.             }
  130.            
  131.             for (int i = 0; i < random(3, 5); i++)
  132.             {
  133.                 sleep(300, 600);
  134.                 summoning.doAction("Cast");
  135.                 sleep(2400, 2700);
  136.             }    
  137.                
  138.             RSGroundItem groundItem = null;
  139.             papayaCount = inventory.getCount(papaya);
  140.            
  141.            
  142.            
  143.             while (groundItems != null && (groundItem = groundItems.getNearest(papaya)) != null && groundItem.isOnScreen())    
  144.             {
  145.                 if (inventory.isFull())
  146.                 {
  147.                     antiban();
  148.                     break;
  149.                 }
  150.                
  151.                 groundItem = groundItems.getNearest(papaya);
  152.                
  153.                 if(groundItems != null)
  154.                 {
  155.                     groundItem.doAction("Take");
  156.                     while(getMyPlayer().isMoving())
  157.                     {
  158.                         sleep(300, 500);
  159.                     }
  160.                     papayaCount = inventory.getCount(papaya) + inventory.getCount(true, notedPapaya);
  161.                 }
  162.                 sleep(800, 1000);
  163.             }
  164.             sleep(400, 500);
  165.            
  166.             RSItem invoItem;
  167.  
  168.             while((invoItem= inventory.getItem(orange)) != null)
  169.             {
  170.                
  171.                 invoItem.doAction("Drop");    
  172.                 sleep(300, 500);
  173.             }
  174.            
  175.             while((invoItem= inventory.getItem(pineapple)) != null)
  176.             {
  177.                
  178.                 invoItem.doAction("Drop");    
  179.                 sleep(300, 500);
  180.             }
  181.            
  182.             while((invoItem= inventory.getItem(lime)) != null)
  183.             {
  184.                
  185.                 invoItem.doAction("Drop");    
  186.                 sleep(300, 500);
  187.             }
  188.            
  189.             while((invoItem= inventory.getItem(lemon)) != null)
  190.             {
  191.                
  192.                 invoItem.doAction("Drop");    
  193.                 sleep(300, 500);
  194.             }
  195.            
  196.             while((invoItem= inventory.getItem(banana)) != null)
  197.             {
  198.                 invoItem.doAction("Drop");    
  199.                 sleep(300, 500);
  200.             }
  201.            
  202.             if (!inventory.isFull())
  203.             {
  204.                 antiban();
  205.                 sleep(3000, 5000);
  206.                 antiban();
  207.                 sleep(6000, 8000);
  208.             }
  209.             else
  210.             {
  211.                 antiban();
  212.                 sleep(6000, 8000);
  213.             }
  214.            
  215.         }
  216.         if (isInSpawningArea() && !needSummoningPoints() && needNoting() && hasScrolls())
  217.         {
  218.             walking.walkTileMM(getLocation(leprechaun));
  219.             if (getMyPlayer().isMoving())
  220.             {
  221.                 sleep(1000, 2000);
  222.             }
  223.             else
  224.             {
  225.                 if (npcs.getNearest(leprechaun).isOnScreen())
  226.                 {
  227.                     inventory.getItem(papaya).doAction("Use");
  228.                     sleep(300, 500);
  229.                     npcs.getNearest(leprechaun).doAction("Use");
  230.                     sleep(1000, 2000);
  231.                     walking.walkTileMM(spawningTile, 1, 4);
  232.                 }
  233.                 else
  234.                 {
  235.                     walking.walkTileMM(getLocation(leprechaun));
  236.                 }
  237.             }
  238.         }
  239.     //    log("Epilogue: leaving SpawnFruit");
  240.     }
  241.    
  242.     public void summonFamiliar()
  243.     {
  244.   //      log("Prologue: entering summonFamiliar");
  245.         if (isInSpawningArea() && !summoning.isFamiliarSummoned() && !needSummoningPoints() && !needNoting() && hasScrolls())
  246.         {
  247.             inventory.getItem(fruitBatPouch).doAction("Summon");
  248.             sleep(2000, 2500);
  249.         }
  250.  
  251. //        log("Epilogue: leaving summonFamiliar");
  252.     }
  253.    
  254.     public void renewPoints()
  255.     {
  256.   //      log("Prologue: Entering renewPoints");
  257.         if (isInSpawningArea() && needSummoningPoints() && !needNoting() && hasScrolls())
  258.         {
  259.             walking.walkTileMM(obeliskTile);
  260.             sleep(2000,3000);
  261.             objects.getNearest(obelisk).doClick();
  262.             sleep(1500,2000);
  263.             walking.walkTileMM(spawningTile, 1, 4);
  264.             sleep(3000,3500);
  265.            
  266.         }
  267.     //    log("Epilogue: Leaving renewPoints");
  268.     }
  269.    
  270.     public void renewFamiliar()
  271.     {
  272.         if (isInSpawningArea() && !needSummoningPoints() && !needNoting() && hasScrolls() && needRenewFamiliar())
  273.         {
  274.             summoning.doAction("Renew");
  275.             sleep(1000, 1500);
  276.         }
  277.     }
  278.    
  279.    
  280.     public void antiban()
  281.     {
  282.         int rand = random(1, 25);
  283.        
  284.         switch (rand)
  285.         {
  286.             case 1:
  287.                 ab.checkXP(Skills.ATTACK);
  288.                 sleep (500, 300);
  289.                 ab.moveCameraRandomly();
  290.                 break;
  291.                
  292.             case 2:
  293.                 ab.checkXP(Skills.FARMING);
  294.                 sleep (500, 300);
  295.                 ab.moveCameraRandomly();
  296.                 break;
  297.            
  298.             case 4:
  299.                 ab.moveCameraRandomly();
  300.                 sleep (500, 300);
  301.                 break;
  302.            
  303.             case 8:
  304.                 ab.moveCameraRandomly();
  305.                 sleep (500, 300);
  306.                 ab.checkXP(Skills.SUMMONING);
  307.                 break;
  308.            
  309.             case 16:
  310.                 ab.moveCameraRandomly();
  311.                 sleep (500, 300);
  312.                 ab.checkXP(Skills.CONSTITUTION);
  313.                 break;
  314.            
  315.                
  316.             default:
  317.                 mouse.setSpeed(random(6, 10));
  318.                 mouse.move(random(1, 600), random(1, 400));
  319.                 sleep (500, 300);
  320.                 break;
  321.         }
  322.     }
  323.    
  324.    
  325.    
  326.     public boolean isInSpawningArea()
  327.     {            
  328.    
  329.     /*    log("Player location is "+ getMyPlayer().getLocation());
  330.         log("SpawningTiles are "+ spawningTiles.toString());
  331.         log("Spawning tiles length: "+ spawningTiles.length);
  332.         log("Spawning tiles length [0]: "+ spawningTiles[0].length);    */
  333.        
  334.         RSTile myPlayerLocation = getMyPlayer().getLocation();
  335.        
  336.         if (myPlayerLocation.getX() < 2867 && myPlayerLocation.getX() > 2844 && myPlayerLocation.getY() < 3442 && myPlayerLocation.getY() > 2430)
  337.         {
  338.             return true;
  339.         }
  340.         return false;
  341.     }
  342.    
  343.     public boolean isInActualSpawningLocation()
  344.     {        
  345.         RSTile myPlayerLocation = getMyPlayer().getLocation();
  346.        
  347.         if (myPlayerLocation.getX() < 2858 && myPlayerLocation.getX() > 2852 && myPlayerLocation.getY() < 3433 && myPlayerLocation.getY() > 3430)
  348.         {
  349.             return true;
  350.         }
  351.         return false;
  352.     }
  353.     public boolean needSummoningPoints()
  354.     {
  355.         if(summoning.getSummoningPoints() < 10)
  356.         {
  357.             return true;
  358.         }
  359.         return false;
  360.     }
  361.    
  362.     public boolean needNoting()
  363.     {
  364.         if (inventory.isFull())
  365.         {
  366.             return true;
  367.         }
  368.         return false;
  369.     }  
  370.    
  371.     public boolean hasScrolls()
  372.     {
  373.         if (inventory.contains(fruitFallScroll))
  374.         {
  375.             return true;
  376.         }
  377.         return false;
  378.     }
  379.    
  380.     public boolean hasPouches()
  381.     {
  382.         if (inventory.contains(fruitBatPouch))
  383.         {
  384.             return true;
  385.         }
  386.         return false;
  387.     }
  388.    
  389.     public boolean needRenewFamiliar()
  390.     {
  391.         if (summoning.isFamiliarSummoned())
  392.         {
  393.             if (summoning.getTimeLeft() <= 1)
  394.             {
  395.                 return true;
  396.             }
  397.         }
  398.         return false;
  399.     }
  400.    
  401.     public RSTile getLocation(int Npc)
  402.     {
  403.         RSTile NpcLocation = new RSTile(npcs.getNearest(Npc).getLocation().getX(), npcs.getNearest(Npc).getLocation().getY());
  404.         return NpcLocation;
  405.     }
  406.  
  407.     public void onRepaint(Graphics g)
  408.     {
  409.         if (game.isLoggedIn())
  410.         {                        
  411.             g.drawImage(getImage("TehPapayacopy.png"), 159, 349, null);
  412.            
  413.             timeRunning = System.currentTimeMillis() - startTime;
  414.             seconds = timeRunning / 1000;
  415.  
  416.             if (seconds >= 60) {
  417.                     minutes = seconds / 60;
  418.                     seconds -= minutes * 60;
  419.             }
  420.             if (minutes >= 60) {
  421.                     hours = minutes / 60;
  422.                     minutes -= hours * 60;
  423.             }
  424.            
  425.             g.setColor(Color.black);
  426.             g.clearRect(226, 440, 231, 30);
  427.            
  428.             g.setColor(Color.orange);
  429.             g.drawString("Papayas Collected: "+ papayaCount +"    $"+ (papayaCount*1950), 228, 452);
  430.             g.drawString("Time Run: "+hours+":"+minutes+":"+seconds, 228, 467);
  431.            
  432.             g.setColor(Color.black);
  433.              g.drawLine(0, (int) (mouse.getLocation().getY()), 800, (int) (mouse.getLocation().getY()));
  434.              g.drawLine((int) (mouse.getLocation().getX()), 0, (int) (mouse.getLocation().getX()), 800);
  435.              g.setColor(Color.green);
  436.              g.drawLine(0, (int) (mouse.getLocation().getY()) + 1, 800, (int) (mouse.getLocation().getY()) + 1);
  437.              g.drawLine((int) (mouse.getLocation().getX()) + 1, 0, (int) (mouse.getLocation().getX()) + 1, 800);
  438.         }
  439.  
  440.     }
  441.    
  442.     public static Image getImage(String fileName) {
  443.         try {
  444.             File f = new File(
  445.                     GlobalConfiguration.Paths.getScriptsDirectory() + "/"
  446.                             + fileName);
  447.             if (f.exists()) {
  448.                 return ImageIO.read(f.toURI().toURL());
  449.             }
  450.             BufferedImage img = ImageIO.read(new URL(
  451.                     "http://i598.photobucket.com/albums/tt68/WarriorX/" + fileName));
  452.             if (img != null) {
  453.                
  454.                 ImageIO.write((RenderedImage) img, "PNG", f);
  455.                 return img;
  456.             }
  457.         } catch (IOException e) {
  458.         }
  459.         return null;
  460.     }
  461.    
  462.     @Override
  463.     public void messageReceived(MessageEvent e) {        
  464.     }
  465.    
  466.  
  467.    
  468.     public class AntiBan {
  469.        
  470.         private int [] Locations = {1 , 2, 3}; //set locations here
  471.        
  472.         private int WHITE = 35;
  473.         private int GREEN = 37;
  474.         private int AMBER = 39;
  475.         private int RED = 41;
  476.         private int NONE = 53;
  477.        
  478.        
  479.         private void checkXP(int Skill) {
  480.              if(game.getCurrentTab() != Game.TAB_STATS){  
  481.                  game.openTab(game.TAB_STATS);
  482.                  skills.doHover(Skill);
  483.              } else {
  484.                  skills.doHover(Skill);
  485.              }
  486.         }
  487.        
  488.         private void moveMouseOffScreen(int Time){
  489.             mouse.moveOffScreen();
  490.             sleep(Time);
  491.         }
  492.        
  493.         private void setRunning(int Energy){
  494.             if(!walking.isRunEnabled() && walking.getEnergy() >= Energy){
  495.                 walking.setRun(true);
  496.                 moveMouseRandomly(Locations);
  497.             }
  498.         }
  499.        
  500.         private void moveMouseRandomly(int[] location){
  501.             switch(location.length){
  502.            
  503.             case 0: // chatBox
  504.                 mouse.move(random(4, 327), random(528, 483));
  505.                 break;
  506.                
  507.             case 2: // Screen
  508.                 mouse.move(random(3, 0), random(525, 352));
  509.                 break;
  510.                
  511.             case 3: //Minimap
  512.                 mouse.move(random(521, 0), random(760, 170));
  513.                 break;
  514.                
  515.             case 4: //inventory
  516.                 mouse.move(random(527, 200), random(744, 464));
  517.                
  518.                
  519.             }
  520.                
  521.         }
  522.        
  523.         private void moveCameraToLeft(int minTime, int maxTime){
  524.             keyboard.pressKey((char)KeyEvent.VK_LEFT);
  525.             sleep(random(minTime, maxTime));
  526.             keyboard.releaseKey((char)KeyEvent.VK_LEFT);
  527.            
  528.         }
  529.        
  530.         private void moveCameraToRight(int minTime, int maxTime){
  531.             keyboard.pressKey((char)KeyEvent.VK_RIGHT);
  532.             sleep(random(minTime, maxTime));
  533.             keyboard.releaseKey((char)KeyEvent.VK_RIGHT);
  534.         }
  535.        
  536.         private void moveCameraRandomly() {
  537.            
  538.             switch(random(0,3)) {
  539.             case 0:
  540.                 moveCameraToLeft(750, 1000);
  541.                 camera.setPitch(random(30, 120));
  542.                 sleep(50, 100);
  543.                 break;
  544.            
  545.             case 1:
  546.                 moveCameraToRight(1000, 2500);
  547.                 camera.setPitch(random(30, 120));
  548.                 sleep(50, 100);
  549.                 break;
  550.             }
  551.         }
  552.        
  553.         private void addNote(String Text){
  554.             RSInterface Notes = interfaces.get(34);
  555.             if(game.getCurrentTab() != game.TAB_NOTES){
  556.                 game.openTab(game.TAB_NOTES);
  557.                 return;
  558.             } else {
  559.                 mouse.click(Notes.getComponent(3).getLocation(), true);
  560.                 sleep(600, 800);
  561.                 keyboard.sendText(Text, true);
  562.             }
  563.         }
  564.        
  565.         private void deleteNote(String Text){
  566.             RSInterface Notes = interfaces.get(34);
  567.             if(game.getCurrentTab() != game.TAB_NOTES){
  568.                 game.openTab(game.TAB_NOTES);
  569.                 return;
  570.             } else {
  571.                 for(int i = 0; i <= 30; i++){
  572.                     log(i);
  573.                     try {
  574.                         if(Notes.getComponent(9).getComponent(i).getText().equals(Text)){
  575.                             mouse.click(Notes.getComponent(9).getComponent(i).getLocation(), true);
  576.                             mouse.click(Notes.getComponent(8).getLocation(), true);
  577.                         } else {
  578.                             i++;
  579.                         }
  580.                     } catch(Exception e){}
  581.                 }
  582.             }
  583.         }
  584.        
  585.         private void setNoteColor(String Text, int Color){
  586.             RSInterface Notes = interfaces.get(34);
  587.             if(game.getCurrentTab() != game.TAB_NOTES){
  588.                 game.openTab(game.TAB_NOTES);
  589.                 return;
  590.             } else {
  591.                 for(int i = 0; i <= 30; i++){
  592.                     try {
  593.                         if(Notes.getComponent(9).getComponent(i).getText().equals(Text)){
  594.                                 mouse.click(Notes.getComponent(9).getComponent(i).getLocation(), false);
  595.                                 Notes.getComponent(9).doAction("Colour");
  596.                                 sleep(200, 500);
  597.                                 mouse.click(Notes.getComponent(Color).getLocation(), true);
  598.                             } else {
  599.                                 i++;
  600.                             }
  601.                            
  602.                         } catch(Exception e){}
  603.                     }
  604.                 }
  605.             }
  606.        
  607.         private void setMode(int chooseOption, CHAT_MODE setMode){
  608.             switch(chooseOption){
  609.            
  610.             case 1: // setPublicMode
  611.                 game.setPublicChat(setMode);
  612.                 break;
  613.                
  614.             case 2:// setTradeMode
  615.                 game.setTradeMode(setMode);
  616.                 break;
  617.            
  618.             case 3:// setPrivateMode
  619.                 game.setPrivateChat(setMode);
  620.                 break;
  621.            
  622.             case 4: //setClanMode
  623.                 game.setClanMode(setMode);
  624.            
  625.             case 5:// setAssistMode
  626.                 game.setAssistMode(setMode);
  627.                 break;
  628.                
  629.             }
  630.         }
  631.     }
  632. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement