Advertisement
phl0w

Equipment API for Powerbot.

Jun 12th, 2012
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.01 KB | None | 0 0
  1. import org.powerbot.game.api.methods.Widgets;
  2. import org.powerbot.game.api.wrappers.widget.WidgetChild;
  3.  
  4. public class Equipment {
  5.  
  6.     /**
  7.      * @author _phl0w
  8.      * @since 12-6-2012
  9.      */
  10.  
  11.     public static final int WIDGET = 387;
  12.     public static final int WIDGET_TOOLBELT = 0;
  13.     public static final int WIDGET_ITEMS_KEPT_ON_DEATH = 1;
  14.     public static final int WIDGET_STATS = 38;
  15.     public static final int WIDGET_EQUIPMENT_HELM = 6;
  16.     public static final int WIDGET_EQUIPMENT_CAPE = 9;
  17.     public static final int WIDGET_EQUIPMENT_NECK = 12;
  18.     public static final int WIDGET_EQUIPMENT_WEAPON = 15;
  19.     public static final int WIDGET_EQUIPMENT_BODY = 18;
  20.     public static final int WIDGET_EQUIPMENT_SHIELD = 21;
  21.     public static final int WIDGET_EQUIPMENT_LEGS = 24;
  22.     public static final int WIDGET_EQUIPMENT_GLOVES = 27;
  23.     public static final int WIDGET_EQUIPMENT_BOOTS = 30;
  24.     public static final int WIDGET_EQUIPMENT_RING = 33;
  25.     public static final int WIDGET_EQUIPMENT_ARROWS = 36;
  26.     public static final int WIDGET_EQUIPMENT_AURA = 45;
  27.     public static final int[] WIDGET_EQUIPMENT_ALL = { WIDGET_EQUIPMENT_HELM,
  28.             WIDGET_EQUIPMENT_CAPE, WIDGET_EQUIPMENT_NECK,
  29.             WIDGET_EQUIPMENT_WEAPON, WIDGET_EQUIPMENT_BODY,
  30.             WIDGET_EQUIPMENT_SHIELD, WIDGET_EQUIPMENT_LEGS,
  31.             WIDGET_EQUIPMENT_GLOVES, WIDGET_EQUIPMENT_BOOTS,
  32.             WIDGET_EQUIPMENT_RING, WIDGET_EQUIPMENT_ARROWS,
  33.             WIDGET_EQUIPMENT_AURA };
  34.  
  35.     /**
  36.      * @param slot
  37.      * @return The widget child of the equipment slot.
  38.      */
  39.     public static WidgetChild getEquipment(int slot) {
  40.         return Widgets.get(WIDGET, slot);
  41.     }
  42.  
  43.     /**
  44.      * @return The helm item id or -1 if none.
  45.      */
  46.     public static int getHelm() {
  47.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_HELM).getChildId();
  48.     }
  49.  
  50.     /**
  51.      * @return The cape item id or -1 if none.
  52.      */
  53.     public static int getCape() {
  54.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_CAPE).getChildId();
  55.     }
  56.  
  57.     /**
  58.      * @return The neck item id or -1 if none.
  59.      */
  60.     public static int getNeck() {
  61.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_NECK).getChildId();
  62.     }
  63.  
  64.     /**
  65.      * @return The weapon item id or -1 if none.
  66.      */
  67.     public static int getWeapon() {
  68.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_WEAPON).getChildId();
  69.     }
  70.  
  71.     /**
  72.      * @return The body item id or -1 if none.
  73.      */
  74.     public static int getBody() {
  75.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_BODY).getChildId();
  76.     }
  77.  
  78.     /**
  79.      * @return The shield item id or -1 if none.
  80.      */
  81.     public static int getShield() {
  82.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_SHIELD).getChildId();
  83.     }
  84.  
  85.     /**
  86.      * @return The legs item id or -1 if none.
  87.      */
  88.     public static int getLegs() {
  89.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_LEGS).getChildId();
  90.     }
  91.  
  92.     /**
  93.      * @return The gloves item id or -1 if none.
  94.      */
  95.     public static int getGloves() {
  96.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_GLOVES).getChildId();
  97.     }
  98.  
  99.     /**
  100.      * @return The boots item id or -1 if none.
  101.      */
  102.     public static int getBoots() {
  103.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_BOOTS).getChildId();
  104.     }
  105.  
  106.     /**
  107.      * @return The ring item id or -1 if none.
  108.      */
  109.     public static int getRing() {
  110.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_RING).getChildId();
  111.     }
  112.  
  113.     /**
  114.      * @return The arrows item id or -1 if none.
  115.      */
  116.     public static int getArrows() {
  117.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_ARROWS).getChildId();
  118.     }
  119.  
  120.     /**
  121.      * @return The arrows stack size or 0 if empty.
  122.      */
  123.     public static int getArrowStackSize() {
  124.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_ARROWS).getChildStackSize();
  125.     }
  126.  
  127.     /**
  128.      * @return The aura item id or -1 if none.
  129.      */
  130.     public static int getAura() {
  131.         return Widgets.get(WIDGET, WIDGET_EQUIPMENT_AURA).getChildId();
  132.     }
  133.  
  134.     /**
  135.      * @return The toolbelt widget child.
  136.      */
  137.     public static WidgetChild getToolbelt() {
  138.         return Widgets.get(WIDGET, WIDGET_TOOLBELT);
  139.     }
  140.  
  141.     /**
  142.      * @return The equipment widget child.
  143.      */
  144.     public static WidgetChild getEquipment() {
  145.         return Widgets.get(WIDGET, WIDGET_STATS);
  146.     }
  147.  
  148.     /**
  149.      * @return The items kept on death widget child.
  150.      */
  151.     public static WidgetChild getItemsKeptOnDeath() {
  152.         return Widgets.get(WIDGET, WIDGET_ITEMS_KEPT_ON_DEATH);
  153.     }
  154.  
  155.     /**
  156.      * @param item
  157.      * @return true if the player has one (or more) of the given items equipped;
  158.      *         otherwise false.
  159.      */
  160.     public static boolean isWearing(int item) {
  161.         for (int slot : WIDGET_EQUIPMENT_ALL) {
  162.             return Widgets.get(WIDGET, WIDGET_EQUIPMENT_ALL[slot]).getChildId() == item;
  163.         }
  164.         return false;
  165.     }
  166.  
  167.     /**
  168.      * @param item
  169.      * @param slot
  170.      * @returntrue if the player has one (or more) of the given items equipped
  171.      *             in the specified slot; otherwise false.
  172.      */
  173.     public static boolean isWearing(int item, int slot) {
  174.         return Widgets.get(WIDGET, slot).getChildId() == item;
  175.     }
  176.  
  177.     /**
  178.      * @return Amount of items currently equipped.
  179.      */
  180.     public static int getCount() {
  181.         int temp = 0;
  182.         for (int slot : WIDGET_EQUIPMENT_ALL) {
  183.             if (Widgets.get(WIDGET, WIDGET_EQUIPMENT_ALL[slot]).getChildId() != -1) {
  184.                 temp++;
  185.             }
  186.         }
  187.         return temp;
  188.     }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement