Leaderboard
Popular Content
Showing content with the highest reputation on 05/16/13 in all areas
-
This piece of software will tell you all Entity by a selected set of types, at a given distance, that you are facing. This has uses to tell what Entity's you can interact with (without changing positions, or direction), or are about to interact with. You could also pair it with animations to tell if a player is interacting with it, or yourself (ex. prioritizing ores by filtering 'currently being mined' ore, same with trees). By mainly this was made to tell what tree your were facing, and decide if it's a evil tree, or not (Wiz). Real use example: Example of use is within the code. import org.osbot.script.Script; import org.osbot.script.rs2.Client; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.Entity; import org.osbot.script.rs2.model.Player; import java.util.ArrayDeque; import java.util.EnumSet; import java.util.List; /** * @author Brainfree */ public class FacingEntities extends Script { public enum DirectionalOrientation { NORTH_WEST(-1, 1, 135), NORTH(0, 1, 90), NORTH_EAST(1, 1, 45), EAST(1, 0, 0), SOUTH_EAST(1, -1, 315), SOUTH(0, -1, 270), SOUTH_WEST(-1, -1, 225), WEST(-1, 0, 180); public final int x_shift, y_shift, angle; DirectionalOrientation(int x_shift, int y_shift, int angle) { this.x_shift = x_shift; this.y_shift = y_shift; this.angle = angle; } } public Position getFacingPosition(Player player, int distance) { int angle_shift = (player.getRotation() / 0x100) * 45; angle_shift -= 270; if (angle_shift > 0) angle_shift += 270; angle_shift = Math.abs(angle_shift); for (DirectionalOrientation orientation : DirectionalOrientation.values()) { if (orientation.angle == angle_shift) { return new Position( player.getX() + (distance * orientation.x_shift), player.getY() + (distance * orientation.y_shift), player.getZ() ); } } return null; } public enum EntityType { OBJECT { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getObjects(); } }, NPC { @Override public List<? extends Entity> getType(Client client) { return client.getLocalNPCs(); } }, PLAYER { @Override public List<? extends Entity> getType(Client client) { return client.getLocalPlayers(); } }, GROUND_ITEM { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getItems(); } }; public abstract List<? extends Entity> getType(Client client); } public Entity[] getFacingEntities(Client client, Player player, int distanceInTiles, EnumSet<EntityType> checkFor) { if (checkFor == null || checkFor.size() == 0) return new Entity[0]; final Position facing = getFacingPosition(player, distanceInTiles); if (facing == null) return new Entity[0]; ArrayDeque<Entity> pool = new ArrayDeque<Entity>(); for (EntityType type : checkFor) { for (Entity node : type.getType(client)) { if (node != null && node.getX() == facing.getX() && node.getY() == facing.getY() && node.getZ() == facing.getZ()) { pool.add(node); } } } return pool.toArray(new Entity[pool.size()]); } public int onLoop() { Entity[] entitiesImFacingByMySelectedDistance = getFacingEntities( client, myPlayer(), 1, EnumSet.of(EntityType.NPC)); for(Entity cur : entitiesImFacingByMySelectedDistance) { if(cur.getName() != null && cur.getName() == "Tree") { System.out.println("I'm facing a tree, but possibly not interacting with it."); } } return 200; } } This part will tell ALL entities at a given distance away from player, so if the entities was less than, or equal to the distance you desired, and your facing it, it'll be added into the return. import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import org.osbot.script.rs2.Client; import org.osbot.script.rs2.map.Position; import org.osbot.script.rs2.model.Entity; import org.osbot.script.rs2.model.NPC; import org.osbot.script.rs2.model.Player; import java.awt.*; import java.util.ArrayDeque; import java.util.EnumSet; import java.util.List; /** * @author Brainfree */ @ScriptManifest(author = "Brainfree", version = 1.0, info = "Tells all entities you're facing, within a given distance.", name = "FutureViewer") public class AllFacingEntities extends Script { public enum DirectionalOrientation { NORTH_WEST(-1, 1, 135), NORTH(0, 1, 90), NORTH_EAST(1, 1, 45), EAST(1, 0, 0), SOUTH_EAST(1, -1, 315), SOUTH(0, -1, 270), SOUTH_WEST(-1, -1, 225), WEST(-1, 0, 180); public final int x_shift, y_shift, angle; DirectionalOrientation(int x_shift, int y_shift, int angle) { this.x_shift = x_shift; this.y_shift = y_shift; this.angle = angle; } } enum EntityType { OBJECT { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getObjects(); } }, NPC { @Override public List<? extends Entity> getType(Client client) { return client.getLocalNPCs(); } }, PLAYER { @Override public List<? extends Entity> getType(Client client) { return client.getLocalPlayers(); } }, GROUND_ITEM { @Override public List<? extends Entity> getType(Client client) { return client.getCurrentRegion().getItems(); } }; public abstract List<? extends Entity> getType(Client client); } public Position getFacingPosition(Player player) { int angle_shift = (player.getRotation() / 0x100) * 45; angle_shift -= 270; if (angle_shift > 0) angle_shift += 270; angle_shift = Math.abs(angle_shift) + 180; if(angle_shift >= 360) angle_shift-= 360; for (DirectionalOrientation orientation : DirectionalOrientation.values()) { if (orientation.angle == angle_shift) { return new Position( player.getX() + orientation.x_shift, player.getY() + orientation.y_shift, player.getZ() ); } } return null; } public static boolean lineContainsPoint(double Ax, double Ay, double Bx, double By, double Px, double Py) { double cross_product = (Py - Ay) * (Bx - Ax) - (Px - Ax) * (By - Ay); double dotproduct = (Px - Ax) * (Bx - Ax) + (Py - Ay) * (By - Ay); return Math.abs((cross_product)) == 0 && dotproduct < 0; } public Entity[] getFacingEntities(Client client, Player player, int distanceInTiles, EnumSet<EntityType> checkFor) { if (checkFor == null || checkFor.size() == 0) return new Entity[0]; final Position facing = getFacingPosition(player); final Position me = client.getMyPlayer().getPosition(); if (facing == null) return new Entity[0]; ArrayDeque<Entity> pool = new ArrayDeque<Entity>(); for (EntityType type : checkFor) { for (Entity node : type.getType(client)) { if (node != null && lineContainsPoint( me.getX(), me.getY(), facing.getX(), facing.getY(), node.getX(), node.getY()) && Math.hypot(node.getX() - me.getX(), node.getY() - me.getY() ) <= distanceInTiles) { pool.add(node); } } } return pool.toArray(new Entity[pool.size()]); } public int onLoop() { Entity[] AllEntitiesImFacingWithinADistanceOf3 = getFacingEntities(client, myPlayer(), 3, EnumSet.of( EntityType.OBJECT, EntityType.NPC)); for(Entity whatImFacing : AllEntitiesImFacingWithinADistanceOf3) { if(whatImFacing instanceof NPC && whatImFacing.getName() == "Banker tutor") { System.out.println("I'm facing a banker tutor :}, she could be 3 tiles away, or even less >_>"); } } return 500; } public void onPaint(Graphics graphics) { Entity[] AllEntitiesImFacingWithinADistanceOf3 = getFacingEntities(client, myPlayer(), 3, EnumSet.of( EntityType.OBJECT, EntityType.NPC)); for(Entity whatImFacing : AllEntitiesImFacingWithinADistanceOf3) { ((Graphics2D) graphics).draw(whatImFacing.getMouseDestination().getArea()); } } } Hope this helps. /Updated, forgot to implement the distance into it. /Updated, as requested by wiz, added code for all facing entities, within a given distance.2 points
-
"You're unable to pick the fruit" is the string returned when you try to pick a strange plant that isn't yours. I decided to make a topic because I know Maxi was asking.1 point
-
Script writers love it when you help them find errors in their script. But the usual Doesn't really help well... There is a way to get the full error so you can see exactly where the problem in the script is. As you can see on the screenshot above I can see exactly what and where in the script causes the error. This is way more useful and it would be great if more people used this. How does it work: Open a notepad and type the following text: "C:\Program Files\Java\jdk1.7.0_07\bin\java.exe" -jar osbot_1.4.5.jar -dev Change the directory to your JDK version and change the 'osbot_1.4.5.jar' to the osbot.jar file you downloaded from OSBot's website. Make sure there aren't any spaces in the name because that won't allow it to work. After you found the corrent directory and changed the name of the osbot.jar file to yours SAVE THE FILE AS... run.bat and make sure to select all files(*): After you named it, save it or place it in the same folder as your osbot.jar file1 point
-
Who cares if there's only 1-3 scripts that are stable past 1+ hours If OSbot was a bakery, all the baked goods would be on display shelves in the front of the store. Of course, there's other bots on the internet. They can be the other bakery shops. The great thing about OSbot's bakery is all the food doesn't cost a penny. OSbot's bakery treats are all free! When you buy treats from the other stores, they cost money so you expect something good in value in return and that's what you get. But at OSBOT's bakery, everythings free, so don't expect more than a cows ass of a script. You don't pay for shit, so OSbot's doesn't owe you.1 point
-
1 point