Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Gets realtime percent (when not in combat).
- */
- public final static int getHpPercent(){
- final double maxHp = Skills.getLevel(3) * 10.0,
- currHp = (double)Integer.parseInt(Widgets.get(748, 8).getText());
- final int hpPercent = (int)((currHp/maxHp)*100.0);
- return hpPercent;
- }
- /*
- * Assumes menu is open.
- */
- public final static int getMenuIndex(final String action) {
- String[] actions = Menu.getActions();
- for(int i = 0; i < actions.length; i++){
- if(actions[i].equals(action)){
- return i + 1;
- }
- }
- return -1;
- }
- /*
- * Name.
- */
- public boolean clickWidgetOption(final Widget widget, String option) {
- if (widget.validate()) {
- option = option.toLowerCase();
- for (final WidgetChild c : widget.getChildren()) {
- if (c.getText().toLowerCase().contains(option)) {
- return c.click(true);
- }
- }
- }
- return false;
- }
- /*
- * Gets an inventory item based on a specified ID.
- */
- public Item getItem(final int... ids){
- for(final Item item : Inventory.getItems()){
- for(int id : ids){
- if(item.getId() == id){
- return item;
- }
- }
- }
- return null;
- }
- /*
- * Interacts with an item in the inventory.
- */
- public boolean interactItem(final String action, final Item item){
- for(final Item invItem : Inventory.getItems()){
- if(invItem.equals(item)){
- return invItem.getWidgetChild().interact(action);
- }
- }
- return false;
- }
- /*
- * Checks if a widget contains certain text.
- */
- public boolean containsText(final Widget widget, String text) {
- if (widget.validate()) {
- text = text.toLowerCase();
- if(widget.getText().toLowerCase().contains(text)){
- return true;
- }
- for (final WidgetChild c : widget.getChildren()) {
- if (c.getText().toLowerCase().contains(text)) {
- return true;
- }
- }
- }
- return false;
- }
Add Comment
Please, Sign In to add comment