Skip to content

Instantly share code, notes, and snippets.

@phl0w
Created June 13, 2012 18:27
Show Gist options
  • Select an option

  • Save phl0w/2925669 to your computer and use it in GitHub Desktop.

Select an option

Save phl0w/2925669 to your computer and use it in GitHub Desktop.
import org.powerbot.game.api.methods.Widgets;
import org.powerbot.game.api.wrappers.widget.WidgetChild;
public class Equipment {
/**
* @author _phl0w
* @since 12-6-2012
*/
public static final int WIDGET = 387;
public static final int WIDGET_TOOLBELT = 0;
public static final int WIDGET_ITEMS_KEPT_ON_DEATH = 1;
public static final int WIDGET_STATS = 38;
public static final int WIDGET_EQUIPMENT_HELM = 6;
public static final int WIDGET_EQUIPMENT_CAPE = 9;
public static final int WIDGET_EQUIPMENT_NECK = 12;
public static final int WIDGET_EQUIPMENT_WEAPON = 15;
public static final int WIDGET_EQUIPMENT_BODY = 18;
public static final int WIDGET_EQUIPMENT_SHIELD = 21;
public static final int WIDGET_EQUIPMENT_LEGS = 24;
public static final int WIDGET_EQUIPMENT_GLOVES = 27;
public static final int WIDGET_EQUIPMENT_BOOTS = 30;
public static final int WIDGET_EQUIPMENT_RING = 33;
public static final int WIDGET_EQUIPMENT_ARROWS = 36;
public static final int WIDGET_EQUIPMENT_AURA = 45;
public static final int[] WIDGET_EQUIPMENT_ALL = { WIDGET_EQUIPMENT_HELM,
WIDGET_EQUIPMENT_CAPE, WIDGET_EQUIPMENT_NECK,
WIDGET_EQUIPMENT_WEAPON, WIDGET_EQUIPMENT_BODY,
WIDGET_EQUIPMENT_SHIELD, WIDGET_EQUIPMENT_LEGS,
WIDGET_EQUIPMENT_GLOVES, WIDGET_EQUIPMENT_BOOTS,
WIDGET_EQUIPMENT_RING, WIDGET_EQUIPMENT_ARROWS,
WIDGET_EQUIPMENT_AURA };
/**
* @param slot
* @return The widget child of the equipment slot.
*/
public static WidgetChild getEquipment(int slot) {
return Widgets.get(WIDGET, slot);
}
/**
* @return The helm item id or -1 if none.
*/
public static int getHelm() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_HELM).getChildId();
}
/**
* @return The cape item id or -1 if none.
*/
public static int getCape() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_CAPE).getChildId();
}
/**
* @return The neck item id or -1 if none.
*/
public static int getNeck() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_NECK).getChildId();
}
/**
* @return The weapon item id or -1 if none.
*/
public static int getWeapon() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_WEAPON).getChildId();
}
/**
* @return The body item id or -1 if none.
*/
public static int getBody() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_BODY).getChildId();
}
/**
* @return The shield item id or -1 if none.
*/
public static int getShield() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_SHIELD).getChildId();
}
/**
* @return The legs item id or -1 if none.
*/
public static int getLegs() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_LEGS).getChildId();
}
/**
* @return The gloves item id or -1 if none.
*/
public static int getGloves() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_GLOVES).getChildId();
}
/**
* @return The boots item id or -1 if none.
*/
public static int getBoots() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_BOOTS).getChildId();
}
/**
* @return The ring item id or -1 if none.
*/
public static int getRing() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_RING).getChildId();
}
/**
* @return The arrows item id or -1 if none.
*/
public static int getArrows() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_ARROWS).getChildId();
}
/**
* @return The arrows stack size or 0 if empty.
*/
public static int getArrowStackSize() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_ARROWS).getChildStackSize();
}
/**
* @return The aura item id or -1 if none.
*/
public static int getAura() {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_AURA).getChildId();
}
/**
* @return The toolbelt widget child.
*/
public static WidgetChild getToolbelt() {
return Widgets.get(WIDGET, WIDGET_TOOLBELT);
}
/**
* @return The equipment widget child.
*/
public static WidgetChild getEquipment() {
return Widgets.get(WIDGET, WIDGET_STATS);
}
/**
* @return The items kept on death widget child.
*/
public static WidgetChild getItemsKeptOnDeath() {
return Widgets.get(WIDGET, WIDGET_ITEMS_KEPT_ON_DEATH);
}
/**
* @param item
* @return true if the player has one (or more) of the given items equipped;
* otherwise false.
*/
public static boolean isWearing(int item) {
for (int slot : WIDGET_EQUIPMENT_ALL) {
return Widgets.get(WIDGET, WIDGET_EQUIPMENT_ALL[slot]).getChildId() == item;
}
return false;
}
/**
* @param item
* @param slot
* @return true if the player has one (or more) of the given items equipped
* in the specified slot; otherwise false.
*/
public static boolean isWearing(int item, int slot) {
return Widgets.get(WIDGET, slot).getChildId() == item;
}
/**
* @return Amount of items currently equipped.
*/
public static int getCount() {
int temp = 0;
for (int slot : WIDGET_EQUIPMENT_ALL) {
if (Widgets.get(WIDGET, WIDGET_EQUIPMENT_ALL[slot]).getChildId() != -1) {
temp++;
}
}
return temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment