Brainfree Posted August 2, 2013 Share Posted August 2, 2013 (edited) If you would like to add pouches (any type) into your script, and want to know what type of rune, and how much is in that pouch, this snippet is for you. Pouch import org.osbot.script.rs2.Client; import org.osbot.script.rs2.skill.Skill; public enum Pouch { SMALL(5509, -1, 1, 3, 3), MEDIUM(5510, 5511, 50, 6, 3), LARGE(5512, 5513, 50, 9, 7), GIANT(5514, 5515, 75, 12, 9); public final int normalID; public final int degradedID; public final int requiredLevel; public final int normalHold; public final int degradedHold; private Pouch(int AssignedNormalID, int AssignedDegradedID, int AssignedRequiredLevel, int AssignedNormalHold, int AssignedDegradedHold ) { this.normalID = AssignedNormalID; this.degradedID = AssignedDegradedID; this.requiredLevel = AssignedRequiredLevel; this.normalHold = AssignedNormalHold; this.degradedHold = AssignedDegradedHold; } public static EssenceType getPouchEssenceType(Client client, Pouch p) { int setting = client.getConfig(720); switch (p) { case SMALL: return setting >= 128 ? EssenceType.PURE : (setting >= 0x40) && (setting < 0x80) ? EssenceType.NORMAL : null; case MEDIUM: if (setting >= 64) setting %= 64; return setting >= 32 ? EssenceType.PURE : (setting >= 0x10) && (setting < 0x20) ? EssenceType.NORMAL : null; case LARGE: if (setting >= 64) setting %= 64; if (setting >= 16) setting %= 16; return setting >= 9 ? EssenceType.PURE : (setting >= 0x4) && (setting < 0x9) ? EssenceType.NORMAL : null; case GIANT: if (setting >= 64) setting %= 64; if (setting >= 16) setting %= 16; if (setting >= 4) if (setting < 0x9) setting %= 0x4; else setting %= 0x9; return setting == 0x2 ? EssenceType.PURE : setting == 0x1 ? EssenceType.NORMAL : null; } return null; } public static int getEssenceCount(Client client, Pouch p) { int setting = client.getConfig(486) - 0x40000000; switch (p) { case GIANT: return setting / 0x40000; case LARGE: setting %= 262144; return setting / 0x200; case MEDIUM: setting %= 262144; setting %= 512; return setting / 8; case SMALL: setting %= 262144; setting %= 512; return setting % 8; } return -1; } public int getNormalID() { return normalID; } public int getDegradedID() { return degradedID; } public int getNormalHold() { return normalHold; } public int getDegradedHold() { return degradedHold; } public int getRequiredLevel() { return requiredLevel; } public EssenceType getEssencesType(Client client) { return getPouchEssenceType(client, this); } public int getEssencesAmount(Client client) { return getEssenceCount(client, this); } } And for wrapping the rune types: public enum EssenceType { PURE(7936), NORMAL(1436); final int ID; private EssenceType(int ID) { this.ID = ID; } public int getID() { return this.ID; } } Example: import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Brainfree", info = "Pouch display", version = 1.0, name = "Pouch viewer") public class Example extends Script { public int onLoop() { return 35; } public void onPaint(Graphics g) { int x = 10; int y = 15; EssenceType type; for (Pouch pouch : Pouch.values()) { type = pouch.getEssencesType(client); g.drawString(pouch.name() + ":[Type: " + (type == null ? "None" : type.name()) + ",Quantity: " + pouch.getEssencesAmount(client) + "]", x, y); y += 15; } } } Hope you enjoy. Edited August 4, 2013 by Brainfree 4 Link to comment Share on other sites More sharing options...
XavierM Posted August 2, 2013 Share Posted August 2, 2013 Nice Link to comment Share on other sites More sharing options...
Ambassador Posted August 2, 2013 Share Posted August 2, 2013 The phantom of the syntax strikes again! Link to comment Share on other sites More sharing options...
PhaseCoder Posted August 2, 2013 Share Posted August 2, 2013 Similar to what I had in my graahk script I use to sell over at ArbiBots Link to comment Share on other sites More sharing options...
Aeterna Posted August 2, 2013 Share Posted August 2, 2013 Looks good man Link to comment Share on other sites More sharing options...
Dashboard Posted August 2, 2013 Share Posted August 2, 2013 Very nice. Brainfree for admin. Link to comment Share on other sites More sharing options...
Ambassador Posted August 2, 2013 Share Posted August 2, 2013 Brainfree for admin. Link to comment Share on other sites More sharing options...
triggamortis Posted August 2, 2013 Share Posted August 2, 2013 (edited) Oh nice I didn't know how to check for essence count in pouches config. Thanks for this. Edited August 2, 2013 by triggamortis Link to comment Share on other sites More sharing options...
Krulvis Posted August 2, 2013 Share Posted August 2, 2013 wow, good job man Link to comment Share on other sites More sharing options...
Brainfree Posted August 4, 2013 Author Share Posted August 4, 2013 (edited) Stark has pointed out a bug in the counting, which has now been fixed. PS: The problem was solves my shifting the switch cases, if there is a problem with the essences, run my example as a debug, and see if simply adjusting the switch cases are the solution, if there is a problem. Edited August 4, 2013 by Brainfree Link to comment Share on other sites More sharing options...