July 21, 201510 yr I'm working on an extremely high-level API that sits on top of the OSBot API, makes it a bit more beginner friendly and adds plenty of shortcuts. Here's how a simple pickpocketer looks like (works flawlessly): import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.ScriptManifest; /** * Created by Bjorn on 21/07/2015. */ @ScriptManifest(author = "Botre", info = "", logo = "", name = "PPS", version = 0.0) public class PickpocketScript extends BasicScript { private EntityDefinition definition = new EntityDefinition(this) .name("Man") .action("Pickpocket") .reachable(); private Target<NPC> target = new Target<>(definition, Searcher.closest(this, definition)); @Override public void loop() { if(target.valid() || target.find()){ target.get().interact("Pickpocket"); } } }
July 21, 201510 yr Nice dude! I had a similar idea where I was going to create my own scripting language for my scripts for presets, the following would be something that thieved from a guard: walkto varrock tag GUARD "Guard" NPC_TYPE interact GUARD "Pickpocket" My API would handle it flawlessly, with built in variables (varrock being varrock square for example), and the script would handle when to stop and restart etc. Good luck
July 21, 201510 yr private EntityDefinition definition = new EntityDefinition(this) .name("Man") .action("Pickpocket") .reachable(); Is this supposed to be more clear than using a constructor?
July 22, 201510 yr Author private EntityDefinition definition = new EntityDefinition(this) .name("Man") .action("Pickpocket") .reachable(); Is this supposed to be more clear than using a constructor? new EntityDefinition(this .name("Man") .action("Pickpocket") .reachable()); vs new EntityDefinition( this, "Man", "Pickpocket", true); 1 constructor 0 ambiguity 100% modular 100% extendable So... yes? On top of that, the class is wrapped around a predicate: the ability to add properties in the sequence you want makes tactical logical shortcutting a piece of pie among other cool things. Source: public class EntityDefinition<T extends Entity> implements Predicate<T> { private Predicate<T> predicate; private MethodProvider mp; public EntityDefinition(MethodProvider mp) { this.mp = mp; predicate = o -> o != null && o.exists(); } public EntityDefinition name(String name) { predicate = predicate.and(o -> o.getName().equals(name)); return this; } public EntityDefinition action(String action) { predicate = predicate.and(o -> o.hasAction(action)); return this; } public EntityDefinition reachable() { predicate = predicate.and(o -> mp.getMap().canReach(o.getPosition())); return this; } @Override public boolean test(T t) { return predicate.test(t); } } Edited July 22, 201510 yr by Botre
July 22, 201510 yr new EntityDefinition(this .name("Man") .action("Pickpocket") .reachable()); vs new EntityDefinition( this, "Man", "Pickpocket", true); 1 constructor 0 ambiguity 100% modular 100% extendable So... yes? On top of that, the class is wrapped around a predicate: the ability to add properties in the sequence you want makes tactical logical shortcutting a piece of pie among other cool things. Source: public class EntityDefinition<T extends Entity> implements Predicate<T> { private Predicate<T> predicate; private MethodProvider mp; public EntityDefinition(MethodProvider mp) { this.mp = mp; predicate = o -> o != null && o.exists(); } public EntityDefinition name(String name) { predicate = predicate.and(o -> o.getName().equals(name)); return this; } public EntityDefinition action(String action) { predicate = predicate.and(o -> o.hasAction(action)); return this; } public EntityDefinition reachable() { predicate = predicate.and(o -> mp.getMap().canReach(o.getPosition())); return this; } @Override public boolean test(T t) { return predicate.test(t); } } That's actually really good use of Predicate, props to you!
Create an account or sign in to comment