-
Posts
5883 -
Joined
-
Last visited
-
Days Won
18 -
Feedback
100%
Everything posted by Botre
-
Examples: 1) PrayerCompatibility.areCompatible(PrayerButton.BURST_OF_STRENGTH, PrayerButton.MYSTIC_LORE); // -> false 2) Code: package org.botre.prayer; import org.osbot.rs07.api.ui.PrayerButton; public class PrayerCompatibility { private enum Wrapper { THICK_SKIN(PrayerButton.THICK_SKIN, (byte)0b00000001), BURST_OF_STRENGTH(PrayerButton.BURST_OF_STRENGTH, (byte)0b00001010), CLARITY_OF_THOUGHT(PrayerButton.CLARITY_OF_THOUGHT, (byte)0b00010100), SHARP_EYE(PrayerButton.SHARP_EYE, (byte)0b00011110), MYSTIC_WILL(PrayerButton.MYSTIC_WILL, (byte)0b00011110), ROCK_SKIN(PrayerButton.ROCK_SKIN, (byte)0b00000001), SUPERHUMAN_STRENGTH(PrayerButton.SUPERHUMAN_STRENGTH, (byte)0b00001010), IMPROVED_REFLEXES(PrayerButton.IMPROVED_REFLEXES, (byte)0b00010100), RAPID_RESTORE(PrayerButton.RAPID_RESTORE, (byte)0b00000000), RAPID_HEAL(PrayerButton.RAPID_HEAL, (byte)0b00000000), PROTECT_ITEM(PrayerButton.PROTECT_ITEM, (byte)0b00000000), HAWK_EYE(PrayerButton.HAWK_EYE, (byte)0b00011110), MYSTIC_LORE(PrayerButton.MYSTIC_LORE, (byte)0b00011110), STEEL_SKIN(PrayerButton.STEEL_SKIN, (byte)0b00000001), ULTIMATE_STRENGTH(PrayerButton.ULTIMATE_STRENGTH, (byte)0b00001010), INCREDIBLE_REFLEXES(PrayerButton.INCREDIBLE_REFLEXES, (byte)0b00010100), PROTECT_FROM_MAGIC(PrayerButton.PROTECT_FROM_MAGIC, (byte)0b00100000), PROTECT_FROM_MISSILES(PrayerButton.PROTECT_FROM_MISSILES, (byte)0b00100000), PROTECT_FROM_MELEE(PrayerButton.PROTECT_FROM_MELEE, (byte)0b00100000), EAGLE_EYE(PrayerButton.EAGLE_EYE, (byte)0b00011110), MYSTIC_MIGHT(PrayerButton.MYSTIC_MIGHT, (byte)0b00011110), RETRIBUTION(PrayerButton.RETRIBUTION, (byte)0b00100000), REDEMPTION(PrayerButton.REDEMPTION, (byte)0b00100000), SMITE(PrayerButton.SMITE, (byte)0b00100000), CHIVALRY(PrayerButton.CHIVALRY, (byte)0b00011111), PIETY(PrayerButton.PIETY, (byte)0b00011111); private PrayerButton prayer; private byte types; private Wrapper(PrayerButton prayer, byte types) { this.prayer = prayer; this.types = types; } } public static byte forPrayer(PrayerButton prayer) { for (Wrapper value : Wrapper.values()) { if(value.prayer == prayer) return value.types; } throw new UnsupportedOperationException("Unable to determine types for: " + prayer); } public static PrayerButton[] findIncompatible(PrayerButton... prayers) { for (PrayerButton prayer : prayers) { byte b = forPrayer(prayer); for (PrayerButton other : prayers) { if(prayer == other) continue; byte o = forPrayer(other); if((b & o)!= 0) return new PrayerButton[]{prayer, other}; } } return null; } public static boolean areCompatible(PrayerButton... prayers) { return findIncompatible(prayers) != null; } }
- 1 reply
-
- 5
-
-
Please fill out this form, I will contact you 1. Do you have an account capable of playing the Ranging Guild minigame? If yes please indicate your ranged level. 2. Do you have an account capable of playing the Pest Control minigame? If yes please indicate your combat level. 3. Are you willing to supply feedback on a regular basis? (at least 1 list of feedback per week) 4. Are you willing to supply progress pictures on a regular basis? (at least 1 picture every 2/3 days) 5. Do you have access to the mirror mode client? 6. Have you ever botted at the Ranging Guild? 7. Have you ever botted at Pest Control? 8. Which script would you like to test (you can ofcourse pick both ). Cheers!
-
You can prevent the AUTO_LOGIN Random event from activating via response codes. You may have to play around with shouldActivate & onResponseCode. I 've done this before so it's deffo possible, but not sure if this kinda stuff is allowed for SDN scripts. getBot().getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.AUTO_LOGIN) { private RandomSolver solver = getBot().getRandomExecutor().forEvent(RandomEvent.AUTO_LOGIN); @Override public void onResponseCode(int c) throws InterruptedException { //INSERT WORK_AROUND HERE } @Override public void onStart() throws InterruptedException { super.onStart(); solver.onStart(); } @Override public boolean shouldActivate() { return solver.shouldActivate(); //Play around with this } @Override public int onLoop() throws InterruptedException { super.onLoop(); return solver.onLoop(); } @Override public void onExit() throws InterruptedException { super.onExit(); solver.onExit(); } }); }
-
Hero of Java
-
Example WarriorsGuild wg = new WarriorsGuild(this); //... Defender next = wg.getNextDefender(); if(next != null) { if(next == Defender.NONE) { //Go talk to Kamfreena } else if(next == Defender.RUNITE) { // If inventory contains rune defender -> go unlock Lorelai's door // Else -> continue killing regular cyclopses } else if(next == Defender.DRAGON) { // Kill high-level cyclopses } else { // Kill regular cyclopses } } Code package org.botre.warriorsguild; import java.awt.Point; import org.osbot.rs07.script.MethodProvider; public class WarriorsGuild { public static final int CONFIG = 788; public enum CatapultProjectile { SPIKED(679, CatapultDefenceStyle.STAB), ANVIL(680, CatapultDefenceStyle.BLUNT), KNIVES(681, CatapultDefenceStyle.SLASH), MAGICAL(682, CatapultDefenceStyle.MAGIC); private int id; private CatapultDefenceStyle defenceStyle; private CatapultProjectile(int id, CatapultDefenceStyle defenceStyle) { this.id = id; this.defenceStyle = defenceStyle; } public static CatapultProjectile forId(int id) { for (CatapultProjectile value : values()) { if(value.id == id) return value; } return null; } public int getId() { return id; } public CatapultDefenceStyle getDefenceStyle() { return defenceStyle; } } public enum CatapultDefenceStyle { STAB(1, new Point(564, 232)), BLUNT(2, new Point(564, 288)), SLASH(3, new Point(563, 344)), MAGIC(0, new Point(563, 401)); private int maskedValue; private Point widgetPosition; private CatapultDefenceStyle(int maskedValue, Point widgetPosition) { this.maskedValue = maskedValue; this.widgetPosition = widgetPosition; } public int getMaskedValue() { return maskedValue; } public Point getWidgetPosition() { return widgetPosition; } public static CatapultDefenceStyle forConfigValue(int configValue) { for (CatapultDefenceStyle value : values()) { if(value.getMaskedValue() == (configValue & 0b00000011)) return value; } return null; } } public enum Defender { NONE(0), BRONZE(1), IRON(2), STEEL(3), BLACK(4), MITHRIL(5), ADAMANTITE(6), RUNITE(7), DRAGON(-1); private int maskedValue; private Defender(int maskedValue) { this.maskedValue = maskedValue; } public int getMaskedValue() { return maskedValue; } public static Defender forConfigValue(int configValue) { if(isLorelaisDoorUnlocked(configValue)) return Defender.DRAGON; for (Defender value : values()) { if(value.getMaskedValue() == ((configValue >> 3) & 0b000001111)) return value; } return null; } } private MethodProvider ctx; public WarriorsGuild(MethodProvider ctx) { this.ctx = ctx; } public CatapultDefenceStyle getCatapultDefenceStyle() { return CatapultDefenceStyle.forConfigValue(ctx.getConfigs().get(CONFIG)); } public boolean isDefendingFromCatapultProjectile(CatapultProjectile projectile) { return getCatapultDefenceStyle() == projectile.getDefenceStyle(); } public Defender getNextDefender() { return Defender.forConfigValue(ctx.getConfigs().get(CONFIG)); } private static boolean isLorelaisDoorUnlocked(int configValue) { return ((configValue >> 12) & 0b00000001) == 1; } public boolean isLorelaisDoorUnlocked() { return isLorelaisDoorUnlocked(ctx.getConfigs().get(CONFIG)); } }
-
His library is an broad generic framework, this is a very specific set of methods just for autocasting :p Apples and oranges I guess.
-
Currently only supports the normal spellbook. Examples package org.botre.magic; import org.osbot.rs07.api.ui.MagicSpell; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; //Script manifest... public class ExampleScript extends Script { private Autocast auto = new Autocast(this); @Override public int onLoop() throws InterruptedException { /* * These are radom non-dependant examples. */ // Autocasts the fireblast spell in non-defensive mode auto.autocast(AutocastSpell.FIRE_BLAST, false); // Autocast the wind bolt spell in defensive mode auto.autocast(AutocastSpell.WIND_BOLT, true); // Stop the script immediately if in defensive mode. if(auto.isDefensiveMode()) { stop(); } // Get the difference between the level required to autocast the... // spell you are autocasting and your static magic level (a bit arbitrary). MagicSpell spell = auto.getAutocastSpell(); if(spell != null) { int difference = Math.abs(spell.getRequiredLevel() - getSkills().getStatic(Skill.MAGIC)); } return 500; } } Autocast package org.botre.magic; import java.awt.Point; import org.botre.tab.TabHotkey; import org.osbot.rs07.api.ui.MagicSpell; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.input.mouse.WidgetDestination; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.utility.ConditionalLoop; import org.osbot.rs07.utility.ConditionalSleep; public class Autocast { public static final int AUTOCAST_SPELL_CONFIG = 108; public static final int AUTOCAST_MODE_CONFIG = 439; // 0 = regular, 256 = defensive public static final Point DEFENSIVE_AUTOCAST_BUTTON_POSITION = new Point(650, 280); public static final Point REGULAR_AUTOCAST_BUTTON_POSITION = new Point(651, 333); private MethodProvider ctx; public Autocast(MethodProvider ctx) { this.ctx = ctx; } public boolean isAutocasting() { return ctx.getConfigs().get(AUTOCAST_SPELL_CONFIG) != 0; } public boolean isAutocasting(AutocastSpell auto) { return ctx.getConfigs().get(AUTOCAST_SPELL_CONFIG) == auto.getConfigValue(); } public boolean isAutocasting(AutocastSpell auto, boolean defensive) { return ctx.getConfigs().get(AUTOCAST_SPELL_CONFIG) == auto.getConfigValue() && defensive == isDefensiveMode(); } public boolean isRegularMode() { return ctx.getConfigs().get(AUTOCAST_MODE_CONFIG) == 0; } public boolean isDefensiveMode() { return ctx.getConfigs().get(AUTOCAST_MODE_CONFIG) == 256; } public MagicSpell getAutocastSpell() { AutocastSpell auto = AutocastSpell.forConfigValue(ctx.getConfigs().get(AUTOCAST_SPELL_CONFIG)); if(auto == null) return null; return auto.getSpell(); } public boolean isAutocastPanelOpen() { RS2Widget panel = ctx.getWidgets().get(201, 0); return panel != null && panel.isVisible(); } @SuppressWarnings("unchecked") public boolean openAutocastPanel(boolean defensive) { new ConditionalLoop(ctx.getBot(), 10) { @Override public boolean condition() { return !isAutocastPanelOpen(); }; @Override public int loop() { if(TabHotkey.COMBAT.openTab(ctx)) { RS2Widget button = ctx.getWidgets().singleFilter(ctx.getWidgets().getAll(), w -> { return w != null && w.isVisible() && w.getMessage() != null && w.getMessage().equals("Spell") && w.getPosition().equals(defensive ? DEFENSIVE_AUTOCAST_BUTTON_POSITION : REGULAR_AUTOCAST_BUTTON_POSITION); }); if(button != null) { WidgetDestination destination = new WidgetDestination(ctx.getBot(), button); if(ctx.getMouse().click(destination)) { new ConditionalSleep(2400, 200) { @Override public boolean condition() throws InterruptedException { return !button.isVisible(); } }.sleep(); } } } return MethodProvider.random(50, 150); } }.start(); return isAutocastPanelOpen(); } @SuppressWarnings("unchecked") public boolean closeAutocastPanel() { new ConditionalLoop(ctx.getBot(), 10) { @Override public boolean condition() { return isAutocastPanelOpen(); }; @Override public int loop() { RS2Widget cancel = ctx.getWidgets().singleFilter(ctx.getWidgets().getAll(), w -> { return w != null && w.isVisible() && w.getMessage() != null && w.getMessage().equals("Cancel"); }); if(cancel != null) { WidgetDestination destination = new WidgetDestination(ctx.getBot(), cancel); if(ctx.getMouse().click(destination)) { new ConditionalSleep(2400, 200) { @Override public boolean condition() throws InterruptedException { return !cancel.isVisible(); } }.sleep(); } } return MethodProvider.random(50, 150); } }.start(); return !isAutocastPanelOpen(); } public boolean autocast(AutocastSpell spell, boolean defensive) { new ConditionalLoop(ctx.getBot(), 10) { @Override public boolean condition() { return spell != null ? !isAutocasting(spell) : isAutocasting(); }; @SuppressWarnings("unchecked") @Override public int loop() { if(isAutocastPanelOpen()) { if(spell == null) { closeAutocastPanel(); } else { if(defensive != isDefensiveMode()) { closeAutocastPanel(); } else { RS2Widget button = ctx.getWidgets().singleFilter(ctx.getWidgets().getAll(), w -> { if(w != null && w.isVisible() && w.getInteractActions() != null) { String name = spell.getSpell().toString().replace("_", " "); for (String action : w.getInteractActions()) if(action != null && action.equalsIgnoreCase(name)) return true; } return false; }); if(button != null) { WidgetDestination destination = new WidgetDestination(ctx.getBot(), button); if(ctx.getMouse().click(destination)) { new ConditionalSleep(2400, 200) { @Override public boolean condition() throws InterruptedException { return !button.isVisible(); } }.sleep(); } } } } } else { openAutocastPanel(defensive); } return MethodProvider.random(50, 150); } }.start(); return spell != null ? isAutocasting(spell) : !isAutocasting(); } } AutocastSpell This is a MagicSpell wrapper storing the config value for a MagicSpell. package org.botre.magic; import org.osbot.rs07.api.ui.MagicSpell; import org.osbot.rs07.api.ui.Spells.NormalSpells; public enum AutocastSpell { WIND_STRIKE(NormalSpells.WIND_STRIKE, 3), WATER_STRIKE(NormalSpells.WATER_STRIKE, 5), EARTH_STRIKE(NormalSpells.EARTH_STRIKE, 7), FIRE_STRIKE(NormalSpells.FIRE_STRIKE, 9), WIND_BOLT(NormalSpells.WIND_BOLT, 11), WATER_BOLT(NormalSpells.WATER_BOLT, 13), EARTH_BOLT(NormalSpells.EARTH_BOLT, 15), FIRE_BOLT(NormalSpells.FIRE_BOLT, 17), WIND_BLAST(NormalSpells.WIND_BLAST, 19), WATER_BLAST(NormalSpells.WATER_BLAST, 21), EARTH_BLAST(NormalSpells.EARTH_BLAST, 23), FIRE_BLAST(NormalSpells.FIRE_BLAST, 25), WIND_WAVE(NormalSpells.WIND_WAVE, 27), WATER_WAVE(NormalSpells.WATER_WAVE, 29), EARTH_WAVE(NormalSpells.EARTH_WAVE, 31), FIRE_WAVE(NormalSpells.FIRE_WAVE, 33); private MagicSpell spell; private int configValue; private AutocastSpell(MagicSpell spell, int configValue) { this.spell = spell; this.configValue = configValue; } public MagicSpell getSpell() { return spell; } public int getConfigValue() { return configValue; } public static AutocastSpell forSpell(MagicSpell spell) { for (AutocastSpell a : values()) { if(a.spell == spell) return a; } return null; } public static AutocastSpell forConfigValue(int configValue) { for (AutocastSpell a : values()) { if(a.configValue == configValue) return a; } return null; } }
-
Example 1) public static void main(String[] args) { String string = "1 snickers beats 5 mars"; System.out.println(RegexUtil.extractAllIntegers(string)); System.out.println(RegexUtil.extractFirstInteger(string)); } [1, 5] 1 2) RS2Widget pointsTotal = getWidgets().singleFilter(getWidgets().getAll(), w -> w != null && w.isVisible() && w.getMessage() != null && w.getMessage().contains("Pest Points: ")); if(pointsTotal != null) { totalPoints = RegexUtil.extractFirstInteger(pointsTotal.getMessage()); } Code: public final class RegexUtil { public static final Pattern INTEGERS_PATTERN = Pattern.compile("-?\\d+"); private RegexUtil() { } public static List<Integer> extractAllIntegers(String string) { List<Integer> result = new ArrayList<>(); Matcher matcher = INTEGERS_PATTERN.matcher(string); while (matcher.find()) { result.add(Integer.parseInt(matcher.group())); } return result; } public static Integer extractFirstInteger(String string) { Matcher matcher = INTEGERS_PATTERN.matcher(string); if (matcher.find()) { return Integer.parseInt(matcher.group()); } return null; } }
-
80 attack 80 strength 70 defence 43 prayer 70 ranged 70 magic All void items Dragon defender Quests for NMZ 50 overloads 200 absorption potions No bans / mutes No membership
-
Example: Event event = new SpellOnItemEvent(NormalSpells.LVL_2_ENCHANT, "Emerald ring"); execute(event); if(event.getStatus() == EventStatus.FINISHED) { casts++; } Code: public class SpellOnItemEvent extends Event { private MagicSpell spell; private String item; public SpellOnItemEvent(MagicSpell spell, String item) { this.spell = spell; this.item = item; } @Override public int execute() throws InterruptedException { if(getMagic().isSpellSelected()) { int slot = getInventory().getSlot(item); long count = getInventory().getAmount(item); if(getMouse().click(new InventorySlotDestination(getBot(), slot))) { if(new ConditionalSleep(2400, 200) { @Override public boolean condition() throws InterruptedException { return getInventory().getAmount(item) != count; } }.sleep()) { setFinished(); } else { setFailed(); } } } else if(getMagic().castSpell(spell)) { if(!new ConditionalSleep(2400, 200) { @Override public boolean condition() throws InterruptedException { return getTabs().getOpen() == Tab.INVENTORY; } }.sleep()) { setFailed(); } } return MethodProvider.random(50, 150); } }
-
1. What is your favourite script? Frost Barrows (Just because of it's awesome loot tracker) 3. Who is your favourite mod/admin? Dex (Belgian crew) 4. Who is your favourite member? Apaec (My brochacho)
-
Not sure but this could be qualified as a bug exploitation so be careful /: Nice find though, what xp-rates are you experiencing with this? :p
-
No standard List implementation sorts automatically. Sequence-order does not equal sorted (also, since List allows insertion at user-specified positions it doesn't even guarantee sequence-order). Not sure why you think LinkedList somehow sorts it elements :p
-
Exactly the kind of story / style / tone I was looking for, digging the first episodes sofar, thanks
-
If you're in an environment where silence isn't an option and you want to cancel out noise consider sound effects: Rain, soft white noise, hoover sounds, etc... all work great. Just try to avoid getting caught listening to those, some people will think you're seriously nuts
-
I really prefer silence myself however sometimes I like to listen to rain sound effects. Music distracts me way too much :p
-
Allows you to group multiple entity types in one list which may or may not allow for more efficient overall traversal cost / filtering. Allows you to access sub-list of RS2Object sub-types such as Wall Decoration, which may allow for more efficient filtering. Examples: List<Entity> wallRelated = Entitype.collect(this, Entitype.OBJECT_WALL_DECORATION, Entitype.OBJECT_WALL_OBJECT); List<Entity> playersAndGroundItems = Entitype.collect(this, Entitype.PLAYER, Entitype.GROUND_ITEM); List<Entity> all = Entitype.collect(this, Entitype.ALL); List<Entity> entities = Entitype.collect(ctx, Entitype.OBJECT_ALL, Entitype.NPC, Entitype.GROUND_ITEM); if(!entities.isEmpty()) { Entity target = entities.get(random.nextInt(entities.size())); target.examine(); } Snippet: import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; import org.osbot.rs07.api.model.Character; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.GroundDecoration; import org.osbot.rs07.api.model.InteractableObject; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.model.WallDecoration; import org.osbot.rs07.api.model.WallObject; import org.osbot.rs07.script.MethodProvider; public class Entitype { public static final int OBJECT_GROUND_DECORATION = 0; public static final int OBJECT_INTERACTABLE_OBJECT = 1; public static final int OBJECT_WALL_DECORATION = 2; public static final int OBJECT_WALL_OBJECT = 3; public static final int OBJECT_ALL = 4; public static final int CHARACTER = 5; public static final int NPC = 6; public static final int PLAYER = 7; public static final int GROUND_ITEM = 8; public static final int ALL = 9; public static List<Entity> collect(MethodProvider ctx, int... types) { List<Entity> result = new ArrayList<>(); List<Entity> objectsGroundDecoration = new ArrayList<>(); List<Entity> objectsInteractableObject = new ArrayList<>(); List<Entity> objectsWallDecoration = new ArrayList<>(); List<Entity> objectsWallObject = new ArrayList<>(); if(IntStream.of(types).anyMatch(x -> x < OBJECT_ALL)) { for (RS2Object o : ctx.getObjects().getAll()) { Class<?> clazz = o.getClass(); if(clazz.equals(GroundDecoration.class)) { objectsGroundDecoration.add(o); } else if(clazz.equals(InteractableObject.class)) { objectsInteractableObject.add(o); } else if(clazz.equals(WallDecoration.class)) { objectsWallDecoration.add(o); } else if(clazz.equals(WallObject.class)) { objectsWallObject.add(o); } } } for (int type : types) { switch (type) { case ALL: List<Entity> all = new ArrayList<>(); all.addAll(ctx.getObjects().getAll()); all.addAll(ctx.getNpcs().getAll()); all.addAll(ctx.getPlayers().getAll()); result.addAll(all); break; case OBJECT_ALL: result.addAll(ctx.getObjects().getAll()); break; case OBJECT_GROUND_DECORATION: result.addAll(objectsGroundDecoration); break; case OBJECT_INTERACTABLE_OBJECT: result.addAll(objectsInteractableObject); break; case OBJECT_WALL_DECORATION: result.addAll(objectsWallDecoration); break; case OBJECT_WALL_OBJECT: result.addAll(objectsWallObject); break; case CHARACTER: List<Character<?>> characters = new ArrayList<>(); characters.addAll(ctx.getNpcs().getAll()); characters.addAll(ctx.getPlayers().getAll()); result.addAll(characters); break; case NPC: result.addAll(ctx.getNpcs().getAll()); break; case PLAYER: result.addAll(ctx.getPlayers().getAll()); break; case GROUND_ITEM: result.addAll(ctx.getGroundItems().getAll()); break; } } return result; } }
-
Is there a cleaner way than the following snippet to set the timeout of a WalkingEvent? While we're at it, what is the default timeout for a WalkingEvent? (walkingTimer is a timer class) walkingTimer.reset(); WalkingEvent walkingEvent = new WalkingEvent(voidKnightArea); walkingEvent.setBreakCondition(new Condition() { @Override public boolean evaluate() { return walkingTimer.getElapsedSeconds() > 10; } }); execute(walkingEvent); Cheerseroni
-
public void EatShark() { Item shark = getInventory().getItem("Shark") if(shark != null) shark.interact("Eat"); World.killPuppy(); }