Avaryan

passivePenguinHideAndSeek

Oct 27th, 2010
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.54 KB | None | 0 0
  1. import impsoft.bots.ColorBot;
  2. import impsoft.bots.reflection.NPC;
  3. import impsoft.bots.reflection.NPCIterator;
  4. import impsoft.scripting.ibot.interfaces.AutoPaint;
  5. import impsoft.scripting.ibot.interfaces.PassiveScript;
  6. import impsoft.scripting.ibot.structs.XY;
  7. import impsoft.scripting.types.ColorScript;
  8.  
  9. import java.awt.Color;
  10. import java.awt.Graphics;
  11. import java.awt.Polygon;
  12. import java.util.ArrayList;
  13.  
  14. import bergCoder.BergUtils;
  15.  
  16. public class passivePenguinHideAndSeek extends ColorScript implements AutoPaint, PassiveScript
  17. {
  18.     BergUtils util = new BergUtils(this);
  19.  
  20.     /****** Identification *******/
  21.     public static String name = "Berg's Penguin Seeker";
  22.     public static double version = 1.02;
  23.     public static String author = "BergCoder, Avaryan";
  24.     public static String description = "Penguin Hide N' Seek Assistant";
  25.  
  26.     ArrayList<NPC> penguins = new ArrayList<NPC>();
  27.  
  28.     public passivePenguinHideAndSeek(ColorBot b, String command, String args[])
  29.     {
  30.         super(b);
  31.     }
  32.  
  33.     public void script() throws InterruptedException
  34.     {
  35.         while (true)
  36.         {
  37.             //log("Seeking penguins"); // This log was annoying.
  38.             penguins.clear();
  39.             paintPenguins();
  40.             sleep(1000);
  41.         }
  42.     }
  43.  
  44.     public void paintPenguins() throws InterruptedException
  45.     {
  46.         for (NPCIterator iterator = getNPCIterator(); iterator.hasNext();)
  47.         {
  48.             NPC npc = iterator.next();
  49.             String name = npc.getName();
  50.  
  51.             if (name.equals("Crate") || name.equals("Bush") || name.equals("Barrel")
  52.                 || name.equals("Cactus")  || name.equals("Rock")  || name.equals("Toadstool")
  53.                 || name.equals("Pumpkin") || name.equals("Snowman"))
  54.             {
  55.                 penguins.add(npc);
  56.             }
  57.         }
  58.     }
  59.  
  60.     @SuppressWarnings({ "unchecked", "static-access" })
  61.     public void paint(final Graphics g)
  62.     {
  63.         try {
  64.             ArrayList<NPC> penguinsCopy = (ArrayList)this.penguins.clone();
  65.             if (penguinsCopy.size() > 0) g.setColor(new Color(255, 0, 255, 255));
  66.             else g.setColor(Color.WHITE);
  67.  
  68.             @SuppressWarnings("unused")
  69.             int i=0;
  70.             for (NPC npc : penguinsCopy)
  71.             {
  72.                 Polygon p = npc.getGameScreenLocation(-10,10,-10,10,0,0);
  73.                 if (p != null)
  74.                 {
  75.                     XY point = util.getMedianXY(p);
  76.                     g.drawString("X",point.x, point.y);
  77.                 }
  78.  
  79.                 XY minimap = theMiniMap.toOnScreenMiniMap(npc.getLocation());
  80.                 if(minimap !=null){
  81.                     g.setColor(new Color(255,0,255,255));
  82.                     g.drawString(npc.getName(),minimap.x,minimap.y);
  83.                 }
  84.                 //if (minimap != null) paintPoint(minimap, new Color(255, 0, 255, 255), 1000, 3);
  85.             }
  86.             g.drawString("Penguins: " + penguinsCopy.size(),340,48);
  87.         } catch(Exception e) {}
  88.     }
  89. }
Add Comment
Please, Sign In to add comment