lolmanden Posted March 10, 2014 Share Posted March 10, 2014 Thanks for the contrib. Link to comment Share on other sites More sharing options...
liverare Posted May 15, 2014 Share Posted May 15, 2014 (edited) public static boolean drinkPotion(Client client, Skill skill) throws InterruptedException { boolean success = false; int boostedLevel = client.getSkills().getCurrentLevel(skill); int baseLevel = client.getSkills().getLevel(skill); if (boostedLevel <= baseLevel) { /* * e.g., * ATTACK -> * -> (A) (ttack) -> * -> Attack */ String potionName = skill.name().charAt(0) + skill.name().substring(1).toLowerCase(); Item potion = client.getInventory().getItemForNameThatContains(potionName); if (potion != null && client.getInventory().interactWithId(potion.getId(), "Drink")) { success = true; } } return success; } Be liek public void someMethod() { // Drink attack potion if (drinkPotion(client, Skill.ATTACK)) { log("Successfully drank a sip of attack potion."); } // Drink strength potion if (drinkPotion(client, Skill.STRENGTH)) { log("Successfully drank a sip of strength potion."); } // Drink agility potion if (drinkPotion(client, Skill.AGILITY)) { log("Successfully drank a sip of agility potion."); } } Oh, forgot to mention: Untested. :\ ...Lol, just realised; don't be havin' no strength amulet on yo' purson! Mmmeh, just so long as getItemForNameThatContains is case sensitive, you should be fine because... Strength potion Amulet of strength Edited May 15, 2014 by liverare 1 Link to comment Share on other sites More sharing options...
Nezz Posted May 15, 2014 Author Share Posted May 15, 2014 public static boolean drinkPotion(Client client, Skill skill) throws InterruptedException { boolean success = false; int boostedLevel = client.getSkills().getCurrentLevel(skill); int baseLevel = client.getSkills().getLevel(skill); if (boostedLevel <= baseLevel) { /* * e.g., * ATTACK -> * -> (A) (ttack) -> * -> Attack */ String potionName = skill.name().charAt(0) + skill.name().substring(1).toLowerCase(); Item potion = client.getInventory().getItemForNameThatContains(potionName); if (potion != null && client.getInventory().interactWithId(potion.getId(), "Drink")) { success = true; } } return success; } Be liek public void someMethod() { // Drink attack potion if (drinkPotion(client, Skill.ATTACK)) { log("Successfully drank a sip of attack potion."); } // Drink strength potion if (drinkPotion(client, Skill.STRENGTH)) { log("Successfully drank a sip of strength potion."); } // Drink agility potion if (drinkPotion(client, Skill.AGILITY)) { log("Successfully drank a sip of agility potion."); } } Oh, forgot to mention: Untested. :\ ...Lol, just realised; don't be havin' no strength amulet on yo' purson! Mmmeh, just so long as getItemForNameThatContains is case sensitive, you should be fine because... Strength potion Amulet of strength None of those would handle Super potions. I should probably go through and rewrite my snippet. :P Link to comment Share on other sites More sharing options...
rsjofaa Posted May 15, 2014 Share Posted May 15, 2014 xd Link to comment Share on other sites More sharing options...