├── resources ├── version.txt ├── images │ ├── add.png │ ├── bot.png │ ├── close.png │ ├── home.png │ ├── icon.png │ ├── mouse.png │ ├── tick.png │ ├── connect.png │ ├── delete.png │ ├── add_down.png │ ├── add_over.png │ ├── close_over.png │ ├── disconnect.png │ ├── keyboard.png │ ├── script_bdl.png │ ├── script_drm.png │ ├── script_pre.png │ ├── script_src.png │ ├── world_link.png │ ├── control_play.png │ ├── control_stop.png │ ├── control_pause.png │ └── control_play_blue.png ├── Manifest.txt ├── ads.txt ├── compile-scripts.sh ├── Compile-Scripts.bat └── FindJDK.bat ├── .gitmodules ├── src └── org │ └── rsbot │ ├── client │ ├── Graphic.java │ ├── LDModel.java │ ├── HDModel.java │ ├── RSObjectComposite.java │ ├── DetailInfo.java │ ├── RSNPCDefLoader.java │ ├── DefLoader.java │ ├── HashTable.java │ ├── RSObjectDefLoader.java │ ├── Settings.java │ ├── TileData.java │ ├── RSNPCNode.java │ ├── ServerData.java │ ├── NodeListCache.java │ ├── HardReference.java │ ├── RSInterfaceNode.java │ ├── Reference.java │ ├── DetailInfoNode.java │ ├── Loader.java │ ├── StatusNodeListLoader.java │ ├── RSGroundEntity.java │ ├── RSItem.java │ ├── RSItemDefLoader.java │ ├── NodeDeque.java │ ├── NodeSubQueue.java │ ├── RSInteractableDef.java │ ├── StatusNode.java │ ├── ChatLine.java │ ├── Node.java │ ├── NodeSub.java │ ├── RSNPC.java │ ├── SoftReference.java │ ├── StatusNodeList.java │ ├── RSInteractable.java │ ├── RSAnimableNode.java │ ├── RSGroundData.java │ ├── RSPlayerComposite.java │ ├── RSNPCDef.java │ ├── RSObjectDef.java │ ├── MenuItemNode.java │ ├── RSGroundObject.java │ ├── Cache.java │ ├── RSObject.java │ ├── RSAnimable.java │ ├── Signlink.java │ ├── RSPlayer.java │ ├── MenuGroupNode.java │ ├── Model.java │ ├── Callback.java │ ├── RSItemDef.java │ ├── Render.java │ ├── input │ │ ├── Focus.java │ │ └── Keyboard.java │ ├── RSCharacter.java │ ├── RSGround.java │ ├── RenderData.java │ ├── ModelCapture.java │ ├── RSInterface.java │ └── Client.java │ ├── event │ ├── listeners │ │ ├── PaintListener.java │ │ ├── MessageListener.java │ │ ├── ServerMessageListener.java │ │ ├── CharacterMovedListener.java │ │ └── TextPaintListener.java │ ├── events │ │ ├── RSEvent.java │ │ ├── ServerMessageEvent.java │ │ ├── PaintEvent.java │ │ ├── MessageEvent.java │ │ ├── TextPaintEvent.java │ │ └── CharacterMovedEvent.java │ └── impl │ │ ├── CharacterMovedLogger.java │ │ ├── MessageLogger.java │ │ ├── TLoginIndex.java │ │ ├── TFloorHeight.java │ │ ├── TUserInputAllowed.java │ │ ├── TTab.java │ │ ├── TMenuActions.java │ │ ├── TPlayerPosition.java │ │ ├── TAnimation.java │ │ ├── TFPS.java │ │ ├── TMousePosition.java │ │ ├── TMenu.java │ │ ├── TCamera.java │ │ ├── DrawInventory.java │ │ ├── DrawGround.java │ │ ├── DrawWeb.java │ │ ├── DrawNPCs.java │ │ ├── DrawSettings.java │ │ ├── DrawItems.java │ │ ├── DrawPlayers.java │ │ └── DrawObjects.java │ ├── script │ ├── wrappers │ │ ├── RSVerifiable.java │ │ ├── RSStaticModel.java │ │ ├── RSItemDef.java │ │ ├── RSObjectDef.java │ │ ├── RSObjectModel.java │ │ ├── RSAnimableModel.java │ │ ├── RSWebSkeleton.java │ │ ├── RSWebTile.java │ │ ├── RSCharacterModel.java │ │ ├── RSTile.java │ │ ├── RSPlayer.java │ │ ├── GEItemInfo.java │ │ ├── RSWebMap.java │ │ ├── RSPath.java │ │ ├── RSGroundItem.java │ │ ├── RSNPC.java │ │ └── RSWebPath.java │ ├── PassiveScriptManifest.java │ ├── internal │ │ ├── event │ │ │ ├── PassiveScriptListener.java │ │ │ └── ScriptListener.java │ │ ├── wrappers │ │ │ ├── HashTable.java │ │ │ ├── Queue.java │ │ │ ├── Deque.java │ │ │ ├── StatusQueue.java │ │ │ └── TileFlags.java │ │ ├── BreakHandler.java │ │ └── PassiveScriptHandler.java │ ├── methods │ │ ├── Web.java │ │ ├── Account.java │ │ ├── Nodes.java │ │ ├── Keyboard.java │ │ ├── Settings.java │ │ └── MethodProvider.java │ ├── util │ │ ├── Filter.java │ │ └── Timer.java │ ├── ScriptManifest.java │ ├── randoms │ │ ├── TeleotherCloser.java │ │ ├── LeaveSafeArea.java │ │ ├── SystemUpdate.java │ │ ├── BankPins.java │ │ ├── FirstTimeDeath.java │ │ ├── Pinball.java │ │ └── CloseAllInterface.java │ ├── PassiveScript.java │ └── passives │ │ └── WebLoader.java │ ├── log │ ├── SystemConsoleHandler.java │ ├── TextAreaLogHandler.java │ └── LogFormatter.java │ ├── service │ ├── ScriptSource.java │ ├── ServiceException.java │ ├── ScriptDefinition.java │ ├── Monitoring.java │ ├── LoginManager.java │ ├── ScriptClassLoader.java │ ├── TwitterUpdates.java │ └── WebQueue.java │ ├── loader │ ├── script │ │ ├── ParseException.java │ │ ├── adapter │ │ │ ├── AddFieldAdapter.java │ │ │ ├── AddInterfaceAdapter.java │ │ │ ├── AddMethodAdapter.java │ │ │ ├── SetSignatureAdapter.java │ │ │ ├── SetSuperAdapter.java │ │ │ └── AddGetterAdapter.java │ │ └── Buffer.java │ └── asm │ │ ├── Handler.java │ │ ├── FieldVisitor.java │ │ ├── Edge.java │ │ ├── ClassAdapter.java │ │ └── AnnotationVisitor.java │ ├── bot │ ├── CallbackImpl.java │ └── Crawler.java │ ├── Boot.java │ ├── Application.java │ ├── util │ ├── UIDData.java │ ├── ScreenshotUtil.java │ ├── PreferenceData.java │ ├── HttpAgent.java │ └── IniParser.java │ └── gui │ └── BotHome.java ├── .gitignore ├── Makefile ├── README.md └── make.bat /resources/version.txt: -------------------------------------------------------------------------------- 1 | 241 2 | -------------------------------------------------------------------------------- /resources/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/add.png -------------------------------------------------------------------------------- /resources/images/bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/bot.png -------------------------------------------------------------------------------- /resources/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/close.png -------------------------------------------------------------------------------- /resources/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/home.png -------------------------------------------------------------------------------- /resources/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/icon.png -------------------------------------------------------------------------------- /resources/images/mouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/mouse.png -------------------------------------------------------------------------------- /resources/images/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/tick.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "scripts"] 2 | path = scripts 3 | url = https://github.com/powerbot/Scripts.git 4 | -------------------------------------------------------------------------------- /resources/images/connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/connect.png -------------------------------------------------------------------------------- /resources/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/delete.png -------------------------------------------------------------------------------- /resources/images/add_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/add_down.png -------------------------------------------------------------------------------- /resources/images/add_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/add_over.png -------------------------------------------------------------------------------- /resources/images/close_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/close_over.png -------------------------------------------------------------------------------- /resources/images/disconnect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/disconnect.png -------------------------------------------------------------------------------- /resources/images/keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/keyboard.png -------------------------------------------------------------------------------- /resources/images/script_bdl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/script_bdl.png -------------------------------------------------------------------------------- /resources/images/script_drm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/script_drm.png -------------------------------------------------------------------------------- /resources/images/script_pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/script_pre.png -------------------------------------------------------------------------------- /resources/images/script_src.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/script_src.png -------------------------------------------------------------------------------- /resources/images/world_link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/world_link.png -------------------------------------------------------------------------------- /resources/images/control_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/control_play.png -------------------------------------------------------------------------------- /resources/images/control_stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/control_stop.png -------------------------------------------------------------------------------- /resources/images/control_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/control_pause.png -------------------------------------------------------------------------------- /resources/images/control_play_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ineedajob/RSBot/HEAD/resources/images/control_play_blue.png -------------------------------------------------------------------------------- /src/org/rsbot/client/Graphic.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface Graphic { 4 | 5 | int getID(); 6 | 7 | } -------------------------------------------------------------------------------- /src/org/rsbot/client/LDModel.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface LDModel extends Model { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/HDModel.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface HDModel extends Model { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSObjectComposite.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSObjectComposite { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/DetailInfo.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface DetailInfo { 4 | int getDetailLevel(); 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSNPCDefLoader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSNPCDefLoader extends DefLoader { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/DefLoader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface DefLoader { 4 | 5 | Cache getCache(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/HashTable.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface HashTable { 4 | 5 | Node[] getBuckets(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSObjectDefLoader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSObjectDefLoader extends DefLoader { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Settings.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface Settings { 4 | 5 | public int[] getData(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/TileData.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface TileData { 4 | 5 | int[][] getHeights(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSNPCNode.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSNPCNode extends Node { 4 | public RSNPC getRSNPC(); 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/ServerData.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface ServerData { 4 | 5 | public int getWorldID(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/NodeListCache.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface NodeListCache { 4 | 5 | NodeDeque getNodeList(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/HardReference.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface HardReference extends Reference { 4 | 5 | Object get(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSInterfaceNode.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSInterfaceNode extends Node { 4 | 5 | int getMainID(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Reference.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface Reference extends NodeSub { 4 | 5 | public int getIndex(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/DetailInfoNode.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface DetailInfoNode extends Node { 4 | public DetailInfo getDetailInfo(); 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Loader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | import java.applet.Applet; 4 | 5 | public interface Loader { 6 | public Applet getClient(); 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/StatusNodeListLoader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface StatusNodeListLoader { 4 | public StatusNodeList getList(); 5 | } 6 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSGroundEntity.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | /** 4 | * @author Jacmob 5 | */ 6 | public interface RSGroundEntity extends RSAnimable { 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSItem.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSItem { 4 | 5 | int getID(); 6 | 7 | int getStackSize(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSItemDefLoader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSItemDefLoader extends DefLoader { 4 | 5 | boolean isMembers(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/NodeDeque.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface NodeDeque { 4 | 5 | Node getCurrent(); 6 | 7 | Node getTail(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/NodeSubQueue.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface NodeSubQueue { 4 | 5 | NodeSub getCurrent(); 6 | 7 | NodeSub getTail(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSInteractableDef.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSInteractableDef extends StatusNode { 4 | 5 | RSInteractable getRSInteractable(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/StatusNode.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface StatusNode { 4 | 5 | StatusNode getNext(); 6 | 7 | StatusNode getPrevious(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/ChatLine.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface ChatLine { 4 | 5 | public String getName(); 6 | 7 | public String getMessage(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Node.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface Node { 4 | 5 | long getID(); 6 | 7 | Node getNext(); 8 | 9 | Node getPrevious(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/org/rsbot/client/NodeSub.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface NodeSub extends Node { 4 | 5 | NodeSub getNextSub(); 6 | 7 | NodeSub getPrevSub(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSNPC.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSNPC extends RSCharacter { 4 | 5 | RSNPCDef getRSNPCDef(); 6 | 7 | int getLevel(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/SoftReference.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface SoftReference extends Reference { 4 | 5 | java.lang.ref.SoftReference getReference(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/org/rsbot/client/StatusNodeList.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface StatusNodeList { 4 | 5 | StatusNode getHead(); 6 | 7 | StatusNode getNext(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSInteractable.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSInteractable { 4 | 5 | int getX(); 6 | 7 | int getY(); 8 | 9 | byte getPlane(); 10 | } 11 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSAnimableNode.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSAnimableNode { 4 | 5 | RSAnimableNode getNext(); 6 | 7 | RSAnimable getRSAnimable(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSGroundData.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSGroundData { 4 | 5 | int[][] getBlocks(); 6 | 7 | int getX(); 8 | 9 | int getY(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSPlayerComposite.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | /** 4 | * @author Jacmob 5 | */ 6 | public interface RSPlayerComposite { 7 | 8 | int getNPCID(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSNPCDef.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSNPCDef { 4 | 5 | String[] getActions(); 6 | 7 | String getName(); 8 | 9 | int getType(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSObjectDef.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSObjectDef { 4 | 5 | String[] getActions(); 6 | 7 | int[] getChildrenIDs(); 8 | 9 | String getName(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /resources/Manifest.txt: -------------------------------------------------------------------------------- 1 | Main-Class: org.rsbot.Boot 2 | 3 | Name: org/rsbot 4 | Sealed: true 5 | Specification-Title: "RSBot" 6 | Specification-Vendor: "org.rsbot" 7 | Implementation-Title: "RSBot" 8 | Implementation-Vendor: "org.rsbot" 9 | -------------------------------------------------------------------------------- /src/org/rsbot/client/MenuItemNode.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface MenuItemNode extends NodeSub { 4 | 5 | String getAction(); 6 | 7 | String getOption(); 8 | 9 | int getType(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSGroundObject.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSGroundObject extends RSGroundEntity { 4 | 5 | int getID(); 6 | 7 | int getStackSize(); 8 | 9 | Model getModel(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Cache.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface Cache { 4 | 5 | HashTable getTable(); 6 | 7 | int getInitialCount(); 8 | 9 | int getSpaceLeft(); 10 | 11 | NodeSubQueue getList(); 12 | } 13 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSObject.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSObject { 4 | 5 | int getID(); 6 | 7 | int getType(); 8 | 9 | int getX(); 10 | 11 | int getY(); 12 | 13 | Model getModel(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSAnimable.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSAnimable extends RSInteractable { 4 | 5 | short getX1(); 6 | 7 | short getX2(); 8 | 9 | short getY1(); 10 | 11 | short getY2(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.diff 3 | *.patch 4 | .svn 5 | /*.iml 6 | /*.ipr 7 | /*.iws 8 | /*.jar 9 | /.classpath 10 | /.file_store_32 11 | /.idea 12 | /.jagex_cache_32 13 | /.project 14 | /.settings 15 | /bin 16 | /lib/*.jar 17 | /scripts/*.class 18 | /temp.txt 19 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Signlink.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | import java.applet.Applet; 4 | import java.awt.*; 5 | 6 | public interface Signlink { 7 | 8 | public EventQueue getEventQueue(); 9 | 10 | public Applet getGameApplet(); 11 | } 12 | -------------------------------------------------------------------------------- /src/org/rsbot/event/listeners/PaintListener.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.listeners; 2 | 3 | import java.awt.*; 4 | import java.util.EventListener; 5 | 6 | public interface PaintListener extends EventListener { 7 | public void onRepaint(Graphics render); 8 | } 9 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSPlayer.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSPlayer extends RSCharacter { 4 | 5 | int getLevel(); 6 | 7 | String getName(); 8 | 9 | int getTeam(); 10 | 11 | RSPlayerComposite getComposite(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/org/rsbot/client/MenuGroupNode.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | /** 4 | * @author Jacmob 5 | */ 6 | public interface MenuGroupNode extends NodeSub { 7 | 8 | NodeSubQueue getItems(); 9 | 10 | String getOption(); 11 | 12 | int size(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/org/rsbot/event/listeners/MessageListener.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.listeners; 2 | 3 | import org.rsbot.event.events.MessageEvent; 4 | 5 | import java.util.EventListener; 6 | 7 | public interface MessageListener extends EventListener { 8 | abstract void messageReceived(MessageEvent e); 9 | } 10 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSVerifiable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | 6 | package org.rsbot.script.wrappers; 7 | 8 | /** 9 | * @author Nader Sleiman 10 | */ 11 | public interface RSVerifiable { 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/org/rsbot/log/SystemConsoleHandler.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.log; 2 | 3 | import java.util.logging.ConsoleHandler; 4 | 5 | /** 6 | * Logs to System.out 7 | */ 8 | public class SystemConsoleHandler extends ConsoleHandler { 9 | public SystemConsoleHandler() { 10 | super(); 11 | setOutputStream(System.out); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Model.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface Model { 4 | public int[] getXPoints(); 5 | 6 | public int[] getYPoints(); 7 | 8 | public int[] getZPoints(); 9 | 10 | public short[] getIndices1(); 11 | 12 | public short[] getIndices2(); 13 | 14 | public short[] getIndices3(); 15 | } 16 | -------------------------------------------------------------------------------- /src/org/rsbot/service/ScriptSource.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | import org.rsbot.script.Script; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Jacmob 9 | */ 10 | public interface ScriptSource { 11 | 12 | List list(); 13 | 14 | Script load(ScriptDefinition def) throws ServiceException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/org/rsbot/event/listeners/ServerMessageListener.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.listeners; 2 | 3 | import org.rsbot.event.events.ServerMessageEvent; 4 | 5 | import java.util.EventListener; 6 | 7 | @Deprecated 8 | public interface ServerMessageListener extends EventListener { 9 | abstract void serverMessageRecieved(ServerMessageEvent e); 10 | } 11 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Callback.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | import org.rsbot.bot.Bot; 4 | 5 | public interface Callback { 6 | 7 | public Bot getBot(); 8 | 9 | public void notifyMessage(int id, String sender, String msg); 10 | 11 | public void rsCharacterMoved(RSCharacter c, int i); 12 | 13 | public void updateRenderInfo(Render r, RenderData rd); 14 | } 15 | -------------------------------------------------------------------------------- /src/org/rsbot/service/ServiceException.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | /** 4 | * @author Jacmob 5 | */ 6 | public class ServiceException extends Exception { 7 | 8 | /** 9 | * Exception message 10 | */ 11 | private static final long serialVersionUID = -7803126953457755292L; 12 | 13 | public ServiceException(String message) { 14 | super(message); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSItemDef.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSItemDef { 4 | 5 | String[] getActions(); 6 | 7 | int getCertID(); 8 | 9 | int getCertTemplateID(); 10 | 11 | String[] getGroundActions(); 12 | 13 | int getID(); 14 | 15 | String getName(); 16 | 17 | boolean isMembersObject(); 18 | 19 | RSItemDefLoader getLoader(); 20 | } 21 | -------------------------------------------------------------------------------- /src/org/rsbot/event/listeners/CharacterMovedListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.rsbot.event.listeners; 5 | 6 | import org.rsbot.event.events.CharacterMovedEvent; 7 | 8 | import java.util.EventListener; 9 | 10 | /** 11 | * @author Qauters 12 | */ 13 | public interface CharacterMovedListener extends EventListener { 14 | public void characterMoved(CharacterMovedEvent e); 15 | } 16 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/ParseException.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script; 2 | 3 | /** 4 | * @author Jacmob 5 | */ 6 | public class ParseException extends Exception { 7 | 8 | /** 9 | * Exception Message 10 | */ 11 | private static final long serialVersionUID = -7099026388712137749L; 12 | 13 | public ParseException(String message) { 14 | super(message); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/org/rsbot/script/PassiveScriptManifest.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.RUNTIME) 7 | public @interface PassiveScriptManifest { 8 | 9 | String name(); 10 | 11 | double version() default 1.0; 12 | 13 | String description() default ""; 14 | 15 | String[] authors(); 16 | } 17 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Render.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | /** 4 | * GraphicsToolkit 5 | */ 6 | public interface Render { 7 | 8 | int getAbsoluteX1(); 9 | 10 | int getAbsoluteX2(); 11 | 12 | int getAbsoluteY1(); 13 | 14 | int getAbsoluteY2(); 15 | 16 | int getXMultiplier(); 17 | 18 | int getYMultiplier(); 19 | 20 | int getZFar(); 21 | 22 | int getZNear(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/org/rsbot/service/ScriptDefinition.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | /** 4 | * @author Jacmob 5 | */ 6 | public class ScriptDefinition { 7 | 8 | public int id; 9 | 10 | public String name; 11 | 12 | public double version; 13 | 14 | public String description; 15 | 16 | public String[] authors; 17 | 18 | public String[] keywords; 19 | 20 | public String website; 21 | 22 | public ScriptSource source; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/event/PassiveScriptListener.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal.event; 2 | 3 | import org.rsbot.script.PassiveScript; 4 | import org.rsbot.script.internal.PassiveScriptHandler; 5 | 6 | public interface PassiveScriptListener { 7 | 8 | public void scriptStarted(PassiveScriptHandler handler, PassiveScript script); 9 | 10 | public void scriptStopped(PassiveScriptHandler handler, PassiveScript script); 11 | } 12 | -------------------------------------------------------------------------------- /src/org/rsbot/event/listeners/TextPaintListener.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.listeners; 2 | 3 | import java.awt.*; 4 | import java.util.EventListener; 5 | 6 | public interface TextPaintListener extends EventListener { 7 | /** 8 | * Argument is the line number to start drawing from. 9 | *

10 | * Returns the line number + number of lines actually drawn. 11 | */ 12 | public int drawLine(Graphics render, int idx); 13 | } 14 | -------------------------------------------------------------------------------- /src/org/rsbot/script/methods/Web.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.methods; 2 | 3 | import org.rsbot.script.internal.wrappers.TileFlags; 4 | import org.rsbot.script.wrappers.RSTile; 5 | 6 | import java.util.HashMap; 7 | 8 | public class Web extends MethodProvider { 9 | public static final HashMap map = new HashMap(); 10 | public static boolean loaded = false; 11 | 12 | Web(final MethodContext ctx) { 13 | super(ctx); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/org/rsbot/client/input/Focus.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client.input; 2 | 3 | import java.awt.event.FocusEvent; 4 | import java.awt.event.FocusListener; 5 | 6 | public abstract class Focus implements FocusListener { 7 | public abstract void _focusGained(FocusEvent e); 8 | 9 | public abstract void _focusLost(FocusEvent e); 10 | 11 | public final void focusGained(final FocusEvent e) { 12 | _focusGained(e); 13 | } 14 | 15 | public final void focusLost(final FocusEvent e) { 16 | _focusLost(e); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/org/rsbot/event/events/RSEvent.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.events; 2 | 3 | import java.util.EventListener; 4 | import java.util.EventObject; 5 | 6 | public abstract class RSEvent extends EventObject { 7 | 8 | private static final long serialVersionUID = 6977096569226837605L; 9 | 10 | private static final Object SOURCE = new Object(); 11 | 12 | public RSEvent() { 13 | super(RSEvent.SOURCE); 14 | } 15 | 16 | public abstract void dispatch(EventListener el); 17 | 18 | public abstract long getMask(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/org/rsbot/script/util/Filter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.util; 2 | 3 | /** 4 | * Provides a predicate that determines whether or not 5 | * a given input should be filtered out of a collection. 6 | * 7 | * @author Jacmob 8 | */ 9 | public interface Filter { 10 | 11 | /** 12 | * Determines whether a given input 13 | * should be included or excluded. 14 | * 15 | * @param t The input. 16 | * @return true to include; 17 | * false to exclude. 18 | */ 19 | public boolean accept(T t); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /resources/ads.txt: -------------------------------------------------------------------------------- 1 | # 0 to disable, 1 to enable 2 | enabled = 0 3 | 4 | # advertiser web address 5 | link = http://links.powerbot.org/botad 6 | 7 | # banner image URL 8 | image = http://links.powerbot.org/botad-img 9 | 10 | # log text 11 | text = 12 | 13 | # 0 to disable link popup every refresh, 1 to enable 14 | popup = 1 15 | 16 | # image cache lifetime (in minutes) and popup frequency 17 | refresh = 86400 18 | 19 | # last update (in yyyyMMddHHmm UTC), forces refresh if this is more recent than cache date 20 | updated = 201104170740 -------------------------------------------------------------------------------- /src/org/rsbot/client/RSCharacter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSCharacter extends RSAnimable { 4 | 5 | int getAnimation(); 6 | 7 | Graphic[] getGraphicsData(); 8 | 9 | int getHeight(); 10 | 11 | int getHPRatio(); 12 | 13 | int getInteracting(); 14 | 15 | int[] getLocationX(); 16 | 17 | int[] getLocationY(); 18 | 19 | int getOrientation(); 20 | 21 | int getLoopCycleStatus(); 22 | 23 | String getMessage(); 24 | 25 | int isMoving(); 26 | 27 | Model getModel(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/rsbot/script/ScriptManifest.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.RUNTIME) 7 | public @interface ScriptManifest { 8 | 9 | String name(); 10 | 11 | double version() default 1.0; 12 | 13 | String description() default ""; 14 | 15 | String[] authors(); 16 | 17 | String[] keywords() default {}; 18 | 19 | String website() default ""; 20 | 21 | int requiresVersion() default 200; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSGround.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSGround { 4 | 5 | byte getPlane1(); 6 | 7 | byte getPlane2(); 8 | 9 | RSAnimableNode getRSAnimableList(); 10 | 11 | RSInteractable getFloorDecoration(); 12 | 13 | RSInteractable getBoundary1(); 14 | 15 | RSInteractable getBoundary2(); 16 | 17 | RSInteractable getWallDecoration1(); 18 | 19 | RSInteractable getWallDecoration2(); 20 | 21 | RSGroundEntity getGroundObject(); 22 | 23 | short getX(); 24 | 25 | short getY(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RenderData.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | /** 4 | * Viewport 5 | */ 6 | public interface RenderData { 7 | 8 | // x calculation values 9 | float getXOff(); 10 | 11 | float getXX(); 12 | 13 | float getXY(); 14 | 15 | float getXZ(); 16 | 17 | // y calculation values 18 | float getYOff(); 19 | 20 | float getYX(); 21 | 22 | float getYY(); 23 | 24 | float getYZ(); 25 | 26 | // z calculation values 27 | float getZOff(); 28 | 29 | float getZX(); 30 | 31 | float getZY(); 32 | 33 | float getZZ(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSStaticModel.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.client.LDModel; 4 | import org.rsbot.script.methods.MethodContext; 5 | 6 | class RSStaticModel extends RSModel { 7 | 8 | private final int x, y; 9 | 10 | RSStaticModel(MethodContext ctx, LDModel model, int x, int y) { 11 | super(ctx, model); 12 | this.x = x; 13 | this.y = y; 14 | } 15 | 16 | protected void update() { 17 | 18 | } 19 | 20 | protected int getLocalX() { 21 | return x; 22 | } 23 | 24 | protected int getLocalY() { 25 | return y; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/org/rsbot/log/TextAreaLogHandler.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.log; 2 | 3 | import org.rsbot.gui.LogTextArea; 4 | 5 | import java.util.logging.Handler; 6 | import java.util.logging.LogRecord; 7 | 8 | public class TextAreaLogHandler extends Handler { 9 | 10 | public static final LogTextArea TEXT_AREA = new LogTextArea(); 11 | 12 | @Override 13 | public void close() throws SecurityException { 14 | } 15 | 16 | @Override 17 | public void flush() { 18 | } 19 | 20 | @Override 21 | public void publish(final LogRecord record) { 22 | TextAreaLogHandler.TEXT_AREA.log(record); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/CharacterMovedLogger.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.event.events.CharacterMovedEvent; 4 | import org.rsbot.event.listeners.CharacterMovedListener; 5 | 6 | import java.util.logging.Logger; 7 | 8 | public class CharacterMovedLogger implements CharacterMovedListener { 9 | 10 | private final Logger log = Logger.getLogger(CharacterMovedLogger.class.getName()); 11 | 12 | public void characterMoved(final CharacterMovedEvent e) { 13 | log.info("Character Moved: " + String.format("%2d %s", e.getDirection(), e.getCharacter().toString())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/org/rsbot/service/Monitoring.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | 4 | /** 5 | * @author Paris 6 | */ 7 | public class Monitoring { 8 | public static enum Event { 9 | Start, Finish, Random, Script, Hack 10 | } 11 | 12 | public static void RandomStarted(final String name) { 13 | RaiseEvent(Event.Random, new String[]{name}); 14 | } 15 | 16 | public static void RandomFinished(final String name, final boolean passed) { 17 | RaiseEvent(Event.Random, new String[]{name, Boolean.toString(passed)}); 18 | } 19 | 20 | public static void RaiseEvent(final Event type, String[] params) { 21 | //TODO Create the sending of an event. 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/MessageLogger.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.event.events.MessageEvent; 4 | import org.rsbot.event.listeners.MessageListener; 5 | 6 | import java.util.logging.Logger; 7 | 8 | public class MessageLogger implements MessageListener { 9 | 10 | private final Logger log = Logger.getLogger(MessageLogger.class.getName()); 11 | 12 | public void messageReceived(final MessageEvent e) { 13 | if (e.getSender().equals("")) { 14 | log.info("[" + e.getID() + "] " + e.getMessage()); 15 | } else { 16 | log.info("[" + e.getID() + "] " + e.getSender() + ": " + e.getMessage()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/event/ScriptListener.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal.event; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.script.Script; 5 | import org.rsbot.script.internal.ScriptHandler; 6 | 7 | /** 8 | * @author Jacmob 9 | */ 10 | public interface ScriptListener { 11 | 12 | public void scriptStarted(ScriptHandler handler, Script script); 13 | 14 | public void scriptStopped(ScriptHandler handler, Script script); 15 | 16 | public void scriptResumed(ScriptHandler handler, Script script); 17 | 18 | public void scriptPaused(ScriptHandler handler, Script script); 19 | 20 | public void inputChanged(Bot bot, int mask); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSItemDef.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | /** 4 | * An item definition. 5 | */ 6 | public class RSItemDef { 7 | private final org.rsbot.client.RSItemDef id; 8 | 9 | public RSItemDef(final org.rsbot.client.RSItemDef id) { 10 | this.id = id; 11 | } 12 | 13 | public String[] getActions() { 14 | return id.getActions(); 15 | } 16 | 17 | public String[] getGroundActions() { 18 | return id.getGroundActions(); 19 | } 20 | 21 | public String getName() { 22 | return id.getName(); 23 | } 24 | 25 | public boolean isMembers() { 26 | return id.isMembersObject(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TLoginIndex.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | import org.rsbot.script.methods.Game; 6 | import org.rsbot.util.StringUtil; 7 | 8 | import java.awt.*; 9 | 10 | public class TLoginIndex implements TextPaintListener { 11 | 12 | private final Game game; 13 | 14 | public TLoginIndex(Bot bot) { 15 | game = bot.getMethodContext().game; 16 | } 17 | 18 | public int drawLine(final Graphics render, int idx) { 19 | StringUtil.drawLine(render, idx++, "Client State: " + game.getClientState()); 20 | return idx; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSObjectDef.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | /** 4 | * An object definition. 5 | */ 6 | public class RSObjectDef { 7 | private final org.rsbot.client.RSObjectDef od; 8 | 9 | public RSObjectDef(final org.rsbot.client.RSObjectDef od) { 10 | this.od = od; 11 | } 12 | 13 | public String[] getActions() { 14 | return od.getActions(); 15 | } 16 | 17 | public int[] getChildIDs() { 18 | return od.getChildrenIDs(); 19 | } 20 | 21 | public int getID() { 22 | // return od.getType(); 23 | return -1; 24 | } 25 | 26 | public String getName() { 27 | return od.getName(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/org/rsbot/service/LoginManager.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | /** 4 | * @author Timer 5 | */ 6 | public class LoginManager { 7 | 8 | private String message = null; 9 | private static final String MESSAGE_GOOD_LOGIN = "Identified correctly."; 10 | 11 | /** 12 | * Checks if your username and password is valid. 13 | * 14 | * @return true if correct; otherwise false. 15 | */ 16 | public boolean valid() { 17 | message = MESSAGE_GOOD_LOGIN; 18 | return true; 19 | } 20 | 21 | /** 22 | * Return message. 23 | * 24 | * @return The login message. 25 | */ 26 | public String message() { 27 | return message; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSObjectModel.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.client.Model; 4 | import org.rsbot.client.RSObject; 5 | import org.rsbot.script.methods.MethodContext; 6 | 7 | class RSObjectModel extends RSModel { 8 | 9 | private final RSObject object; 10 | 11 | RSObjectModel(MethodContext ctx, Model model, RSObject object) { 12 | super(ctx, model); 13 | this.object = object; 14 | } 15 | 16 | protected void update() { 17 | 18 | } 19 | 20 | @Override 21 | protected int getLocalX() { 22 | return object.getX(); 23 | } 24 | 25 | @Override 26 | protected int getLocalY() { 27 | return object.getY(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TFloorHeight.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | import org.rsbot.script.methods.Game; 6 | import org.rsbot.util.StringUtil; 7 | 8 | import java.awt.*; 9 | 10 | public class TFloorHeight implements TextPaintListener { 11 | 12 | private final Game game; 13 | 14 | public TFloorHeight(Bot bot) { 15 | game = bot.getMethodContext().game; 16 | } 17 | 18 | public int drawLine(final Graphics render, int idx) { 19 | final int floor = game.getPlane(); 20 | StringUtil.drawLine(render, idx++, "Floor " + floor); 21 | return idx; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /resources/compile-scripts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cc=javac 4 | cflags= 5 | scripts=Scripts/Sources 6 | scriptspre=Scripts/Precompiled 7 | jarpathfile=Settings/path.txt 8 | 9 | cd ~/RSBot 10 | 11 | if [ ! -e "$jarpathfile" ]; then 12 | echo "Path file does not exist. Please run RSBot and try again." 13 | exit 14 | fi 15 | 16 | for file in $scripts/*.java 17 | do 18 | if [ ! -e "${file}" ]; then 19 | echo "No .java script source files found." 20 | exit 21 | fi 22 | done 23 | 24 | echo "Compiling scripts" 25 | for file in $scripts/*.class 26 | do 27 | if [ -e "${file}" ]; then 28 | rm -R $scripts/*.class 29 | break 30 | fi 31 | done 32 | 33 | "$cc" $cflags -cp "/$(cat $jarpathfile)" $scripts/*.java -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TUserInputAllowed.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | import org.rsbot.util.StringUtil; 6 | 7 | import java.awt.*; 8 | 9 | public class TUserInputAllowed implements TextPaintListener { 10 | 11 | private final Bot bot; 12 | 13 | public TUserInputAllowed(Bot bot) { 14 | this.bot = bot; 15 | } 16 | 17 | public int drawLine(final Graphics render, int idx) { 18 | StringUtil.drawLine(render, idx++, "User Input: " + 19 | (bot.inputFlags == 0 && !bot.overrideInput ? 20 | "[red]Disabled (" + bot.inputFlags + ")" : "[green]Enabled")); 21 | return idx; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TTab.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | import org.rsbot.script.methods.Game; 6 | import org.rsbot.util.StringUtil; 7 | 8 | import java.awt.*; 9 | 10 | public class TTab implements TextPaintListener { 11 | 12 | private final Game game; 13 | 14 | public TTab(Bot bot) { 15 | game = bot.getMethodContext().game; 16 | } 17 | 18 | public int drawLine(final Graphics render, int idx) { 19 | final int cTab = game.getCurrentTab(); 20 | StringUtil.drawLine(render, idx++, 21 | "Current Tab: " + cTab + (cTab != -1 ? " (" + Game.TAB_NAMES[cTab] + ")" : "")); 22 | return idx; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TMenuActions.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | import org.rsbot.script.methods.Menu; 6 | import org.rsbot.util.StringUtil; 7 | 8 | import java.awt.*; 9 | 10 | public class TMenuActions implements TextPaintListener { 11 | 12 | private final Menu menu; 13 | 14 | public TMenuActions(Bot bot) { 15 | menu = bot.getMethodContext().menu; 16 | } 17 | 18 | public int drawLine(final Graphics render, int idx) { 19 | final String[] items = menu.getItems(); 20 | int i = 0; 21 | for (final String item : items) { 22 | StringUtil.drawLine(render, idx++, i++ + ": [red]" + item); 23 | } 24 | return idx; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/Compile-Scripts.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | TITLE RSBot Scripts 4 | 5 | SET cc=javac 6 | SET cflags= 7 | SET scripts=Scripts\Sources 8 | SET scriptspre=Scripts\Precompiled 9 | SET jarpathfile=Settings\path.txt 10 | 11 | IF NOT EXIST "%jarpathfile%" ( 12 | ECHO Path file does not exist. Please run RSBot and try again. 13 | GOTO end 14 | ) 15 | 16 | FOR /F "delims=" %%G IN (%jarpathfile%) DO SET jarpath=%%G 17 | 18 | CALL FindJDK.bat 19 | 20 | IF NOT EXIST %scripts%\*.java ( 21 | ECHO No .java script source files found. 22 | GOTO end 23 | ) 24 | 25 | ECHO Compiling scripts 26 | ECHO. > "%scripts%\.class" 27 | DEL /F /Q "%scripts%\*.class" > NUL 28 | "%cc%" %cflags% -cp "%jarpath%" %scripts%\*.java 29 | 30 | :end 31 | PAUSE 32 | EXIT 33 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSAnimableModel.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.client.Model; 4 | import org.rsbot.client.RSAnimable; 5 | import org.rsbot.script.methods.MethodContext; 6 | 7 | /** 8 | * @author Jacmob 9 | */ 10 | class RSAnimableModel extends RSModel { 11 | 12 | private final RSAnimable animable; 13 | 14 | RSAnimableModel(MethodContext ctx, Model model, RSAnimable animable) { 15 | super(ctx, model); 16 | this.animable = animable; 17 | } 18 | 19 | protected void update() { 20 | 21 | } 22 | 23 | @Override 24 | protected int getLocalX() { 25 | return animable.getX(); 26 | } 27 | 28 | @Override 29 | protected int getLocalY() { 30 | return animable.getY(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TPlayerPosition.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | import org.rsbot.script.methods.Players; 6 | import org.rsbot.script.wrappers.RSTile; 7 | import org.rsbot.util.StringUtil; 8 | 9 | import java.awt.*; 10 | 11 | public class TPlayerPosition implements TextPaintListener { 12 | 13 | private final Players players; 14 | 15 | public TPlayerPosition(Bot bot) { 16 | players = bot.getMethodContext().players; 17 | } 18 | 19 | public int drawLine(final Graphics render, int idx) { 20 | final RSTile position = players.getMyPlayer().getLocation(); 21 | StringUtil.drawLine(render, idx++, "Position: " + position); 22 | return idx; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/adapter/AddFieldAdapter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script.adapter; 2 | 3 | import org.rsbot.loader.asm.ClassAdapter; 4 | import org.rsbot.loader.asm.ClassVisitor; 5 | 6 | /** 7 | * @author Jacmob 8 | */ 9 | public class AddFieldAdapter extends ClassAdapter { 10 | 11 | public static class Field { 12 | public int access; 13 | public String name; 14 | public String desc; 15 | } 16 | 17 | private final Field[] fields; 18 | 19 | public AddFieldAdapter(ClassVisitor delegate, Field[] fields) { 20 | super(delegate); 21 | this.fields = fields; 22 | } 23 | 24 | public void visitEnd() { 25 | for (Field f : fields) { 26 | cv.visitField(f.access, f.name, f.desc, null, null); 27 | } 28 | cv.visitEnd(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/org/rsbot/client/input/Keyboard.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client.input; 2 | 3 | import java.awt.event.KeyEvent; 4 | import java.awt.event.KeyListener; 5 | 6 | /** 7 | * @author Alex 8 | */ 9 | public abstract class Keyboard extends Focus implements KeyListener { 10 | public abstract void _keyPressed(KeyEvent e); 11 | 12 | public abstract void _keyReleased(KeyEvent e); 13 | 14 | public abstract void _keyTyped(KeyEvent e); 15 | 16 | public void keyPressed(final KeyEvent e) { 17 | // System.out.println(("KP"); 18 | _keyPressed(e); 19 | } 20 | 21 | public void keyReleased(final KeyEvent e) { 22 | // System.out.println(("KR"); 23 | _keyReleased(e); 24 | } 25 | 26 | public void keyTyped(final KeyEvent e) { 27 | // System.out.println(("KT"); 28 | _keyTyped(e); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TAnimation.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | import org.rsbot.script.methods.MethodContext; 6 | import org.rsbot.util.StringUtil; 7 | 8 | import java.awt.*; 9 | 10 | public class TAnimation implements TextPaintListener { 11 | 12 | private final MethodContext ctx; 13 | 14 | public TAnimation(Bot bot) { 15 | ctx = bot.getMethodContext(); 16 | } 17 | 18 | public int drawLine(final Graphics render, int idx) { 19 | int animation; 20 | if (ctx.game.isLoggedIn()) { 21 | animation = ctx.players.getMyPlayer().getAnimation(); 22 | } else { 23 | animation = -1; 24 | } 25 | StringUtil.drawLine(render, idx++, "Animation " + animation); 26 | return idx; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TFPS.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.event.listeners.TextPaintListener; 4 | import org.rsbot.util.StringUtil; 5 | 6 | import java.awt.*; 7 | 8 | public class TFPS implements TextPaintListener { 9 | 10 | private static final int LEN = 2; 11 | 12 | private final int[] frameCount = new int[TFPS.LEN]; 13 | 14 | private int lastIdx = 0; 15 | 16 | public int drawLine(final Graphics render, int idx) { 17 | final int secTime = (int) (System.currentTimeMillis() / 1000); 18 | 19 | final int prevIdx = (secTime - 1) % TFPS.LEN; 20 | StringUtil.drawLine(render, idx++, String.format("%2d fps", frameCount[prevIdx])); 21 | 22 | final int curIdx = secTime % TFPS.LEN; 23 | if (lastIdx != curIdx) { 24 | lastIdx = curIdx; 25 | frameCount[curIdx] = 1; 26 | } else { 27 | frameCount[curIdx]++; 28 | } 29 | return idx; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/org/rsbot/event/events/ServerMessageEvent.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.events; 2 | 3 | import org.rsbot.event.EventMulticaster; 4 | import org.rsbot.event.listeners.ServerMessageListener; 5 | 6 | import java.util.EventListener; 7 | 8 | /** 9 | * A server message event. 10 | */ 11 | @Deprecated 12 | public class ServerMessageEvent extends RSEvent { 13 | 14 | private static final long serialVersionUID = -2786472026976811201L; 15 | 16 | private final String message; 17 | 18 | public ServerMessageEvent(String message) { 19 | this.message = message; 20 | } 21 | 22 | @Override 23 | public void dispatch(final EventListener el) { 24 | ((ServerMessageListener) el).serverMessageRecieved(this); 25 | } 26 | 27 | @Override 28 | public long getMask() { 29 | return EventMulticaster.SERVER_MESSAGE_EVENT; 30 | } 31 | 32 | public String getMessage() { 33 | return message; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /resources/FindJDK.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | ECHO Looking for JDK 4 | 5 | SET KEY_NAME=HKLM\SOFTWARE\JavaSoft\Java Development Kit 6 | FOR /F "tokens=3" %%A IN ('REG QUERY "%KEY_NAME%" /v CurrentVersion 2^>NUL') DO SET jdkv=%%A 7 | SET jdk= 8 | 9 | IF DEFINED jdkv ( 10 | FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "%KEY_NAME%\%jdkv%" /v JavaHome 2^>NUL') DO SET jdk=%%B 11 | ) ELSE ( 12 | FOR /F "tokens=*" %%G IN ('DIR /B "%ProgramFiles%\Java\jdk*"') DO SET jdk=%%G 13 | ) 14 | 15 | SET jdk=%jdk%\bin 16 | SET javac="%jdk%\javac.exe" 17 | 18 | IF NOT EXIST %javac% ( 19 | javac -version 2>NUL 20 | IF "%ERRORLEVEL%" NEQ "0" GOTO :notfound 21 | ) ELSE ( 22 | GOTO :setpath 23 | ) 24 | GOTO :eof 25 | 26 | :notfound 27 | ECHO JDK is not installed, please download and install it from: 28 | ECHO http://java.sun.com/javase/downloads 29 | ECHO. 30 | PAUSE 31 | EXIT 32 | 33 | :setpath 34 | SET PATH=%jdk%;%PATH% 35 | GOTO :eof 36 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TMousePosition.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.client.Client; 5 | import org.rsbot.client.input.Mouse; 6 | import org.rsbot.event.listeners.TextPaintListener; 7 | import org.rsbot.util.StringUtil; 8 | 9 | import java.awt.*; 10 | 11 | public class TMousePosition implements TextPaintListener { 12 | 13 | private final Client client; 14 | 15 | public TMousePosition(Bot bot) { 16 | client = bot.getClient(); 17 | } 18 | 19 | public int drawLine(final Graphics render, int idx) { 20 | final Mouse mouse = client.getMouse(); 21 | if (mouse != null) { 22 | final int mouse_x = mouse.getX(); 23 | final int mouse_y = mouse.getY(); 24 | String off = mouse.isPresent() ? "" : " (off)"; 25 | StringUtil.drawLine(render, idx++, "Mouse Position: (" + mouse_x + "," + mouse_y + ")" + off); 26 | } 27 | 28 | return idx; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/adapter/AddInterfaceAdapter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script.adapter; 2 | 3 | import org.rsbot.loader.asm.ClassAdapter; 4 | import org.rsbot.loader.asm.ClassVisitor; 5 | 6 | /** 7 | * @author Jacmob 8 | */ 9 | public class AddInterfaceAdapter extends ClassAdapter { 10 | 11 | private final String inter; 12 | 13 | public AddInterfaceAdapter(ClassVisitor delegate, String inter) { 14 | super(delegate); 15 | this.inter = inter; 16 | } 17 | 18 | public void visit( 19 | final int version, 20 | final int access, 21 | final String name, 22 | final String signature, 23 | final String superName, 24 | final String[] interfaces) { 25 | String[] inters = new String[interfaces.length + 1]; 26 | System.arraycopy(interfaces, 0, inters, 0, interfaces.length); 27 | inters[interfaces.length] = inter; 28 | cv.visit(version, access, name, signature, superName, inters); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/org/rsbot/script/randoms/TeleotherCloser.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.randoms; 2 | 3 | import org.rsbot.script.Random; 4 | import org.rsbot.script.ScriptManifest; 5 | import org.rsbot.script.methods.Game; 6 | import org.rsbot.script.wrappers.RSInterface; 7 | 8 | @ScriptManifest(authors = {"ToshiXZ"}, name = "TeleotherCloser", version = 1.0) 9 | public class TeleotherCloser extends Random { 10 | 11 | @Override 12 | public boolean activateCondition() { 13 | final RSInterface iface = interfaces.get(326); 14 | return iface.isValid() && iface.getComponent(2).getText().contains("wants to teleport"); 15 | } 16 | 17 | @Override 18 | public int loop() { 19 | interfaces.get(326).getComponent(8).doClick(); 20 | sleep(random(500, 750)); 21 | game.openTab(Game.TAB_OPTIONS); 22 | sleep(random(500, 750)); 23 | log.info("Disabling accept aid"); 24 | mouse.click(random(569, 603), random(415, 440), false); 25 | return -1; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/wrappers/HashTable.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal.wrappers; 2 | 3 | public class HashTable { 4 | 5 | private final org.rsbot.client.HashTable nc; 6 | private org.rsbot.client.Node current; 7 | private int c_index = 0; 8 | 9 | public HashTable(org.rsbot.client.HashTable hashTable) { 10 | nc = hashTable; 11 | } 12 | 13 | public org.rsbot.client.Node getFirst() { 14 | c_index = 0; 15 | return getNext(); 16 | } 17 | 18 | public org.rsbot.client.Node getNext() { 19 | if (c_index > 0 && nc.getBuckets()[c_index - 1] != current) { 20 | org.rsbot.client.Node node = current; 21 | current = node.getPrevious(); 22 | return node; 23 | } 24 | while (c_index < nc.getBuckets().length) { 25 | org.rsbot.client.Node node = nc.getBuckets()[c_index++].getPrevious(); 26 | if (nc.getBuckets()[c_index - 1] != node) { 27 | current = node.getPrevious(); 28 | return node; 29 | } 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TMenu.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.client.Client; 5 | import org.rsbot.event.listeners.TextPaintListener; 6 | import org.rsbot.util.StringUtil; 7 | 8 | import java.awt.*; 9 | 10 | public class TMenu implements TextPaintListener { 11 | 12 | private final Client client; 13 | 14 | public TMenu(Bot bot) { 15 | client = bot.getClient(); 16 | } 17 | 18 | public int drawLine(Graphics render, int idx) { 19 | StringUtil.drawLine(render, idx++, "Menu " + (client.isMenuOpen() ? "Open" : "Closed") + 20 | " & " + (client.isMenuCollapsed() ? "Collapsed" : "Expanded")); 21 | StringUtil.drawLine(render, idx++, "Menu Location: (" + 22 | client.getMenuX() + "," + client.getMenuY() + ")"); 23 | StringUtil.drawLine(render, idx++, "Sub-Menu Location: (" + 24 | client.getSubMenuX() + "," + client.getSubMenuY() + ")"); 25 | StringUtil.drawLine(render, idx++, "Sub-Menu Width: " + client.getSubMenuWidth()); 26 | return idx; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/org/rsbot/script/randoms/LeaveSafeArea.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.randoms; 2 | 3 | import org.rsbot.script.Random; 4 | import org.rsbot.script.ScriptManifest; 5 | 6 | @ScriptManifest(name = "LeaveSafeArea", authors = "Taha", version = 1.0) 7 | public class LeaveSafeArea extends Random { 8 | 9 | @Override 10 | public boolean activateCondition() { 11 | return (interfaces.getComponent(212, 2).containsText("things can get more") && 12 | (interfaces.getComponent(212, 2).getAbsoluteY() > 380) && 13 | (interfaces.getComponent(212, 2).getAbsoluteY() < 410)) || 14 | (interfaces.getComponent(236, 1).containsText("the starting area") && 15 | (interfaces.getComponent(236, 1).getAbsoluteY() > 390) && 16 | (interfaces.getComponent(236, 1).getAbsoluteY() < 415)); 17 | } 18 | 19 | @Override 20 | public int loop() { 21 | if (interfaces.canContinue()) { 22 | interfaces.clickContinue(); 23 | sleep(random(1000, 1200)); 24 | } 25 | interfaces.getComponent(236, 1).doClick(); 26 | return -1; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/asm/Handler.java: -------------------------------------------------------------------------------- 1 | /*** 2 | * ASM: a very small and fast Java bytecode manipulation framework 3 | * Copyright (c) 2000-2007 INRIA, France Telecom 4 | * All rights reserved. 5 | */ 6 | package org.rsbot.loader.asm; 7 | 8 | /** 9 | * Information about an exception handler block. 10 | * 11 | * @author Eric Bruneton 12 | */ 13 | class Handler { 14 | 15 | /** 16 | * Beginning of the exception handler's scope (inclusive). 17 | */ 18 | Label start; 19 | 20 | /** 21 | * End of the exception handler's scope (exclusive). 22 | */ 23 | Label end; 24 | 25 | /** 26 | * Beginning of the exception handler's code. 27 | */ 28 | Label handler; 29 | 30 | /** 31 | * Internal name of the type of exceptions handled by this handler, or 32 | * null to catch any exceptions. 33 | */ 34 | String desc; 35 | 36 | /** 37 | * Constant pool index of the internal name of the type of exceptions 38 | * handled by this handler, or 0 to catch any exceptions. 39 | */ 40 | int type; 41 | 42 | /** 43 | * Next exception handler block info. 44 | */ 45 | Handler next; 46 | } 47 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/TCamera.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.client.Client; 5 | import org.rsbot.event.listeners.TextPaintListener; 6 | import org.rsbot.util.StringUtil; 7 | 8 | import java.awt.*; 9 | 10 | public class TCamera implements TextPaintListener { 11 | 12 | private final Client client; 13 | 14 | public TCamera(Bot bot) { 15 | client = bot.getClient(); 16 | } 17 | 18 | public int drawLine(final Graphics render, int idx) { 19 | final String camPos = "Camera Position (x,y,z): (" + client.getCamPosX() + ", " + client.getCamPosY() + ", " + client.getCamPosZ() + ")"; 20 | final String camAngle = "Camera Angle (pitch, yaw): (" + client.getCameraPitch() + ", " + client.getCameraYaw() + ")"; 21 | //final String detailLvl = "Detail lvl: " + (client.getDetailInfo() != null ? client.getDetailInfo().getDetailLevel() : "null"); 22 | 23 | StringUtil.drawLine(render, idx++, camPos); 24 | StringUtil.drawLine(render, idx++, camAngle); 25 | //Methods.drawLine(render, idx++, detailLvl); 26 | return idx; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawInventory.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.PaintListener; 5 | import org.rsbot.script.methods.Game; 6 | import org.rsbot.script.methods.MethodContext; 7 | import org.rsbot.script.wrappers.RSItem; 8 | 9 | import java.awt.*; 10 | 11 | public class DrawInventory implements PaintListener { 12 | 13 | private final MethodContext ctx; 14 | 15 | public DrawInventory(Bot bot) { 16 | ctx = bot.getMethodContext(); 17 | } 18 | 19 | public void onRepaint(final Graphics render) { 20 | if (!ctx.game.isLoggedIn()) { 21 | return; 22 | } 23 | 24 | if (ctx.game.getCurrentTab() != Game.TAB_INVENTORY) { 25 | return; 26 | } 27 | 28 | render.setColor(Color.WHITE); 29 | final RSItem[] inventoryItems = ctx.inventory.getItems(); 30 | 31 | for (RSItem inventoryItem : inventoryItems) { 32 | if (inventoryItem.getID() != -1) { 33 | final Point location = inventoryItem.getComponent().getCenter(); 34 | render.drawString("" + inventoryItem.getID(), location.x, location.y); 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/adapter/AddMethodAdapter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script.adapter; 2 | 3 | import org.rsbot.loader.asm.ClassAdapter; 4 | import org.rsbot.loader.asm.ClassVisitor; 5 | import org.rsbot.loader.asm.MethodVisitor; 6 | import org.rsbot.loader.script.CodeReader; 7 | 8 | /** 9 | * @author Jacmob 10 | */ 11 | public class AddMethodAdapter extends ClassAdapter { 12 | 13 | public static class Method { 14 | public int access; 15 | public String name; 16 | public String desc; 17 | public byte[] code; 18 | public int max_stack; 19 | public int max_locals; 20 | } 21 | 22 | private final Method[] methods; 23 | 24 | public AddMethodAdapter(ClassVisitor delegate, Method[] methods) { 25 | super(delegate); 26 | this.methods = methods; 27 | } 28 | 29 | public void visitEnd() { 30 | for (Method m : methods) { 31 | MethodVisitor mv = cv.visitMethod(m.access, m.name, m.desc, null, null); 32 | mv.visitCode(); 33 | new CodeReader(m.code).accept(mv); 34 | mv.visitMaxs(m.max_stack, m.max_locals); 35 | mv.visitEnd(); 36 | } 37 | cv.visitEnd(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/wrappers/Queue.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal.wrappers; 2 | 3 | import org.rsbot.client.NodeSubQueue; 4 | 5 | @SuppressWarnings("unchecked") 6 | public class Queue { 7 | 8 | private final NodeSubQueue nl; 9 | private org.rsbot.client.NodeSub current; 10 | 11 | public Queue(NodeSubQueue nl) { 12 | this.nl = nl; 13 | } 14 | 15 | public int size() { 16 | int size = 0; 17 | org.rsbot.client.NodeSub node = nl.getTail().getPrevSub(); 18 | 19 | while (node != nl.getTail()) { 20 | node = node.getPrevSub(); 21 | size++; 22 | } 23 | 24 | return size; 25 | } 26 | 27 | public N getHead() { 28 | org.rsbot.client.NodeSub node = nl.getTail().getNextSub(); 29 | 30 | if (node == nl.getTail()) { 31 | current = null; 32 | return null; 33 | } 34 | current = node.getNextSub(); 35 | 36 | return (N) node; 37 | } 38 | 39 | public N getNext() { 40 | org.rsbot.client.NodeSub node = current; 41 | 42 | if (node == nl.getTail()) { 43 | current = null; 44 | return null; 45 | } 46 | current = node.getNextSub(); 47 | 48 | return (N) node; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSWebSkeleton.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.script.methods.MethodContext; 4 | import org.rsbot.script.methods.MethodProvider; 5 | 6 | import java.util.EnumSet; 7 | 8 | /** 9 | * A class that walks a web skeleton path. 10 | * 11 | * @author Timer 12 | * @author Aut0r 13 | */ 14 | 15 | public abstract class RSWebSkeleton extends MethodProvider { 16 | 17 | /** 18 | * Optional handlers while walking the web path. 19 | */ 20 | public static enum TraversalOption { 21 | HANDLE_RUN, SPACE_ACTIONS 22 | } 23 | 24 | public RSWebSkeleton(final MethodContext ctx) { 25 | super(ctx); 26 | } 27 | 28 | /** 29 | * Takes a step on the web path. 30 | * 31 | * @param options The flags to take into account while traversing the path. 32 | * @return If a step was taken on the path. 33 | */ 34 | public abstract boolean traverse(EnumSet options); 35 | 36 | /** 37 | * Takes a step on the web path with traversal options. 38 | * 39 | * @return If a step was taken on the path. 40 | */ 41 | public boolean traverse() { 42 | return traverse(EnumSet.of( 43 | TraversalOption.HANDLE_RUN, 44 | TraversalOption.SPACE_ACTIONS)); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSWebTile.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | /** 4 | * A RSTile modified for A-Star. 5 | * 6 | * @author Timer 7 | * @author Aut0r 8 | */ 9 | public class RSWebTile extends RSTile { 10 | 11 | private int[] neighbors = null; 12 | public RSWebTile parent = null; 13 | public Task req = null; 14 | public double g = 0.00, f = 0.00; 15 | 16 | public RSWebTile(final RSTile tile, final int[] neighbors, 17 | final Task requirement) { 18 | super(tile.getX(), tile.getY()); 19 | this.neighbors = neighbors; 20 | this.req = requirement; 21 | } 22 | 23 | /** 24 | * Returns the tile. 25 | * 26 | * @return This RSTile. 27 | */ 28 | public RSTile tile() { 29 | return this; 30 | } 31 | 32 | /** 33 | * Returns the connecting indices. 34 | * 35 | * @return The indices. 36 | */ 37 | public int[] connectingIndex() { 38 | return neighbors; 39 | } 40 | 41 | /** 42 | * Task class. 43 | */ 44 | public abstract class Task { 45 | 46 | public abstract boolean meetsRequirement(); 47 | 48 | public abstract boolean task(); 49 | 50 | public boolean canDo() { 51 | return meetsRequirement(); 52 | } 53 | 54 | public boolean execute() { 55 | return task(); 56 | } 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/org/rsbot/script/methods/Account.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.methods; 2 | 3 | import org.rsbot.gui.AccountManager; 4 | 5 | import java.util.logging.Logger; 6 | 7 | /** 8 | * Selected account information. 9 | */ 10 | public class Account extends MethodProvider { 11 | 12 | Logger log = Logger.getLogger(getClass().getName()); 13 | 14 | public Account(MethodContext ctx) { 15 | super(ctx); 16 | } 17 | 18 | /** 19 | * The account name. 20 | * 21 | * @return The currently selected account's name. 22 | */ 23 | public String getName() { 24 | return methods.bot.getAccountName(); 25 | } 26 | 27 | /** 28 | * The account password. 29 | * 30 | * @return The currently selected account's password. 31 | */ 32 | public String getPassword() { 33 | return AccountManager.getPassword(getName()); 34 | } 35 | 36 | /** 37 | * The account pin. 38 | * 39 | * @return The currently selected account's pin. 40 | */ 41 | public String getPin() { 42 | return AccountManager.getPin(getName()); 43 | } 44 | 45 | /** 46 | * The account reward. 47 | * 48 | * @return The currently selected account's reward. 49 | */ 50 | public String getReward() { 51 | return AccountManager.getReward(getName()); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/asm/FieldVisitor.java: -------------------------------------------------------------------------------- 1 | /*** 2 | * ASM: a very small and fast Java bytecode manipulation framework 3 | * Copyright (c) 2000-2007 INRIA, France Telecom 4 | * All rights reserved. 5 | */ 6 | package org.rsbot.loader.asm; 7 | 8 | /** 9 | * A visitor to visit a Java field. The methods of this interface must be called 10 | * in the following order: ( visitAnnotation | 11 | * visitAttribute )* visitEnd. 12 | * 13 | * @author Eric Bruneton 14 | */ 15 | public interface FieldVisitor { 16 | 17 | /** 18 | * Visits an annotation of the field. 19 | * 20 | * @param desc the class descriptor of the annotation class. 21 | * @param visible true if the annotation is visible at runtime. 22 | * @return a visitor to visit the annotation values, or null if 23 | * this visitor is not interested in visiting this annotation. 24 | */ 25 | AnnotationVisitor visitAnnotation(String desc, boolean visible); 26 | 27 | /** 28 | * Visits a non standard attribute of the field. 29 | * 30 | * @param attr an attribute. 31 | */ 32 | void visitAttribute(Attribute attr); 33 | 34 | /** 35 | * Visits the end of the field. This method, which is the last one to be 36 | * called, is used to inform the visitor that all the annotations and 37 | * attributes of the field have been visited. 38 | */ 39 | void visitEnd(); 40 | } 41 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC=javac 2 | CFLAGS=-g -Xlint:deprecation 3 | SRC=src 4 | LIB=lib 5 | RES=resources 6 | BINDIR=bin 7 | LSTF=temp.txt 8 | IMGDIR=$(RES)/images 9 | MANIFEST=$(RES)/Manifest.txt 10 | VERSIONFILE=$(RES)/version.txt 11 | VERSION=`cat $(VERSIONFILE)` 12 | SCRIPTS=scripts 13 | NAME=RSBot 14 | DIST=$(NAME).jar 15 | ACCOUNTS=$(HOME)/.$(shell echo $(NAME) | tr '[A-Z]' '[a-z]')acct 16 | INSTALLDIR=$(HOME)/$(NAME) 17 | 18 | .PHONY: all Bot Scripts mostlyclean clean remove 19 | 20 | all: Bundle 21 | 22 | Bot: 23 | @if [ ! -d "$(BINDIR)" ]; then mkdir "$(BINDIR)"; fi 24 | $(CC) $(CFLAGS) -d "$(BINDIR)" `find "$(SRC)" -name \*.java` 25 | 26 | Scripts: mostlyclean Bot 27 | $(CC) $(CFLAGS) -cp "$(BINDIR)" "$(SCRIPTS)"/*.java 28 | 29 | Bundle: Scripts 30 | @rm -fv "$(LSTF)" 31 | @cp "$(MANIFEST)" "$(LSTF)" 32 | @echo "Specification-Version: \"$(VERSION)\"" >> "$(LSTF)" 33 | @echo "Implementation-Version: \"$(VERSION)\"" >> "$(LSTF)" 34 | @if [ -e "$(DIST)" ]; then rm -fv "$(DIST)"; fi 35 | jar cfm "$(DIST)" "$(LSTF)" -C "$(BINDIR)" . "$(VERSIONFILE)" "$(IMGDIR)"/* "$(RES)"/*.bat "$(RES)"/*.sh 36 | @rm -f "$(LSTF)" 37 | 38 | mostlyclean: 39 | @rm -fv "$(SCRIPTS)"/*.class 40 | 41 | clean: mostlyclean 42 | @rm -fv "$(DIST)" 43 | @rm -rfv "$(BINDIR)" 44 | 45 | remove: 46 | @if [ -e "$(ACCOUNTS)" ]; then rm -fv "$(ACCOUNTS)"; fi 47 | @if [ -d "$(INSTALLDIR)" ]; then rm -rfv "$(INSTALLDIR)"; fi 48 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/adapter/SetSignatureAdapter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script.adapter; 2 | 3 | import org.rsbot.loader.asm.ClassAdapter; 4 | import org.rsbot.loader.asm.ClassVisitor; 5 | import org.rsbot.loader.asm.MethodVisitor; 6 | 7 | /** 8 | * @author Jacmob 9 | */ 10 | public class SetSignatureAdapter extends ClassAdapter { 11 | 12 | public static class Signature { 13 | public String name; 14 | public String desc; 15 | public int new_access; 16 | public String new_name; 17 | public String new_desc; 18 | } 19 | 20 | private final Signature[] signatures; 21 | 22 | public SetSignatureAdapter(ClassVisitor delegate, Signature[] signatures) { 23 | super(delegate); 24 | this.signatures = signatures; 25 | } 26 | 27 | public MethodVisitor visitMethod( 28 | final int access, 29 | final String name, 30 | final String desc, 31 | final String signature, 32 | final String[] exceptions) { 33 | for (Signature s : signatures) { 34 | if (s.name.equals(name) && s.desc.equals("") || s.desc.equals(desc)) { 35 | return cv.visitMethod( 36 | s.new_access == -1 ? access : s.new_access, 37 | s.new_name, 38 | s.new_desc.equals("") ? desc : s.new_desc, 39 | signature, 40 | exceptions); 41 | } 42 | } 43 | return cv.visitMethod(access, name, desc, signature, exceptions); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/Buffer.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script; 2 | 3 | /** 4 | * @author Jacmob 5 | */ 6 | class Buffer { 7 | 8 | private int pos; 9 | private final byte[] data; 10 | 11 | public Buffer(byte[] buffer) { 12 | data = buffer; 13 | pos = 0; 14 | } 15 | 16 | public int g1() { 17 | return data[pos++] & 0xff; 18 | } 19 | 20 | public int g2() { 21 | pos += 2; 22 | return ((data[pos - 2] & 0xff) << 8) + (data[pos - 1] & 0xff); 23 | } 24 | 25 | public int g4() { 26 | pos += 4; 27 | return ((data[pos - 4] & 0xff) << 24) + ((data[pos - 3] & 0xff) << 16) + ((data[pos - 2] & 0xff) << 8) + (data[pos - 1] & 0xff); 28 | } 29 | 30 | public long g8() { 31 | long l = (long) g4() & 0xffffffffL; 32 | long r = (long) g4() & 0xffffffffL; 33 | return (l << 32) + r; 34 | } 35 | 36 | public String gstr() { 37 | int i = pos; 38 | while (data[pos++] != 10) { 39 | } 40 | return new String(data, i, pos - i - 1); 41 | } 42 | 43 | public byte[] gstrbyte() { 44 | int i = pos; 45 | while (data[pos++] != 10) { 46 | } 47 | byte str[] = new byte[pos - i - 1]; 48 | System.arraycopy(data, i, str, i - i, pos - 1 - i); 49 | return str; 50 | } 51 | 52 | public void gdata(byte[] data, int len, int off) { 53 | for (int i = off; i < off + len; i++) { 54 | data[i] = this.data[pos++]; 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/wrappers/Deque.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal.wrappers; 2 | 3 | import org.rsbot.client.NodeDeque; 4 | 5 | @SuppressWarnings("unchecked") 6 | public class Deque { 7 | 8 | private final NodeDeque nl; 9 | private org.rsbot.client.Node current; 10 | 11 | public Deque(NodeDeque nl) { 12 | this.nl = nl; 13 | } 14 | 15 | public int size() { 16 | int size = 0; 17 | org.rsbot.client.Node node = nl.getTail().getPrevious(); 18 | 19 | while (node != nl.getTail()) { 20 | node = node.getPrevious(); 21 | size++; 22 | } 23 | 24 | return size; 25 | } 26 | 27 | public N getHead() { 28 | org.rsbot.client.Node node = nl.getTail().getNext(); 29 | 30 | if (node == nl.getTail()) { 31 | current = null; 32 | return null; 33 | } 34 | current = node.getNext(); 35 | 36 | return (N) node; 37 | } 38 | 39 | public N getTail() { 40 | org.rsbot.client.Node node = nl.getTail().getPrevious(); 41 | 42 | if (node == nl.getTail()) { 43 | current = null; 44 | return null; 45 | } 46 | current = node.getPrevious(); 47 | 48 | return (N) node; 49 | } 50 | 51 | public N getNext() { 52 | org.rsbot.client.Node node = current; 53 | 54 | if (node == nl.getTail()) { 55 | current = null; 56 | return null; 57 | } 58 | current = node.getNext(); 59 | 60 | return (N) node; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawGround.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.PaintListener; 5 | import org.rsbot.script.methods.MethodContext; 6 | import org.rsbot.script.wrappers.RSGroundItem; 7 | import org.rsbot.script.wrappers.RSPlayer; 8 | import org.rsbot.script.wrappers.RSTile; 9 | 10 | import java.awt.*; 11 | 12 | public class DrawGround implements PaintListener { 13 | 14 | private final MethodContext ctx; 15 | 16 | public DrawGround(Bot bot) { 17 | this.ctx = bot.getMethodContext(); 18 | } 19 | 20 | public void onRepaint(final Graphics render) { 21 | if (!ctx.game.isLoggedIn()) { 22 | return; 23 | } 24 | final RSPlayer player = ctx.players.getMyPlayer(); 25 | if (player == null) { 26 | return; 27 | } 28 | render.setColor(Color.WHITE); 29 | final RSTile location = player.getLocation(); 30 | for (int x = location.getX() - 25; x < location.getX() + 25; x++) { 31 | for (int y = location.getY() - 25; y < location.getY() + 25; y++) { 32 | final RSGroundItem[] item = ctx.groundItems.getAllAt(x, y); 33 | if ((item == null) || (item.length == 0)) { 34 | continue; 35 | } 36 | final Point screen = ctx.calc.tileToScreen(item[0].getLocation()); 37 | if (ctx.calc.pointOnScreen(screen)) { 38 | render.drawString("" + item[0].getItem().getID(), location.getX() - 10, location.getY()); 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/org/rsbot/script/methods/Nodes.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.methods; 2 | 3 | import org.rsbot.client.DefLoader; 4 | import org.rsbot.client.HashTable; 5 | import org.rsbot.client.Node; 6 | 7 | /** 8 | * For internal use to reference data stored in the engine's Node-based 9 | * structures. 10 | */ 11 | public class Nodes extends MethodProvider { 12 | 13 | Nodes(MethodContext ctx) { 14 | super(ctx); 15 | } 16 | 17 | /** 18 | * @param nc The node cache to check 19 | * @param id The id of the node 20 | * @return A Node object corresponding to the ID in the nodecache. 21 | */ 22 | public Node lookup(final HashTable nc, final long id) { 23 | try { 24 | if ((nc == null) || (nc.getBuckets() == null) || (id < 0)) { 25 | return null; 26 | } 27 | 28 | final Node n = nc.getBuckets()[(int) (id & nc.getBuckets().length - 1)]; 29 | for (Node node = n.getPrevious(); node != n; node = node 30 | .getPrevious()) { 31 | if (node.getID() == id) { 32 | return node; 33 | } 34 | } 35 | } catch (final Exception ignored) { 36 | } 37 | return null; 38 | } 39 | 40 | /** 41 | * @param loader The node's loader. 42 | * @param id The id of the node 43 | * @return A Node object corresponding to the ID in the loader. 44 | */ 45 | public Node lookup(final DefLoader loader, final long id) { 46 | if ((loader == null) || (loader.getCache() == null)) { 47 | return null; 48 | } 49 | return lookup(loader.getCache().getTable(), id); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/adapter/SetSuperAdapter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script.adapter; 2 | 3 | import org.rsbot.loader.asm.*; 4 | 5 | /** 6 | * @author Jacmob 7 | */ 8 | public class SetSuperAdapter extends ClassAdapter { 9 | 10 | private String superName; 11 | private final String newSuperName; 12 | 13 | public SetSuperAdapter(ClassVisitor delegate, String superName) { 14 | super(delegate); 15 | newSuperName = superName; 16 | } 17 | 18 | public void visit( 19 | final int version, 20 | final int access, 21 | final String name, 22 | final String signature, 23 | final String superName, 24 | final String[] interfaces) { 25 | this.superName = superName; 26 | cv.visit(version, access, name, signature, newSuperName, interfaces); 27 | } 28 | 29 | public MethodVisitor visitMethod( 30 | final int access, 31 | final String name, 32 | final String desc, 33 | final String signature, 34 | final String[] exceptions) { 35 | if (name.equals("")) { 36 | return new MethodAdapter(cv.visitMethod(access, name, desc, signature, exceptions)) { 37 | public void visitMethodInsn(int opcode, String owner, String name, String desc) { 38 | if (opcode == Opcodes.INVOKESPECIAL && owner.equals(superName)) { 39 | owner = newSuperName; 40 | } 41 | mv.visitMethodInsn(opcode, owner, name, desc); 42 | } 43 | }; 44 | } 45 | return cv.visitMethod(access, name, desc, signature, exceptions); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/org/rsbot/bot/CallbackImpl.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.bot; 2 | 3 | import org.rsbot.client.Callback; 4 | import org.rsbot.client.Render; 5 | import org.rsbot.client.RenderData; 6 | import org.rsbot.event.events.CharacterMovedEvent; 7 | import org.rsbot.event.events.MessageEvent; 8 | import org.rsbot.event.events.ServerMessageEvent; 9 | import org.rsbot.script.methods.MethodContext; 10 | 11 | @SuppressWarnings("deprecation") 12 | public class CallbackImpl implements Callback { 13 | 14 | private final Bot bot; 15 | 16 | public CallbackImpl(Bot bot) { 17 | this.bot = bot; 18 | } 19 | 20 | public Bot getBot() { 21 | return bot; 22 | } 23 | 24 | public void notifyMessage(final int id, final String sender, final String msg) { 25 | MessageEvent m = new MessageEvent(sender, id, msg); 26 | bot.getEventManager().dispatchEvent(m); 27 | if (id == MessageEvent.MESSAGE_SERVER || id == MessageEvent.MESSAGE_ACTION) { 28 | ServerMessageEvent e = new ServerMessageEvent(msg); 29 | bot.getEventManager().dispatchEvent(e); 30 | } 31 | } 32 | 33 | public void rsCharacterMoved(final org.rsbot.client.RSCharacter c, final int i) { 34 | CharacterMovedEvent e = new CharacterMovedEvent(bot.getMethodContext(), c, i); 35 | bot.getEventManager().dispatchEvent(e); 36 | } 37 | 38 | public void updateRenderInfo(final Render r, final RenderData rd) { 39 | MethodContext ctx = bot.getMethodContext(); 40 | if (ctx != null) { 41 | ctx.calc.updateRenderInfo(r, rd); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/org/rsbot/service/ScriptClassLoader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.net.MalformedURLException; 7 | import java.net.URL; 8 | 9 | /** 10 | * @author Jacmob 11 | */ 12 | class ScriptClassLoader extends ClassLoader { 13 | 14 | private final URL base; 15 | 16 | public ScriptClassLoader(URL url) { 17 | this.base = url; 18 | } 19 | 20 | @SuppressWarnings("rawtypes") 21 | public Class loadClass(String name, boolean resolve) throws ClassNotFoundException { 22 | Class clazz = findLoadedClass(name); 23 | 24 | if (clazz == null) { 25 | try { 26 | InputStream in = getResourceAsStream(name.replace('.', '/') + ".class"); 27 | byte[] buffer = new byte[4096]; 28 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 29 | int n; 30 | while ((n = in.read(buffer, 0, 4096)) != -1) { 31 | out.write(buffer, 0, n); 32 | } 33 | byte[] bytes = out.toByteArray(); 34 | clazz = defineClass(name, bytes, 0, bytes.length); 35 | if (resolve) { 36 | resolveClass(clazz); 37 | } 38 | } catch (Exception e) { 39 | clazz = super.loadClass(name, resolve); 40 | } 41 | } 42 | 43 | return clazz; 44 | } 45 | 46 | public URL getResource(String name) { 47 | try { 48 | return new URL(base, name); 49 | } catch (MalformedURLException e) { 50 | return null; 51 | } 52 | } 53 | 54 | public InputStream getResourceAsStream(String name) { 55 | try { 56 | return new URL(base, name).openStream(); 57 | } catch (IOException e) { 58 | return null; 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSCharacterModel.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.client.Model; 4 | import org.rsbot.script.methods.Calculations; 5 | import org.rsbot.script.methods.MethodContext; 6 | 7 | /** 8 | * @author Jacmob 9 | */ 10 | class RSCharacterModel extends RSModel { 11 | 12 | private final org.rsbot.client.RSCharacter c; 13 | 14 | private final int[] x_base, z_base; 15 | 16 | RSCharacterModel(MethodContext ctx, Model model, org.rsbot.client.RSCharacter c) { 17 | super(ctx, model); 18 | this.c = c; 19 | x_base = xPoints; 20 | z_base = zPoints; 21 | xPoints = new int[xPoints.length]; 22 | zPoints = new int[zPoints.length]; 23 | } 24 | 25 | /** 26 | * Performs a y rotation camera transform, where 27 | * the character's orientation is the rotation around 28 | * the y axis in fixed point radians. 29 | *

30 | * [cos(t), 0, sin(t) 31 | * 0, 1, 0 32 | * -sin(t), 0, cos(t)] 33 | */ 34 | protected void update() { 35 | int theta = c.getOrientation() & 0x3fff; 36 | int sin = Calculations.SIN_TABLE[theta]; 37 | int cos = Calculations.COS_TABLE[theta]; 38 | for (int i = 0; i < x_base.length; ++i) { 39 | // Note that the second row of the matrix would result 40 | // in no change, as the y coordinates are always unchanged 41 | // by rotation about the y axis. 42 | xPoints[i] = x_base[i] * cos + z_base[i] * sin >> 15; 43 | zPoints[i] = z_base[i] * cos - x_base[i] * sin >> 15; 44 | } 45 | } 46 | 47 | @Override 48 | protected int getLocalX() { 49 | return c.getX(); 50 | } 51 | 52 | @Override 53 | protected int getLocalY() { 54 | return c.getY(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/org/rsbot/client/ModelCapture.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Implementation of the Model interface used to 7 | * store model data by injection in transform 8 | * methods where model implementations in the 9 | * client are reused. 10 | * 11 | * @author Jacmob 12 | */ 13 | public class ModelCapture implements Model { 14 | 15 | private int[] vertex_x; 16 | private int[] vertex_y; 17 | private int[] vertex_z; 18 | 19 | private short[] face_a; 20 | private short[] face_b; 21 | private short[] face_c; 22 | 23 | public ModelCapture(Model model) { 24 | if (model == null) { 25 | return; 26 | } 27 | int[] vertices = model.getXPoints(); 28 | vertex_x = Arrays.copyOf(vertices, vertices.length); 29 | vertices = model.getYPoints(); 30 | vertex_y = Arrays.copyOf(vertices, vertices.length); 31 | vertices = model.getZPoints(); 32 | vertex_z = Arrays.copyOf(vertices, vertices.length); 33 | 34 | short[] faces = model.getIndices1(); 35 | face_a = Arrays.copyOf(faces, faces.length); 36 | faces = model.getIndices2(); 37 | face_b = Arrays.copyOf(faces, faces.length); 38 | faces = model.getIndices3(); 39 | face_c = Arrays.copyOf(faces, faces.length); 40 | } 41 | 42 | public int[] getXPoints() { 43 | return vertex_x; 44 | } 45 | 46 | public int[] getYPoints() { 47 | return vertex_y; 48 | } 49 | 50 | public int[] getZPoints() { 51 | return vertex_z; 52 | } 53 | 54 | public short[] getIndices1() { 55 | return face_a; 56 | } 57 | 58 | public short[] getIndices2() { 59 | return face_b; 60 | } 61 | 62 | public short[] getIndices3() { 63 | return face_c; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/org/rsbot/script/methods/Keyboard.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.methods; 2 | 3 | /** 4 | * Keyboard related operations. 5 | */ 6 | public class Keyboard extends MethodProvider { 7 | 8 | Keyboard(final MethodContext ctx) { 9 | super(ctx); 10 | } 11 | 12 | /** 13 | * Presses and releases a given key. 14 | * 15 | * @param c The character to press. 16 | */ 17 | public void sendKey(final char c) { 18 | methods.inputManager.sendKey(c); 19 | } 20 | 21 | /** 22 | * Types a given string. 23 | * 24 | * @param text The text to press/send. 25 | * @param pressEnter true to press enter after pressing the text. 26 | */ 27 | public void sendText(final String text, final boolean pressEnter) { 28 | methods.inputManager.sendKeys(text, pressEnter); 29 | } 30 | 31 | /** 32 | * Types a given string instantly. 33 | * 34 | * @param text The text to press/send. 35 | * @param pressEnter true to press enter after pressing the text. 36 | */ 37 | public void sendTextInstant(final String text, final boolean pressEnter) { 38 | methods.inputManager.sendKeysInstant(text, pressEnter); 39 | } 40 | 41 | /** 42 | * Presses and holds a given key. 43 | * 44 | * @param c The character to press. 45 | * @see #releaseKey(char) 46 | */ 47 | public void pressKey(final char c) { 48 | methods.inputManager.pressKey(c); 49 | } 50 | 51 | /** 52 | * Releases a given held key. 53 | * 54 | * @param c The character to release. 55 | * @see #pressKey(char) 56 | */ 57 | public void releaseKey(final char c) { 58 | methods.inputManager.releaseKey(c); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/org/rsbot/event/events/PaintEvent.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.events; 2 | 3 | import org.rsbot.event.EventMulticaster; 4 | import org.rsbot.event.listeners.PaintListener; 5 | 6 | import java.awt.*; 7 | import java.awt.geom.AffineTransform; 8 | import java.util.EventListener; 9 | 10 | /** 11 | * A paint update event. 12 | */ 13 | public class PaintEvent extends RSEvent { 14 | 15 | private static final long serialVersionUID = -7404828108740551228L; 16 | 17 | public Graphics graphics; 18 | 19 | @Override 20 | public void dispatch(final EventListener el) { 21 | final Graphics2D g2d = (Graphics2D) graphics; 22 | 23 | // Store settings 24 | final Color s_background = g2d.getBackground(); 25 | final Shape s_clip = g2d.getClip(); 26 | final Color s_color = g2d.getColor(); 27 | final Composite s_composite = g2d.getComposite(); 28 | final Font s_font = g2d.getFont(); 29 | final Paint s_paint = g2d.getPaint(); 30 | final RenderingHints s_renderingHints = g2d.getRenderingHints(); 31 | final Stroke s_stroke = g2d.getStroke(); 32 | final AffineTransform s_transform = g2d.getTransform(); 33 | 34 | // Dispatch the event 35 | ((PaintListener) el).onRepaint(graphics); 36 | 37 | // Restore settings 38 | g2d.setBackground(s_background); 39 | g2d.setClip(s_clip); 40 | g2d.setColor(s_color); 41 | g2d.setComposite(s_composite); 42 | g2d.setFont(s_font); 43 | g2d.setPaint(s_paint); 44 | g2d.setRenderingHints(s_renderingHints); 45 | g2d.setStroke(s_stroke); 46 | g2d.setTransform(s_transform); 47 | } 48 | 49 | @Override 50 | public long getMask() { 51 | return EventMulticaster.PAINT_EVENT; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #RSBot 2 | 3 | RSBot is an immensely popular and successful bot for a Java MMORPG. The program source code is completely open and free - whether you're a Java expert or just keen to explore, the bot is a valuable learning resource. 4 | 5 | ###Get the code 6 | 7 | Download the latest source code with: 8 | 9 | git clone git://github.com/powerbot/RSBot.git 10 | 11 | Keep your source up to date with: 12 | 13 | git pull origin master 14 | 15 | Subversion is also supported: 16 | 17 | svn checkout http://svn.github.com/powerbot/RSBot.git 18 | 19 | ### Dependencies 20 | 21 | * [Java Development Kit](http://www.oracle.com/technetwork/java/javase/downloads/) 22 | 23 | 24 | ##Microsoft Windows 25 | 26 | ###Compiling 27 | 28 | Make sure JDK is installed, then execute the `make.bat` file by *double clicking* it. 29 | 30 | ### Running 31 | 32 | Java is required to run RSBot. You can run the client by *double clicking* the JAR file named `RSBot.jar`. 33 | 34 | 35 | ##Linux, Mac OS X and other Unix systems 36 | 37 | ### Compiling 38 | 39 | Make sure JDK and other needed packages (e.g. `make`) are installed on your system. Open a terminal and navigate to the directory where the source code is located, using the `cd` command. Execute `make` in the terminal to compile RSBot. 40 | 41 | ### Running 42 | 43 | To run RSBot, *double click* on the compiled JAR file, `RSBot.jar`, or execute `java -jar RSBot.jar` in a terminal. 44 | 45 | ## Legal 46 | 47 | The entire source code is freely available under the GPLv3 terms. Contrary to bogus and automated DMCA claims, no content is under the copyright of Jagex Ltd. The code is provided purely for educational purposes by the authors as freedom of expression. 48 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawWeb.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.PaintListener; 5 | import org.rsbot.script.internal.wrappers.TileFlags; 6 | import org.rsbot.script.methods.MethodContext; 7 | import org.rsbot.script.methods.Web; 8 | import org.rsbot.script.wrappers.RSPlayer; 9 | import org.rsbot.script.wrappers.RSTile; 10 | 11 | import java.awt.*; 12 | import java.util.Iterator; 13 | import java.util.Map; 14 | 15 | public class DrawWeb implements PaintListener { 16 | 17 | private final MethodContext ctx; 18 | 19 | private Point tileToMap(final RSTile tile, final RSPlayer player) { 20 | double minimapAngle = -1 * Math.toRadians(ctx.camera.getAngle()); 21 | int x = (tile.getX() - player.getLocation().getX()) * 4 - 2; 22 | int y = (player.getLocation().getY() - tile.getY()) * 4 - 2; 23 | return new Point((int) Math.round(x * Math.cos(minimapAngle) + y * Math.sin(minimapAngle) + 628), (int) Math.round(y * Math.cos(minimapAngle) - x * Math.sin(minimapAngle) + 87)); 24 | } 25 | 26 | public DrawWeb(Bot bot) { 27 | this.ctx = bot.getMethodContext(); 28 | } 29 | 30 | public void onRepaint(final Graphics render) { 31 | if (!ctx.game.isLoggedIn()) { 32 | return; 33 | } 34 | final RSPlayer player = ctx.players.getMyPlayer(); 35 | if (player == null) { 36 | return; 37 | } 38 | Iterator> rs = Web.map.entrySet().iterator(); 39 | while (rs.hasNext()) { 40 | TileFlags t = rs.next().getValue(); 41 | render.setColor(t.isWalkable() ? t.isQuestionable() ? Color.yellow : Color.green : t.isWater() ? Color.cyan : Color.red); 42 | Point p = tileToMap(t.getTile(), player); 43 | render.drawLine(p.x, p.y, p.x, p.y); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/BreakHandler.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal; 2 | 3 | import org.rsbot.bot.Bot; 4 | 5 | import java.util.Random; 6 | 7 | public class BreakHandler { 8 | 9 | private final Random random = new Random(); 10 | 11 | private long nextBreak; 12 | private long breakEnd; 13 | private int ticks = 0; 14 | private final Bot bot; 15 | private boolean checked = false; 16 | private boolean result = false; 17 | 18 | public BreakHandler(Bot bot) { 19 | this.bot = bot; 20 | } 21 | 22 | public boolean isBreaking() { 23 | return ticks > 50 && nextBreak > 0 && nextBreak < System.currentTimeMillis() 24 | && breakEnd > System.currentTimeMillis() && can(); 25 | } 26 | 27 | private boolean can() { 28 | if (checked) { 29 | return result; 30 | } else { 31 | checked = true; 32 | result = bot.getScriptHandler().onBreak(); 33 | return result; 34 | } 35 | } 36 | 37 | public void tick() { 38 | ++ticks; 39 | if (checked) { 40 | checked = false; 41 | bot.getScriptHandler().onBreakResume(); 42 | } 43 | if (nextBreak < 0 || nextBreak - System.currentTimeMillis() < -30000) { 44 | ticks = 0; 45 | int offset = random(20, 120) * 60000; 46 | nextBreak = System.currentTimeMillis() + offset; 47 | if (random(0, 4) != 0) { 48 | breakEnd = nextBreak + random(2, 40) * 60000 + offset / 6; 49 | } else { 50 | breakEnd = nextBreak + random(10, 60) * 1000; 51 | } 52 | } 53 | } 54 | 55 | public long getBreakTime() { 56 | return breakEnd - System.currentTimeMillis(); 57 | } 58 | 59 | private int random(int min, int max) { 60 | int n = Math.abs(max - min); 61 | return Math.min(min, max) + (n == 0 ? 0 : random.nextInt(n)); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/asm/Edge.java: -------------------------------------------------------------------------------- 1 | /*** 2 | * ASM: a very small and fast Java bytecode manipulation framework 3 | * Copyright (c) 2000-2007 INRIA, France Telecom 4 | * All rights reserved. 5 | */ 6 | package org.rsbot.loader.asm; 7 | 8 | /** 9 | * An edge in the control flow graph of a method body. See {@link Label Label}. 10 | * 11 | * @author Eric Bruneton 12 | */ 13 | class Edge { 14 | 15 | /** 16 | * Denotes a normal control flow graph edge. 17 | */ 18 | static final int NORMAL = 0; 19 | 20 | /** 21 | * Denotes a control flow graph edge corresponding to an exception handler. 22 | * More precisely any {@link Edge} whose {@link #info} is strictly positive 23 | * corresponds to an exception handler. The actual value of {@link #info} is 24 | * the index, in the {@link ClassWriter} type table, of the exception that 25 | * is catched. 26 | */ 27 | static final int EXCEPTION = 0x7FFFFFFF; 28 | 29 | /** 30 | * Information about this control flow graph edge. If 31 | * {@link ClassWriter#COMPUTE_MAXS} is used this field is the (relative) 32 | * stack size in the basic block from which this edge originates. This size 33 | * is equal to the stack size at the "jump" instruction to which this edge 34 | * corresponds, relatively to the stack size at the beginning of the 35 | * originating basic block. If {@link ClassWriter#COMPUTE_FRAMES} is used, 36 | * this field is the kind of this control flow graph edge (i.e. NORMAL or 37 | * EXCEPTION). 38 | */ 39 | int info; 40 | 41 | /** 42 | * The successor block of the basic block from which this edge originates. 43 | */ 44 | Label successor; 45 | 46 | /** 47 | * The next edge in the list of successors of the originating basic block. 48 | * See {@link Label#successors successors}. 49 | */ 50 | Edge next; 51 | } 52 | -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/wrappers/StatusQueue.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal.wrappers; 2 | 3 | class StatusQueue { 4 | 5 | private final org.rsbot.client.StatusNodeList nl; 6 | private org.rsbot.client.StatusNode c_node; 7 | 8 | public StatusQueue(final org.rsbot.client.StatusNodeList nl) { 9 | this.nl = nl; 10 | } 11 | 12 | public org.rsbot.client.StatusNode getFirst() { 13 | final org.rsbot.client.StatusNode node = nl.getHead().getNext(); 14 | 15 | if (node == nl.getHead()) { 16 | c_node = null; 17 | return null; 18 | } 19 | c_node = node.getNext(); 20 | 21 | return node; 22 | } 23 | 24 | public org.rsbot.client.StatusNode getLast() { 25 | final org.rsbot.client.StatusNode node = nl.getHead().getPrevious(); 26 | 27 | if (node == nl.getHead()) { 28 | c_node = null; 29 | return null; 30 | } 31 | c_node = node.getPrevious(); 32 | 33 | return node; 34 | } 35 | 36 | public org.rsbot.client.StatusNode getNext() { 37 | final org.rsbot.client.StatusNode node = c_node; 38 | 39 | if (node == nl.getHead() || node == null) { 40 | c_node = null; 41 | return null; 42 | } 43 | c_node = node.getNext(); 44 | 45 | return node; 46 | } 47 | 48 | public org.rsbot.client.StatusNode getPrevious() { 49 | final org.rsbot.client.StatusNode node = c_node; 50 | 51 | if (node == nl.getHead() || node == null) { 52 | c_node = null; 53 | return null; 54 | } 55 | c_node = node.getNext(); 56 | 57 | return node; 58 | } 59 | 60 | public int size() { 61 | int size = 0; 62 | org.rsbot.client.StatusNode node = nl.getHead().getPrevious(); 63 | 64 | while (node != nl.getHead()) { 65 | node = node.getPrevious(); 66 | size++; 67 | } 68 | 69 | return size; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/org/rsbot/event/events/MessageEvent.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.events; 2 | 3 | import org.rsbot.event.EventMulticaster; 4 | import org.rsbot.event.listeners.MessageListener; 5 | 6 | import java.util.EventListener; 7 | 8 | /** 9 | * A message event. 10 | * 11 | * @author Jacmob 12 | */ 13 | public class MessageEvent extends RSEvent { 14 | 15 | public static final int MESSAGE_SERVER = 0; 16 | public static final int MESSAGE_CHAT = 2; 17 | public static final int MESSAGE_PRIVATE_IN = 3; 18 | public static final int MESSAGE_PRIVATE_INFO = 5; 19 | public static final int MESSAGE_PRIVATE_OUT = 6; 20 | public static final int MESSAGE_CLAN_CHAT = 9; 21 | public static final int MESSAGE_CLIENT = 11; 22 | public static final int MESSAGE_EXAMINE_NPC = 28; 23 | public static final int MESSAGE_EXAMINE_OBJECT = 29; 24 | public static final int MESSAGE_TRADE_REQ = 100; 25 | public static final int MESSAGE_ASSIST_REQ = 102; 26 | public static final int MESSAGE_TRADE_INFO = 103; 27 | public static final int MESSAGE_ASSIST_INFO = 104; 28 | public static final int MESSAGE_ACTION = 109; 29 | 30 | private static final long serialVersionUID = -8416382326776831211L; 31 | 32 | private final String sender; 33 | private final int id; 34 | private final String message; 35 | 36 | public MessageEvent(String sender, int id, String message) { 37 | this.sender = sender; 38 | this.id = id; 39 | this.message = message; 40 | } 41 | 42 | @Override 43 | public void dispatch(final EventListener el) { 44 | ((MessageListener) el).messageReceived(this); 45 | } 46 | 47 | @Override 48 | public long getMask() { 49 | return EventMulticaster.MESSAGE_EVENT; 50 | } 51 | 52 | public String getSender() { 53 | return sender; 54 | } 55 | 56 | public int getID() { 57 | return id; 58 | } 59 | 60 | public String getMessage() { 61 | return message; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/org/rsbot/Boot.java: -------------------------------------------------------------------------------- 1 | package org.rsbot; 2 | 3 | import java.io.IOException; 4 | import java.net.URLDecoder; 5 | 6 | import org.rsbot.util.GlobalConfiguration; 7 | 8 | /** 9 | * @author Paris 10 | */ 11 | public class Boot { 12 | public static void main(String[] args) throws IOException { 13 | String location = Boot.class.getProtectionDomain().getCodeSource().getLocation().getPath(); 14 | location = URLDecoder.decode(location, "UTF-8").replaceAll("\\\\", "/"); 15 | final String app = Application.class.getCanonicalName(); 16 | final String flags = "-Xmx512m -Dsun.java2d.d3d=false"; 17 | boolean sh = true; 18 | final char q = '"', s = ' '; 19 | StringBuilder param = new StringBuilder(64); 20 | 21 | switch (GlobalConfiguration.getCurrentOperatingSystem()) { 22 | case WINDOWS: 23 | sh = false; 24 | param.append("javaw"); 25 | param.append(s); 26 | param.append(flags); 27 | break; 28 | case MAC: 29 | param.append("java"); 30 | param.append(s); 31 | param.append(flags); 32 | param.append(s); 33 | param.append("-Xdock:name="); 34 | param.append(q); 35 | param.append(GlobalConfiguration.NAME); 36 | param.append(q); 37 | param.append(s); 38 | param.append("-Xdock:icon="); 39 | param.append(q); 40 | param.append(GlobalConfiguration.Paths.Resources.ICON); 41 | param.append(q); 42 | break; 43 | default: 44 | param.append("java"); 45 | param.append(s); 46 | param.append(flags); 47 | break; 48 | } 49 | 50 | param.append(s); 51 | param.append("-classpath"); 52 | param.append(s); 53 | param.append(q); 54 | param.append(location); 55 | param.append(q); 56 | param.append(s); 57 | param.append(app); 58 | 59 | final Runtime run = Runtime.getRuntime(); 60 | 61 | if (sh) { 62 | run.exec(new String[] { "/bin/sh", "-c", param.toString() } ); 63 | } else { 64 | run.exec(param.toString()); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/org/rsbot/client/RSInterface.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | public interface RSInterface { 4 | 5 | String[] getActions(); 6 | 7 | int getBorderThickness(); 8 | 9 | int getBoundsArrayIndex(); 10 | 11 | int getComponentID(); 12 | 13 | int getComponentIndex(); 14 | 15 | String getComponentName(); 16 | 17 | RSInterface[] getComponents(); 18 | 19 | int getComponentStackSize(); 20 | 21 | int getHeight(); 22 | 23 | int getHeight2(); 24 | 25 | int getHorizontalScrollBarSize(); 26 | 27 | int getHorizontalScrollBarThumbPosition(); 28 | 29 | int getHorizontalScrollBarThumbSize(); 30 | 31 | int getID(); 32 | 33 | int[] getInventory(); 34 | 35 | int[] getInventoryStackSizes(); 36 | 37 | int getInvSpritePadX(); 38 | 39 | int getInvSpritePadY(); 40 | 41 | int getMasterX(); 42 | 43 | int getMasterY(); 44 | 45 | int getModelID(); 46 | 47 | int getModelType(); 48 | 49 | int getModelZoom(); 50 | 51 | int getParentID(); 52 | 53 | String getSelectedActionName(); 54 | 55 | int getShadowColor(); 56 | 57 | int getSpecialType(); 58 | 59 | String getSpellName(); 60 | 61 | String getText(); 62 | 63 | int getTextColor(); 64 | 65 | int getTextureID(); 66 | 67 | String getToolTip(); 68 | 69 | int getType(); 70 | 71 | int[][] getValueIndexArray(); 72 | 73 | int getVerticalScrollBarPosition(); 74 | 75 | int getVerticalScrollBarSize(); 76 | 77 | int getVerticalScrollBarThumbSize(); 78 | 79 | int getWidth(); 80 | 81 | int getWidth2(); 82 | 83 | int getX(); 84 | 85 | int getXRotation(); 86 | 87 | int getY(); 88 | 89 | int getYRotation(); 90 | 91 | int getZRotation(); 92 | 93 | boolean isHorizontallyFlipped(); 94 | 95 | boolean isInventoryRSInterface(); 96 | 97 | boolean isVerticallyFlipped(); 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/org/rsbot/script/randoms/SystemUpdate.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.randoms; 2 | 3 | import org.rsbot.script.Random; 4 | import org.rsbot.script.ScriptManifest; 5 | import org.rsbot.script.util.Timer; 6 | 7 | /** 8 | * Advanced System Update script that will logout at a random time during a 9 | * system update. 10 | * 11 | * @author Gnarly 12 | */ 13 | @ScriptManifest(authors = {"Gnarly", "Pervy Shuya"}, name = "SystemUpdate", version = 1.5) 14 | public class SystemUpdate extends Random { 15 | 16 | @SuppressWarnings("unused") 17 | private int logoutSeconds; 18 | private final Timer systemTime = new Timer(0L); 19 | 20 | @Override 21 | public boolean activateCondition() { 22 | if (game.isLoggedIn() 23 | && interfaces.getComponent(754, 5).getText() 24 | .startsWith("System update in") 25 | && !getMyPlayer().isInCombat()) { 26 | check(); 27 | } 28 | return false; 29 | } 30 | 31 | @Override 32 | public int loop() { 33 | return -1; 34 | } 35 | 36 | private void check() { 37 | int logoutMinutes = random(1, getMinutes()); 38 | // logoutSeconds = random(10, getSeconds()); 39 | systemTime.setEndIn(logoutMinutes); 40 | while (!checkForLogout()) { 41 | sleep(1000); 42 | } 43 | log.info("System update will occur soon, we have logged out."); 44 | } 45 | 46 | private boolean checkForLogout() { 47 | // if ((getMinutes() < logoutMinutes) && (getSeconds() < logoutSeconds)) 48 | // { 49 | if (!systemTime.isRunning()) { 50 | stopScript(false); 51 | return true; 52 | } else { 53 | return false; 54 | } 55 | } 56 | 57 | private int getMinutes() { 58 | return Integer.parseInt(interfaces.getComponent(754, 5).getText() 59 | .substring(29).trim().split(":")[0]); 60 | } 61 | 62 | @SuppressWarnings("unused") 63 | private int getSeconds() { 64 | return Integer.parseInt(interfaces.getComponent(754, 5).getText() 65 | .substring(29).trim().split(":")[1]); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/org/rsbot/log/LogFormatter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.log; 2 | 3 | import org.rsbot.util.StringUtil; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | import java.util.logging.Formatter; 8 | import java.util.logging.LogRecord; 9 | 10 | public class LogFormatter extends Formatter { 11 | 12 | private static final String LINE_SEPARATOR = System.getProperty("line.separator"); 13 | 14 | private final boolean appendNewLine; 15 | 16 | public LogFormatter() { 17 | this(true); 18 | } 19 | 20 | public LogFormatter(boolean appendNewLine) { 21 | this.appendNewLine = appendNewLine; 22 | } 23 | 24 | @Override 25 | public String format(LogRecord record) { 26 | StringBuilder result = new StringBuilder().append("[").append(record.getLevel().getName()).append("] "). 27 | append(new Date(record.getMillis())).append(": ").append(record.getLoggerName()).append(": "). 28 | append(record.getMessage()).append(StringUtil.throwableToString(record.getThrown())); 29 | if (appendNewLine) { 30 | result.append(LogFormatter.LINE_SEPARATOR); 31 | } 32 | return result.toString(); 33 | } 34 | 35 | @Override 36 | public String formatMessage(LogRecord record) { 37 | return String.format(record.getMessage()); 38 | } 39 | 40 | public String formatTimestamp(LogRecord record) { 41 | SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss"); 42 | return "[" + dateFormat.format(record.getMillis()) + "]"; 43 | } 44 | 45 | public String formatClass(LogRecord record) { 46 | String append = "..."; 47 | String[] className = record.getLoggerName().split("\\."); 48 | String name = className[className.length - 1]; 49 | int maxLen = 16; 50 | 51 | return String.format( 52 | name.length() > maxLen ? name.substring(0, 53 | maxLen - append.length()) 54 | + append : name); 55 | } 56 | 57 | public String formatError(LogRecord record) { 58 | return StringUtil.throwableToString(record.getThrown()); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/org/rsbot/event/events/TextPaintEvent.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.events; 2 | 3 | import org.rsbot.event.EventMulticaster; 4 | import org.rsbot.event.listeners.TextPaintListener; 5 | 6 | import java.awt.*; 7 | import java.awt.geom.AffineTransform; 8 | import java.util.EventListener; 9 | 10 | /** 11 | * An event that specifies a line index and graphics 12 | * object on which a TextPaintListener should paint a 13 | * line of text. 14 | */ 15 | public class TextPaintEvent extends RSEvent { 16 | 17 | private static final long serialVersionUID = 6634362568916377937L; 18 | 19 | public Graphics graphics; 20 | public int idx; 21 | 22 | @Override 23 | public void dispatch(final EventListener el) { 24 | final Graphics2D g2d = (Graphics2D) graphics; 25 | 26 | // Backup settings 27 | // Which is needed, otherwise if some script does a transform without 28 | // cleaning 29 | // every other graphics call will use the same transformations. 30 | final Color s_background = g2d.getBackground(); 31 | final Shape s_clip = g2d.getClip(); 32 | final Color s_color = g2d.getColor(); 33 | final Composite s_composite = g2d.getComposite(); 34 | final Font s_font = g2d.getFont(); 35 | final Paint s_paint = g2d.getPaint(); 36 | final RenderingHints s_renderingHints = g2d.getRenderingHints(); 37 | final Stroke s_stroke = g2d.getStroke(); 38 | final AffineTransform s_transform = g2d.getTransform(); 39 | 40 | // Dispatch the event 41 | idx = ((TextPaintListener) el).drawLine(graphics, idx); 42 | 43 | // Restore settings 44 | g2d.setBackground(s_background); 45 | g2d.setClip(s_clip); 46 | g2d.setColor(s_color); 47 | g2d.setComposite(s_composite); 48 | g2d.setFont(s_font); 49 | g2d.setPaint(s_paint); 50 | g2d.setRenderingHints(s_renderingHints); 51 | g2d.setStroke(s_stroke); 52 | g2d.setTransform(s_transform); 53 | } 54 | 55 | @Override 56 | public long getMask() { 57 | return EventMulticaster.TEXT_PAINT_EVENT; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/org/rsbot/Application.java: -------------------------------------------------------------------------------- 1 | package org.rsbot; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.gui.BotGUI; 5 | import org.rsbot.log.LogOutputStream; 6 | import org.rsbot.log.SystemConsoleHandler; 7 | import org.rsbot.security.RestrictedSecurityManager; 8 | import org.rsbot.util.Extractor; 9 | 10 | import java.awt.*; 11 | import java.io.PrintStream; 12 | import java.util.logging.Level; 13 | import java.util.logging.Logger; 14 | 15 | public class Application { 16 | private static BotGUI gui; 17 | 18 | public static void main(final String[] args) throws Exception { 19 | System.setSecurityManager(new RestrictedSecurityManager()); 20 | bootstrap(); 21 | new Extractor(args).run(); 22 | gui = new BotGUI(); 23 | gui.setVisible(true); 24 | gui.addBot(); 25 | } 26 | 27 | /** 28 | * Returns the Bot for any object loaded in its client. For internal use 29 | * only (not useful for script writers). 30 | * 31 | * @param o Any object from within the client. 32 | * @return The Bot for the client. 33 | */ 34 | public static Bot getBot(Object o) { 35 | return gui.getBot(o); 36 | } 37 | 38 | /** 39 | * Returns the size of the panel that clients should be drawn into. For 40 | * internal use. 41 | * 42 | * @return The client panel size. 43 | */ 44 | public static Dimension getPanelSize() { 45 | return gui.getPanel().getSize(); 46 | } 47 | 48 | private static void bootstrap() { 49 | Logger.getLogger("").setLevel(Level.ALL); 50 | Logger.getLogger("").addHandler(new SystemConsoleHandler()); 51 | Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { 52 | private final Logger log = Logger.getLogger("EXCEPTION"); 53 | 54 | public void uncaughtException(final Thread t, final Throwable e) { 55 | log.logp(Level.SEVERE, "EXCEPTION", "", "Unhandled exception in thread " + t.getName() + ": ", e); 56 | } 57 | }); 58 | System.setErr(new PrintStream(new LogOutputStream(Logger.getLogger("STDERR"), Level.SEVERE), true)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/org/rsbot/event/events/CharacterMovedEvent.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.events; 2 | 3 | import org.rsbot.event.EventMulticaster; 4 | import org.rsbot.event.listeners.CharacterMovedListener; 5 | import org.rsbot.script.methods.MethodContext; 6 | 7 | import java.util.EventListener; 8 | 9 | /** 10 | * A character moved event. 11 | */ 12 | public class CharacterMovedEvent extends RSEvent { 13 | 14 | private static final long serialVersionUID = 8883312847545757405L; 15 | 16 | private final MethodContext ctx; 17 | private final org.rsbot.client.RSCharacter character; 18 | private final int direction; 19 | private org.rsbot.script.wrappers.RSCharacter wrapped; 20 | 21 | public CharacterMovedEvent(final MethodContext ctx, final org.rsbot.client.RSCharacter character, final int direction) { 22 | this.ctx = ctx; 23 | this.character = character; 24 | this.direction = direction; 25 | } 26 | 27 | @Override 28 | public void dispatch(final EventListener el) { 29 | ((CharacterMovedListener) el).characterMoved(this); 30 | } 31 | 32 | public org.rsbot.script.wrappers.RSCharacter getCharacter() { 33 | if (wrapped == null) { 34 | if (character instanceof org.rsbot.client.RSNPC) { 35 | final org.rsbot.client.RSNPC npc = (org.rsbot.client.RSNPC) character; 36 | wrapped = new org.rsbot.script.wrappers.RSNPC(ctx, npc); 37 | } else if (character instanceof org.rsbot.client.RSPlayer) { 38 | final org.rsbot.client.RSPlayer player = (org.rsbot.client.RSPlayer) character; 39 | wrapped = new org.rsbot.script.wrappers.RSPlayer(ctx, player); 40 | } 41 | } 42 | return wrapped; 43 | } 44 | 45 | /** 46 | * 0 = NW 47 | * 1 = N 48 | * 2 = NE 49 | * 3 = W 50 | * 4 = E 51 | * 5 = SW 52 | * 6 = S 53 | * 7 = SE 54 | * 55 | * @return Returns the direction of the character movement event. 56 | */ 57 | public int getDirection() { 58 | return direction; 59 | } 60 | 61 | @Override 62 | public long getMask() { 63 | return EventMulticaster.CHARACTER_MOVED_EVENT; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/org/rsbot/script/randoms/BankPins.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.randoms; 2 | 3 | import org.rsbot.gui.AccountManager; 4 | import org.rsbot.script.Random; 5 | import org.rsbot.script.ScriptManifest; 6 | import org.rsbot.script.wrappers.RSComponent; 7 | 8 | @ScriptManifest(authors = {"Holo", "Gnarly", "Salty_Fish", "Pervy Shuya", "Doout"}, name = "BankPin", version = 3.0) 9 | public class BankPins extends Random { 10 | 11 | public boolean activateCondition() { 12 | return interfaces.get(13).isValid() || interfaces.get(14).isValid(); 13 | } 14 | 15 | void enterCode(final String pin) { 16 | if (!interfaces.get(13).isValid()) { 17 | return; 18 | } 19 | final RSComponent[] children = interfaces.get(13).getComponents(); 20 | int state = 0; 21 | for (int i = 1; i < 5; i++) { 22 | if (children[i].containsText("?")) { 23 | state++; 24 | } 25 | } 26 | state = 4 - state; 27 | if (!interfaces.get(759).isValid()) { 28 | return; 29 | } 30 | final RSComponent[] bankPin = interfaces.get(759).getComponents(); 31 | for (RSComponent aBankPin : bankPin) { 32 | if (aBankPin.containsText(pin.substring(state, state + 1))) { 33 | aBankPin.doClick(true); 34 | sleep(random(500, 1000)); 35 | break; 36 | } 37 | } 38 | } 39 | 40 | @Override 41 | public int loop() { 42 | if (interfaces.get(14).isValid()) { 43 | interfaces.getComponent(14, 33).doClick(); 44 | sleep(300); 45 | } else { 46 | String pin = AccountManager.getPin(account.getName()); 47 | if ((pin == null) || (pin.length() != 4)) { 48 | log.severe("You must add a bank pin to your account."); 49 | stopScript(false); 50 | } 51 | if (interfaces.get(14).isValid() || !interfaces.get(13).isValid()) { 52 | interfaces.get(14).getComponent(3).doClick(); 53 | return -1; 54 | } 55 | enterCode(pin); 56 | if (interfaces.get(211).isValid()) { 57 | interfaces.get(211).getComponent(3).doClick(); 58 | } else if (interfaces.get(217).isValid()) { 59 | sleep(random(10500, 12000)); 60 | } 61 | } 62 | return 500; 63 | } 64 | } -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawNPCs.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.client.Node; 5 | import org.rsbot.client.RSNPCNode; 6 | import org.rsbot.event.listeners.PaintListener; 7 | import org.rsbot.script.methods.MethodContext; 8 | import org.rsbot.script.wrappers.RSNPC; 9 | 10 | import java.awt.*; 11 | 12 | public class DrawNPCs implements PaintListener { 13 | 14 | private final MethodContext ctx; 15 | 16 | public DrawNPCs(Bot bot) { 17 | ctx = bot.getMethodContext(); 18 | } 19 | 20 | public void onRepaint(final Graphics render) { 21 | if (!ctx.game.isLoggedIn()) { 22 | return; 23 | } 24 | 25 | final FontMetrics metrics = render.getFontMetrics(); 26 | for (int element : ctx.client.getRSNPCIndexArray()) { 27 | Node node = ctx.nodes.lookup(ctx.client.getRSNPCNC(), element); 28 | if (node == null || !(node instanceof RSNPCNode)) { 29 | continue; 30 | } 31 | final RSNPC npc = new RSNPC(ctx, ((RSNPCNode) node).getRSNPC()); 32 | final Point location = ctx.calc.tileToScreen(npc.getLocation(), npc.getHeight() / 2); 33 | if (!ctx.calc.pointOnScreen(location)) { 34 | continue; 35 | } 36 | render.setColor(Color.RED); 37 | render.fillRect((int) location.getX() - 1, (int) location.getY() - 1, 2, 2); 38 | String s = "" + npc.getID(); 39 | render.setColor(npc.isInCombat() ? Color.red : npc.isMoving() ? Color.green : Color.WHITE); 40 | render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() / 2); 41 | // int x = element.getX(); 42 | // x -= ((int)(x >> 7)) << 7; 43 | if (npc.getAnimation() != -1 || npc.getGraphic() != -1) { 44 | s = "(A: " + npc.getAnimation() + " | G: " + npc.getGraphic() + " | L: " + npc.getLevel() +")"; 45 | render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() * 3 / 2); 46 | } 47 | // s = "" + element.isMoving(); 48 | // render.drawString(s, location.x - metrics.stringWidth(s) / 2, 49 | // location.y - metrics.getHeight() * 5 / 2); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSTile.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | /** 4 | * A tile at an absolute location in the game world. 5 | */ 6 | public class RSTile { 7 | 8 | private final int x; 9 | private final int y; 10 | private final int z; 11 | 12 | /** 13 | * @param x the x axel of the Tile 14 | * @param y the y axel of the Tile 15 | */ 16 | public RSTile(final int x, final int y) { 17 | this.x = x; 18 | this.y = y; 19 | this.z = 0; 20 | } 21 | 22 | /** 23 | * @param x the x axel of the Tile 24 | * @param y the y axel of the Tile 25 | * @param z the z axel of the Tile( the floor) 26 | */ 27 | public RSTile(final int x, final int y, final int z) { 28 | this.x = x; 29 | this.y = y; 30 | this.z = z; 31 | } 32 | 33 | public int getX() { 34 | return x; 35 | } 36 | 37 | public int getY() { 38 | return y; 39 | } 40 | 41 | public int getZ() { 42 | return z; 43 | } 44 | 45 | /** 46 | * Randomizes this tile. 47 | * 48 | * @param maxXDeviation Max X distance from tile x. 49 | * @param maxYDeviation Max Y distance from tile y. 50 | * @return The randomized tile 51 | */ 52 | public RSTile randomize(final int maxXDeviation, final int maxYDeviation) { 53 | int x = getX(); 54 | int y = getY(); 55 | if (maxXDeviation > 0) { 56 | double d = Math.random() * 2 - 1.0; 57 | d *= maxXDeviation; 58 | x += (int) d; 59 | } 60 | if (maxYDeviation > 0) { 61 | double d = Math.random() * 2 - 1.0; 62 | d *= maxYDeviation; 63 | y += (int) d; 64 | } 65 | return new RSTile(x, y); 66 | } 67 | 68 | @Override 69 | public int hashCode() { 70 | return x * 31 + y; 71 | } 72 | 73 | @Override 74 | public boolean equals(final Object obj) { 75 | if (obj == this) { 76 | return true; 77 | } 78 | if (obj instanceof RSTile) { 79 | final RSTile tile = (RSTile) obj; 80 | return (tile.x == x) && (tile.y == y) && (tile.z == z); 81 | } 82 | return false; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "(X: " + x + ", Y:" + y + ", Z:" + z + ")"; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawSettings.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.PaintListener; 5 | import org.rsbot.script.methods.Settings; 6 | 7 | import java.awt.*; 8 | import java.util.Arrays; 9 | 10 | public class DrawSettings implements PaintListener { 11 | 12 | private static final Font monoFont = Font.decode(Font.MONOSPACED); 13 | private static final int TIMEOUT = 5000; 14 | 15 | private int[] lastSettings = new int[0]; 16 | private long[] settingsAge = new long[0]; 17 | 18 | private final Settings settings; 19 | 20 | public DrawSettings(Bot bot) { 21 | settings = bot.getMethodContext().settings; 22 | } 23 | 24 | public void onRepaint(final Graphics render) { 25 | final int[] settings = this.settings.getSettingArray(); 26 | if (settings != null) { 27 | final Font prev = render.getFont(); 28 | render.setFont(DrawSettings.monoFont); 29 | if (settings.length > lastSettings.length) { 30 | lastSettings = Arrays.copyOf(lastSettings, settings.length); 31 | settingsAge = Arrays.copyOf(settingsAge, settings.length); 32 | } 33 | int id = 0; 34 | final long curTime = System.currentTimeMillis(); 35 | final long cutoffTime = curTime - DrawSettings.TIMEOUT; 36 | for (int i = 0; i < settings.length; i++) { 37 | if (settingsAge[i] == 0) { 38 | settingsAge[i] = settings[i] != 0 ? cutoffTime : curTime; 39 | } 40 | if (lastSettings[i] != settings[i]) { 41 | settingsAge[i] = curTime; 42 | lastSettings[i] = settings[i]; 43 | } 44 | final boolean highlight = settingsAge[i] > cutoffTime; 45 | final boolean show = settings[i] != 0; 46 | if (show || highlight) { 47 | final int x = 10 + 140 * (id % 4); 48 | final int y = 70 + 12 * (id / 4); 49 | final String s = String.format("%4d: %d", i, settings[i]); 50 | render.setColor(Color.black); 51 | render.drawString(s, x, y + 1); 52 | render.setColor(highlight ? Color.red : Color.green); 53 | render.drawString(s, x, y); 54 | id++; 55 | } 56 | } 57 | render.setFont(prev); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawItems.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.PaintListener; 5 | import org.rsbot.script.methods.MethodContext; 6 | import org.rsbot.script.wrappers.RSGroundItem; 7 | import org.rsbot.script.wrappers.RSModel; 8 | import org.rsbot.script.wrappers.RSPlayer; 9 | import org.rsbot.script.wrappers.RSTile; 10 | 11 | import java.awt.*; 12 | 13 | public class DrawItems implements PaintListener { 14 | 15 | private final MethodContext ctx; 16 | 17 | public DrawItems(Bot bot) { 18 | ctx = bot.getMethodContext(); 19 | } 20 | 21 | public void onRepaint(final Graphics render) { 22 | if (!ctx.game.isLoggedIn()) { 23 | return; 24 | } 25 | final RSPlayer player = ctx.players.getMyPlayer(); 26 | if (player == null) { 27 | return; 28 | } 29 | final FontMetrics metrics = render.getFontMetrics(); 30 | final RSTile location = player.getLocation(); 31 | final int locX = location.getX(); 32 | final int locY = location.getY(); 33 | final int tHeight = metrics.getHeight(); 34 | for (int x = locX - 25; x < locX + 25; x++) { 35 | for (int y = locY - 25; y < locY + 25; y++) { 36 | final Point screen = ctx.calc.tileToScreen(new RSTile(x, y)); 37 | if (!ctx.calc.pointOnScreen(screen)) { 38 | continue; 39 | } 40 | final RSGroundItem[] items = ctx.groundItems.getAllAt(x, y); 41 | if (items.length > 0) { 42 | RSModel model = items[0].getModel(); 43 | if (model != null) { 44 | render.setColor(Color.BLUE); 45 | for (Polygon polygon : model.getTriangles()) { 46 | render.drawPolygon(polygon); 47 | } 48 | } 49 | } 50 | for (int i = 0; i < items.length; i++) { 51 | render.setColor(Color.RED); 52 | render.fillRect((int) screen.getX() - 1, (int) screen.getY() - 1, 2, 2); 53 | final String s = "" + items[i].getItem().getID(); 54 | final int ty = screen.y - tHeight * (i + 1) + tHeight / 2; 55 | final int tx = screen.x - metrics.stringWidth(s) / 2; 56 | render.setColor(Color.green); 57 | render.drawString(s, tx, ty); 58 | } 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/org/rsbot/service/TwitterUpdates.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | import java.awt.Color; 4 | import java.io.BufferedReader; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | import java.net.URL; 8 | import java.util.logging.Level; 9 | import java.util.logging.Logger; 10 | 11 | import org.rsbot.util.GlobalConfiguration; 12 | 13 | public class TwitterUpdates { 14 | 15 | private TwitterUpdates() { } 16 | 17 | public static void loadTweets(final int count) { 18 | final Logger log = Logger.getLogger("@" + GlobalConfiguration.Twitter.NAME); 19 | final Level level = Level.INFO; 20 | final Object[] param = new Object[] { new Color(0x1d, 0x83, 0xae) }; 21 | 22 | StringBuilder url = new StringBuilder(); 23 | url.append("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name="); 24 | url.append(GlobalConfiguration.Twitter.NAME); 25 | url.append("&count="); 26 | url.append(count * 5); 27 | 28 | InputStreamReader stream = null; 29 | BufferedReader reader = null; 30 | 31 | try { 32 | stream = new InputStreamReader(new URL(url.toString()).openStream()); 33 | reader = new BufferedReader(stream); 34 | String s = null; 35 | int c = 0; 36 | while ((s = reader.readLine()) != null) { 37 | final String a = "", b = ""; 38 | int x = s.indexOf(a); 39 | if (x == -1) 40 | continue; 41 | x += a.length(); 42 | final int y = s.indexOf(b, x); 43 | if (y == -1) 44 | continue; 45 | String msg = s.substring(x, y).trim(); 46 | if (!msg.contains(GlobalConfiguration.Twitter.HASHTAG)) 47 | continue; 48 | if (msg.endsWith(GlobalConfiguration.Twitter.HASHTAG)) 49 | msg = msg.substring(0, msg.length() - GlobalConfiguration.Twitter.HASHTAG.length()).trim(); 50 | if (msg.isEmpty()) 51 | continue; 52 | log.log(level, msg, param); 53 | if (++c == count) 54 | break; 55 | } 56 | } catch (IOException ioe) { 57 | } finally { 58 | try { 59 | if (reader != null) 60 | reader.close(); 61 | if (stream != null) 62 | stream.close(); 63 | } catch (IOException ioe1) { } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/org/rsbot/util/UIDData.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileOutputStream; 6 | import java.io.FileReader; 7 | import java.util.HashMap; 8 | 9 | public class UIDData { 10 | 11 | private static final String newline = System.getProperty("line.separator"); 12 | private static final String separator = "#"; 13 | 14 | private final HashMap uids = new HashMap(); 15 | private String lastUsed = ""; 16 | 17 | public UIDData() { 18 | File fUIDs = new File(GlobalConfiguration.Paths.getUIDsFile()); 19 | if (!fUIDs.exists()) { 20 | return; 21 | } 22 | 23 | try { 24 | final BufferedReader in = new BufferedReader(new FileReader(fUIDs)); 25 | String line;// Used to store the lines from the file 26 | while ((line = in.readLine()) != null) { 27 | if (line.isEmpty()) { 28 | continue; 29 | } 30 | 31 | String[] data = line.split(separator, 2); 32 | uids.put(data[0], data[1].getBytes()); 33 | } 34 | } catch (Exception ignored) { 35 | } 36 | } 37 | 38 | public String getLastUsed() { 39 | return this.lastUsed; 40 | } 41 | 42 | public byte[] getUID(String name) { 43 | if (name.equals("")) { 44 | name = "DEFAULT"; 45 | } 46 | 47 | lastUsed = name; 48 | 49 | byte[] data = uids.get(name); 50 | if (data == null) { 51 | return new byte[0]; 52 | } 53 | 54 | return data; 55 | } 56 | 57 | public void setUID(String name, byte[] uid) { 58 | if (name.equals("")) { 59 | name = "DEFAULT"; 60 | } 61 | 62 | uids.put(name, uid); 63 | } 64 | 65 | public void save() { 66 | try { 67 | File fUIDs = new File(GlobalConfiguration.Paths.getUIDsFile()); 68 | if (fUIDs.exists() || fUIDs.createNewFile()) { 69 | final FileOutputStream out = new FileOutputStream(fUIDs); 70 | for (String key : uids.keySet()) { 71 | out.write(key.getBytes()); 72 | out.write(separator.getBytes()); 73 | out.write(uids.get(key)); 74 | 75 | out.write(newline.getBytes()); 76 | } 77 | out.close(); 78 | } 79 | } catch (Exception ignored) { 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /src/org/rsbot/script/PassiveScript.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script; 2 | 3 | import org.rsbot.script.methods.MethodContext; 4 | import org.rsbot.script.methods.Methods; 5 | 6 | import java.util.EventListener; 7 | 8 | public abstract class PassiveScript extends Methods implements EventListener, Runnable { 9 | protected String name = ""; 10 | private volatile boolean enabled = true; 11 | private volatile boolean running = false; 12 | private boolean runningL = false; 13 | private int id = -1; 14 | 15 | public abstract boolean activateCondition(); 16 | 17 | public abstract int loop(); 18 | 19 | public abstract int iterationSleep(); 20 | 21 | public boolean onStart() { 22 | return true; 23 | } 24 | 25 | public void onFinish() { 26 | 27 | } 28 | 29 | @Override 30 | public final void init(MethodContext ctx) { 31 | super.init(ctx); 32 | onStart(); 33 | } 34 | 35 | public final boolean isEnabled() { 36 | return enabled; 37 | } 38 | 39 | public final void setEnabled(boolean enabled) { 40 | this.enabled = enabled; 41 | } 42 | 43 | public final void run() { 44 | name = getClass().getAnnotation(PassiveScriptManifest.class).name(); 45 | ctx.bot.getEventManager().addListener(this); 46 | running = true; 47 | try { 48 | while (running) { 49 | if (activateCondition()) { 50 | boolean start = onStart(); 51 | if (start) { 52 | while (running) { 53 | int timeOut = loop(); 54 | if (timeOut == -1) { 55 | break; 56 | } 57 | Thread.sleep(timeOut); 58 | } 59 | onFinish(); 60 | } 61 | } 62 | Thread.sleep(iterationSleep()); 63 | } 64 | } catch (Exception ignored) { 65 | } 66 | ctx.bot.getEventManager().removeListener(this); 67 | running = false; 68 | } 69 | 70 | public final void deactivate(int id) { 71 | if (id != this.id) { 72 | throw new IllegalStateException("Invalid id!"); 73 | } 74 | this.running = false; 75 | } 76 | 77 | public final void setID(int id) { 78 | if (this.id != -1) { 79 | throw new IllegalStateException("Already added to pool!"); 80 | } 81 | this.id = id; 82 | } 83 | 84 | public final int getID() { 85 | return id; 86 | } 87 | 88 | public final boolean isRunning() { 89 | return running; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/org/rsbot/script/randoms/FirstTimeDeath.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.randoms; 2 | 3 | import org.rsbot.script.Random; 4 | import org.rsbot.script.ScriptManifest; 5 | import org.rsbot.script.wrappers.RSNPC; 6 | import org.rsbot.script.wrappers.RSObject; 7 | import org.rsbot.script.wrappers.RSTile; 8 | 9 | @ScriptManifest(authors = {"Taha"}, name = "FirstTimeDeath", version = 1.1) 10 | public class FirstTimeDeath extends Random { 11 | private int step; 12 | private boolean exit; 13 | private RSNPC reaper; 14 | 15 | @Override 16 | public boolean activateCondition() { 17 | return ((reaper = npcs.getNearest(8869)) != null) 18 | || ((reaper = npcs.getNearest(8870)) != null); 19 | } 20 | 21 | @Override 22 | public int loop() { 23 | if (!activateCondition()) { 24 | return -1; 25 | } 26 | camera.setPitch(true); 27 | if (interfaces.canContinue() && !exit) { 28 | if (interfaces.getComponent(241, 4).getText().contains("Yes?")) { 29 | step++; 30 | exit = true; 31 | return random(200, 400); 32 | } else if (interfaces.getComponent(242, 5).getText() 33 | .contains("Enjoy!")) { 34 | step++; 35 | exit = true; 36 | } 37 | interfaces.clickContinue(); 38 | return random(200, 400); 39 | } 40 | switch (step) { 41 | case 0: 42 | RSObject reaperChair = objects.getNearest(45802); 43 | reaperChair.doAction("Talk-to"); 44 | sleep(random(1000, 1200)); 45 | if (!interfaces.canContinue()) { 46 | walking.walkTileOnScreen(new RSTile( 47 | reaper.getLocation().getX() + 2, reaper.getLocation() 48 | .getY() + 1)); 49 | camera.turnTo(reaperChair); 50 | } 51 | break; 52 | 53 | case 1: 54 | int portalID = 45803; 55 | RSObject portal = objects.getNearest(portalID); 56 | RSTile loc = getMyPlayer().getLocation(); 57 | portal.doAction("Enter"); 58 | sleep(random(1000, 1200)); 59 | if (calc.distanceTo(loc) < 10) { 60 | camera.turnTo(portal); 61 | if (!calc.tileOnScreen(portal.getLocation())) { 62 | walking.walkTileOnScreen(portal.getLocation()); 63 | } 64 | } 65 | break; 66 | } 67 | return random(200, 400); 68 | } 69 | 70 | @Override 71 | public void onFinish() { 72 | step = -1; 73 | exit = false; 74 | reaper = null; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/org/rsbot/util/ScreenshotUtil.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.util; 2 | 3 | import org.rsbot.bot.Bot; 4 | 5 | import javax.imageio.ImageIO; 6 | import java.awt.*; 7 | import java.awt.image.BufferedImage; 8 | import java.awt.image.WritableRaster; 9 | import java.io.File; 10 | import java.text.SimpleDateFormat; 11 | import java.util.Date; 12 | import java.util.logging.Level; 13 | import java.util.logging.Logger; 14 | 15 | public class ScreenshotUtil { 16 | 17 | private static final Logger log = Logger.getLogger(ScreenshotUtil.class.getName()); 18 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-hhmmss"); 19 | 20 | public static void saveScreenshot(final Bot bot, final boolean hideUsername) { 21 | final String name = ScreenshotUtil.dateFormat.format(new Date()) + ".png"; 22 | final File dir = new File(GlobalConfiguration.Paths.getScreenshotsDirectory()); 23 | if (dir.isDirectory() || dir.mkdirs()) { 24 | ScreenshotUtil.saveScreenshot(bot, new File(dir, name), "png", hideUsername); 25 | } 26 | } 27 | 28 | private static void saveScreenshot(final Bot bot, final File file, final String type, final boolean hideUsername) { 29 | try { 30 | BufferedImage image = takeScreenshot(bot, hideUsername); 31 | 32 | ImageIO.write(image, type, file); 33 | ScreenshotUtil.log.info("Screenshot saved to: " + file.getPath()); 34 | } catch (final Exception e) { 35 | ScreenshotUtil.log.log(Level.SEVERE, "Could not take screenshot.", e); 36 | } 37 | } 38 | 39 | public static BufferedImage takeScreenshot(final Bot bot, final boolean hideUsername) { 40 | final BufferedImage source = bot.getImage(); 41 | final WritableRaster raster = source.copyData(null); 42 | 43 | final BufferedImage bufferedImage = new BufferedImage(source.getColorModel(), raster, 44 | source.isAlphaPremultiplied(), null); 45 | final Graphics2D graphics = bufferedImage.createGraphics(); 46 | 47 | if (hideUsername) { 48 | if (bot.getMethodContext().game.isFixed()) { 49 | graphics.setColor(Color.black); 50 | graphics.fill(new Rectangle(9, 459, 100, 15)); 51 | graphics.dispose(); 52 | } else { 53 | graphics.setColor(Color.black); 54 | graphics.drawRect(8, 555, 100, 15); 55 | graphics.dispose(); 56 | } 57 | } 58 | return source; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/org/rsbot/script/methods/Settings.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.methods; 2 | 3 | /** 4 | * Provides access to game settings. 5 | */ 6 | public class Settings extends MethodProvider { 7 | 8 | public static final int SETTING_COMBAT_STYLE = 43; 9 | public static final int SETTING_TOGGLE_RUN = 173; 10 | public static final int SETTING_BANK_TOGGLE_REARRANGE_MODE = 304; 11 | public static final int SETTING_TOGGLE_ACCEPT_AID = 427; 12 | public static final int SETTING_MOUSE_BUTTONS = 170; 13 | public static final int SETTING_CHAT_EFFECTS = 171; 14 | public static final int SETTING_SPLIT_PRIVATE_CHAT = 287; 15 | public static final int SETTING_ADJUST_SCREEN_BRIGHTNESS = 166; 16 | public static final int SETTING_ADJUST_MUSIC_VOLUME = 168; 17 | public static final int SETTING_ADJUST_SOUND_EFFECT_VOLUME = 169; 18 | public static final int SETTING_ADJUST_AREA_SOUND_EFFECT_VOLUME = 872; 19 | public static final int SETTING_AUTO_RETALIATE = 172; 20 | public static final int SETTING_SWAP_QUEST_DIARY = 1002; 21 | public static final int SETTING_PRAYER_THICK_SKIN = 83; 22 | public static final int SETTING_TOGGLE_LOOP_MUSIC = 19; 23 | public static final int SETTING_BANK_TOGGLE_WITHDRAW_MODE = 115; 24 | public static final int SETTING_TYPE_SHOP = 118; 25 | public static final int SETTING_SPECIAL_ATTACK_ENABLED = 301; 26 | 27 | Settings(final MethodContext ctx) { 28 | super(ctx); 29 | } 30 | 31 | /** 32 | * Gets the settings array. 33 | * 34 | * @return An int array representing all of the settings values; 35 | * otherwise new int[0]. 36 | */ 37 | public int[] getSettingArray() { 38 | org.rsbot.client.Settings settingArray = methods.client 39 | .getSettingArray(); 40 | if (settingArray == null || settingArray.getData() == null) { 41 | return new int[0]; 42 | } 43 | return settingArray.getData().clone(); // NEVER return pointer 44 | } 45 | 46 | /** 47 | * Gets the setting at a given index. 48 | * 49 | * @param setting The setting index to return the value of. 50 | * @return int representing the setting of the given setting id; 51 | * otherwise -1. 52 | */ 53 | public int getSetting(final int setting) { 54 | int[] settings = getSettingArray(); 55 | if (setting < settings.length) { 56 | return settings[setting]; 57 | } 58 | return -1; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | SETLOCAL 4 | CALL :setvars 5 | SET cmd=%1 6 | IF "%cmd%"=="" SET cmd=all 7 | CALL :%cmd% 8 | GOTO :eof 9 | 10 | :setvars 11 | SET name=RSBot 12 | SET cc=javac 13 | SET cflags=-g -Xlint:deprecation 14 | SET src=src 15 | SET lib=lib 16 | SET res=resources 17 | SET out=bin 18 | SET dist=%name%.jar 19 | SET lstf=temp.txt 20 | SET imgdir=%res%\images 21 | SET manifest=%res%\Manifest.txt 22 | SET versionfile=%res%\version.txt 23 | FOR /F %%G IN (%versionfile%) DO SET version=%%G 24 | SET scripts=scripts 25 | CALL "%res%\FindJDK.bat" 26 | GOTO :eof 27 | 28 | :all 29 | CALL :clean 2>NUL 30 | ECHO Compiling bot 31 | CALL :Bot 32 | ECHO Compiling scripts 33 | CALL :Scripts 2>NUL 34 | ECHO Packing JAR 35 | CALL :pack 36 | CALL :end 37 | GOTO :eof 38 | 39 | :Bot 40 | IF EXIST "%lstf%" DEL /F /Q "%lstf%" 41 | FOR /F "usebackq tokens=*" %%G IN (`DIR /B /S "%src%\*.java"`) DO CALL :append "%%G" 42 | IF EXIST "%out%" RMDIR /S /Q "%out%" > NUL 43 | MKDIR "%out%" 44 | "%cc%" %cflags% -d "%out%" "@%lstf%" 2>NUL 45 | DEL /F /Q "%lstf%" 46 | GOTO :eof 47 | 48 | :Scripts 49 | CALL :mostlyclean 50 | "%cc%" %cflags% -cp "%out%" %scripts%\*.java 51 | GOTO :eof 52 | 53 | :pack 54 | IF EXIST "%dist%" DEL /F /Q "%dist%" 55 | IF EXIST "%lstf%" DEL /F /Q "%lstf%" 56 | COPY "%manifest%" "%lstf%" 57 | ECHO Specification-Version: "%version%" >> "%lstf%" 58 | ECHO Implementation-Version: "%version%" >> "%lstf%" 59 | jar cfm "%dist%" "%lstf%" -C "%out%" . %versionfile% %imgdir%\* %res%\*.bat %res%\*.sh 60 | DEL /F /Q "%lstf%" 61 | GOTO :eof 62 | 63 | :end 64 | CALL :clean 2>NUL 65 | ECHO Compilation successful. 66 | GOTO :eof 67 | 68 | :append 69 | SET gx=%1 70 | SET gx=%gx:\=\\% 71 | ECHO %gx% >> %lstf% 72 | GOTO :eof 73 | 74 | :mostlyclean 75 | ECHO. > "%scripts%\.class" 76 | DEL /F /Q %scripts%\*.class 77 | GOTO :eof 78 | 79 | :clean 80 | CALL :mostlyclean 81 | RMDIR /S /Q "%out%" 2>NUL 82 | GOTO :eof 83 | 84 | :remove 85 | IF EXIST "%APPDATA%\%name%_Accounts.ini" DEL "%APPDATA%\%name%_Accounts.ini" 86 | IF EXIST "%APPDATA%\%name% Accounts.ini" DEL "%APPDATA%\%name% Accounts.ini" 87 | IF EXIST "%RSBOT_HOME%" RMDIR /S /Q "%RSBOT_HOME%" 88 | FOR /F "tokens=3" %%G IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal"') DO (SET docs=%%G) 89 | IF EXIST "%docs%\%name%" RMDIR /S /Q "%docs%\%name%" 90 | GOTO :eof 91 | -------------------------------------------------------------------------------- /src/org/rsbot/util/PreferenceData.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.util; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.RandomAccessFile; 6 | 7 | public class PreferenceData { 8 | private final int type; 9 | private final File file; 10 | 11 | public PreferenceData(int type) { 12 | this.type = type; 13 | file = new File(GlobalConfiguration.Paths.getSettingsDirectory() + File.separator + "pref" + type + ".dat"); 14 | try { 15 | if (!file.exists()) { 16 | file.createNewFile(); 17 | switch (type) { 18 | case 1: 19 | set(new byte[]{ 20 | 24, 0, 0, 3, 0, 0, 0, 0, 21 | 0, 0, 0, 0, 0, 0, 1, 2, 22 | 0, 0, 0, 3, 1, 0, 1, 0, 23 | 0, 4, 8, 0, 0, 0, 127, 0, 24 | 1, 1, 0, 0, 0, 0, 0, 0, 25 | 0, 4, 0, 1, 2, 0 26 | }); 27 | break; 28 | 29 | case 2: 30 | set(new byte[]{ 31 | 1, 0, 19, 3, -38, 0, 0, 0, 32 | 1, 3, -37, 0, 0, 0, 1, 3, 33 | -30, 0, 0, 0, 2, 3, -28, -1, 34 | -1, -1, -1, 3, -27, -1, -1, -1, 35 | -1, 3, -26, -1, -1, -1, -1, 3, 36 | -25, -1, -1, -1, -1, 4, 11, 0, 37 | 0, 0, 79, 4, 12, 0, 0, 0, 38 | 74, 4, 13, -1, -1, -1, -1, 4, 39 | 28, -1, -1, -1, -1, 4, -40, 0, 40 | 0, 0, 3, 4, -6, 0, 0, 0, 41 | 67, 4, -3, 0, 0, 0, 0, 5, 42 | 35, -1, -1, -1, -1, 5, 36, -1, 43 | -1, -1, -1, 5, -122, 0, 0, 0, 44 | 1, 5, -115, -1, -1, -1, -1, 5, 45 | -107, -1, -1, -1, -1 46 | }); 47 | break; 48 | } 49 | } 50 | } catch (IOException ignored) { 51 | } 52 | } 53 | 54 | public byte[] get() { 55 | try { 56 | RandomAccessFile raf = new RandomAccessFile(file, "rw"); 57 | byte[] b = new byte[(int) raf.length()]; 58 | raf.readFully(b); 59 | 60 | return checkPrefs(b); 61 | } catch (IOException ioe) { 62 | return new byte[0]; 63 | } 64 | } 65 | 66 | public void set(byte[] data) { 67 | data = checkPrefs(data); 68 | 69 | try { 70 | RandomAccessFile raf = new RandomAccessFile(file, "rw"); 71 | raf.write(data); 72 | } catch (IOException ignored) { 73 | } 74 | } 75 | 76 | private byte[] checkPrefs(byte[] data) { 77 | switch (type) { 78 | 79 | case 1: { 80 | if (data.length <= 40) { 81 | break; 82 | } 83 | 84 | data[19] = 3; //Graphics Mode 85 | } 86 | 87 | } 88 | 89 | return data; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawPlayers.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.PaintListener; 5 | import org.rsbot.script.methods.MethodContext; 6 | import org.rsbot.script.wrappers.RSPlayer; 7 | 8 | import java.awt.*; 9 | 10 | public class DrawPlayers implements PaintListener { 11 | 12 | private final MethodContext ctx; 13 | 14 | public DrawPlayers(Bot bot) { 15 | ctx = bot.getMethodContext(); 16 | } 17 | 18 | public void onRepaint(final Graphics render) { 19 | if (!ctx.game.isLoggedIn()) { 20 | return; 21 | } 22 | final org.rsbot.client.RSPlayer[] players = ctx.client.getRSPlayerArray(); 23 | if (players == null) { 24 | return; 25 | } 26 | final FontMetrics metrics = render.getFontMetrics(); 27 | for (final org.rsbot.client.RSPlayer element : players) { 28 | if (element == null) { 29 | continue; 30 | } 31 | final RSPlayer player = new RSPlayer(ctx, element); 32 | final Point location = ctx.calc.tileToScreen(player.getLocation(), player.getHeight() / 2); 33 | if (!ctx.calc.pointOnScreen(location)) { 34 | continue; 35 | } 36 | render.setColor(Color.RED); 37 | render.fillRect((int) location.getX() - 1, (int) location.getY() - 1, 2, 2); 38 | String s = "" + player.getName() + " (" + player.getCombatLevel() + ")"; 39 | render.setColor(player.isInCombat() ? Color.RED : player.isMoving() ? Color.GREEN : Color.WHITE); 40 | render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() / 2); 41 | String msg = player.getMessage(); 42 | boolean raised = false; 43 | if (player.getAnimation() != -1 || player.getGraphic() != -1 || player.getNPCID() != -1) { 44 | if (player.getNPCID() != -1) { 45 | s = "(NPC: " + player.getNPCID() + " | L: " + player.getLevel() + " | A: " + player.getAnimation() + " | G: " + player.getGraphic() + ")"; 46 | } else { 47 | s = "(A: " + player.getAnimation() + " | L: " + player.getLevel() + " | G: " + player.getGraphic() + ")"; 48 | } 49 | render.drawString(s, location.x - metrics.stringWidth(s) / 2, location.y - metrics.getHeight() * 3 / 2); 50 | raised = true; 51 | } 52 | if (msg != null) { 53 | render.setColor(Color.ORANGE); 54 | render.drawString(msg, location.x - metrics.stringWidth(msg) / 2, 55 | location.y - metrics.getHeight() * (raised ? 5 : 3) / 2); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/org/rsbot/script/passives/WebLoader.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.passives; 2 | 3 | import org.rsbot.script.PassiveScript; 4 | import org.rsbot.script.PassiveScriptManifest; 5 | import org.rsbot.script.internal.wrappers.TileFlags; 6 | import org.rsbot.script.methods.Web; 7 | import org.rsbot.script.wrappers.RSTile; 8 | import org.rsbot.util.GlobalConfiguration; 9 | 10 | import java.io.BufferedReader; 11 | import java.io.FileReader; 12 | import java.util.HashMap; 13 | 14 | @PassiveScriptManifest(name = "Web Data Loader", authors = {"Timer"}) 15 | public class WebLoader extends PassiveScript { 16 | @Override 17 | public boolean activateCondition() { 18 | return !Web.loaded; 19 | } 20 | 21 | @Override 22 | public int loop() { 23 | if (!Web.loaded) { 24 | try { 25 | final long startLoad = System.currentTimeMillis(); 26 | BufferedReader br = new BufferedReader(new FileReader(GlobalConfiguration.Paths.getWebCache())); 27 | String line; 28 | final HashMap theFlagsList = new HashMap(); 29 | while ((line = br.readLine()) != null) { 30 | String[] data = line.split("tile=data"); 31 | if (data.length == 2) { 32 | String[] tileData = data[0].split(","); 33 | String[] abbData = data[1].split("="); 34 | if (tileData.length == 3) { 35 | try { 36 | RSTile tile = new RSTile(Integer.parseInt(tileData[0]), Integer.parseInt(tileData[1]), Integer.parseInt(tileData[2])); 37 | TileFlags tileFlags = new TileFlags(tile); 38 | for (String abb : abbData) { 39 | if (abb.length() > 0) { 40 | try { 41 | tileFlags.addKey(Integer.parseInt(abb)); 42 | } catch (Exception e) { 43 | } 44 | } 45 | } 46 | theFlagsList.put(tile, tileFlags); 47 | } catch (Exception e) { 48 | } 49 | } else { 50 | log.info("Length != 3"); 51 | } 52 | } else { 53 | log.info("Lengh != 2" + line); 54 | } 55 | } 56 | Web.map.putAll(theFlagsList); 57 | Web.loaded = true; 58 | final long timeTook = System.currentTimeMillis() - startLoad; 59 | log("Loaded " + Web.map.size() + " nodes in " + timeTook + "ms."); 60 | } catch (Exception e) { 61 | log("Failed to load the web.. trying again."); 62 | } 63 | } 64 | if (Web.loaded) { 65 | deactivate(getID()); 66 | } 67 | return -1; 68 | } 69 | 70 | @Override 71 | public int iterationSleep() { 72 | return 5000; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/org/rsbot/util/HttpAgent.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.util; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.DataInputStream; 6 | import java.io.File; 7 | import java.io.FileOutputStream; 8 | import java.io.IOException; 9 | import java.net.HttpURLConnection; 10 | import java.net.URL; 11 | import java.util.logging.Logger; 12 | import java.util.zip.GZIPInputStream; 13 | 14 | /** 15 | * @author Paris 16 | */ 17 | public class HttpAgent { 18 | private static final Logger log = Logger.getLogger(HttpAgent.class.getName()); 19 | 20 | public static HttpURLConnection download(final URL url, final File file) throws IOException { 21 | HttpURLConnection con = GlobalConfiguration.getHttpConnection(url); 22 | con.setUseCaches(true); 23 | 24 | if (file.exists()) { 25 | con.setIfModifiedSince(file.lastModified()); 26 | con.connect(); 27 | if (con.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) { 28 | log.fine("Using " + file.getName() + " from cache"); 29 | con.disconnect(); 30 | return con; 31 | } 32 | } 33 | 34 | log.fine("Downloading new " + file.getName()); 35 | 36 | DataInputStream di = new DataInputStream(con.getInputStream()); 37 | byte[] buffer = new byte[con.getContentLength()]; 38 | di.readFully(buffer); 39 | di.close(); 40 | buffer = ungzip(buffer); 41 | 42 | if (!file.exists()) { 43 | file.createNewFile(); 44 | } 45 | if (file.exists() && (!file.canRead() || file.canWrite())) { 46 | file.setReadable(true); 47 | file.setWritable(true); 48 | } 49 | if (file.exists() && file.canRead() && file.canWrite()) { 50 | FileOutputStream fos = new FileOutputStream(file); 51 | fos.write(buffer); 52 | fos.flush(); 53 | fos.close(); 54 | } 55 | 56 | file.setLastModified(con.getLastModified()); 57 | 58 | con.disconnect(); 59 | return con; 60 | } 61 | 62 | 63 | private static byte[] ungzip(byte[] data) { 64 | if (data.length < 2) { 65 | return data; 66 | } 67 | 68 | int header = (data[0] | data[1] << 8) ^ 0xffff0000; 69 | if (header != GZIPInputStream.GZIP_MAGIC) { 70 | return data; 71 | } 72 | 73 | try { 74 | ByteArrayInputStream b = new ByteArrayInputStream(data); 75 | GZIPInputStream gzin = new GZIPInputStream(b); 76 | ByteArrayOutputStream out = new ByteArrayOutputStream(data.length); 77 | for (int c = gzin.read(); c != -1; c = gzin.read()) { 78 | out.write(c); 79 | } 80 | return out.toByteArray(); 81 | } catch (IOException e) { 82 | e.printStackTrace(); 83 | return data; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSPlayer.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.client.RSPlayerComposite; 4 | import org.rsbot.script.methods.MethodContext; 5 | 6 | import java.awt.*; 7 | import java.lang.ref.SoftReference; 8 | 9 | /** 10 | * Represents a player. 11 | */ 12 | public class RSPlayer extends RSCharacter { 13 | 14 | private final SoftReference p; 15 | 16 | public RSPlayer(final MethodContext ctx, final org.rsbot.client.RSPlayer p) { 17 | super(ctx); 18 | this.p = new SoftReference(p); 19 | } 20 | 21 | protected org.rsbot.client.RSCharacter getAccessor() { 22 | return p.get(); 23 | } 24 | 25 | public int getCombatLevel() { 26 | return p.get().getLevel(); 27 | } 28 | 29 | @Override 30 | public String getName() { 31 | return p.get().getName(); 32 | } 33 | 34 | public int getTeam() { 35 | return p.get().getTeam(); 36 | } 37 | 38 | public int getNPCID() { 39 | RSPlayerComposite comp = p.get().getComposite(); 40 | if (comp != null) { 41 | return comp.getNPCID(); 42 | } 43 | return -1; 44 | } 45 | 46 | public boolean isIdle() { 47 | return !isMoving() && (getAnimation() == -1) && !isInCombat(); 48 | } 49 | 50 | @Override 51 | public boolean doAction(final String action) { 52 | return doAction(action, null); 53 | } 54 | 55 | @Override 56 | public boolean doAction(final String action, final String option) { 57 | final RSModel model = getModel(); 58 | if (model != null && isValid()) { 59 | return model.doAction(action, option); 60 | } 61 | try { 62 | Point screenLoc; 63 | for (int i = 0; i < 20; i++) { 64 | screenLoc = getScreenLocation(); 65 | if (!isValid() || !methods.calc.pointOnScreen(screenLoc)) { 66 | return false; 67 | } 68 | if (methods.mouse.getLocation().equals(screenLoc)) { 69 | break; 70 | } 71 | methods.mouse.move(screenLoc); 72 | } 73 | String[] items = methods.menu.getItems(); 74 | if (items.length <= 1) { 75 | return false; 76 | } 77 | if (items[0].toLowerCase().contains(action.toLowerCase())) { 78 | methods.mouse.click(true); 79 | return true; 80 | } else { 81 | methods.mouse.click(false); 82 | return methods.menu.doAction(action, option); 83 | } 84 | } catch (Exception e) { 85 | e.printStackTrace(); 86 | return false; 87 | } 88 | } 89 | 90 | @Override 91 | public String toString() { 92 | return "Player[" + getName() + "]" + super.toString(); 93 | } 94 | 95 | } -------------------------------------------------------------------------------- /src/org/rsbot/event/impl/DrawObjects.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.event.impl; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.event.listeners.PaintListener; 5 | import org.rsbot.script.methods.MethodContext; 6 | import org.rsbot.script.wrappers.RSObject; 7 | import org.rsbot.script.wrappers.RSPlayer; 8 | import org.rsbot.script.wrappers.RSTile; 9 | 10 | import java.awt.*; 11 | import java.util.HashMap; 12 | 13 | public class DrawObjects implements PaintListener { 14 | 15 | private final MethodContext ctx; 16 | 17 | public DrawObjects(Bot bot) { 18 | ctx = bot.getMethodContext(); 19 | } 20 | 21 | private static final HashMap color_map = new HashMap(); 22 | 23 | static { 24 | color_map.put(RSObject.Type.BOUNDARY, Color.BLACK); 25 | color_map.put(RSObject.Type.FLOOR_DECORATION, Color.YELLOW); 26 | color_map.put(RSObject.Type.INTERACTABLE, Color.WHITE); 27 | color_map.put(RSObject.Type.WALL_DECORATION, Color.GRAY); 28 | } 29 | 30 | public void onRepaint(final Graphics render) { 31 | if (!ctx.game.isLoggedIn()) { 32 | return; 33 | } 34 | final RSPlayer player = ctx.players.getMyPlayer(); 35 | if (player == null) { 36 | return; 37 | } 38 | final FontMetrics metrics = render.getFontMetrics(); 39 | final RSTile location = player.getLocation(); 40 | final int locX = location.getX(); 41 | final int locY = location.getY(); 42 | final int tHeight = metrics.getHeight(); 43 | for (int x = locX - 25; x < locX + 25; x++) { 44 | for (int y = locY - 25; y < locY + 25; y++) { 45 | RSTile tile = new RSTile(x, y); 46 | final Point screen = ctx.calc.tileToScreen(tile); 47 | if (!ctx.calc.pointOnScreen(screen)) { 48 | continue; 49 | } 50 | final RSObject[] objects = ctx.objects.getAllAt(tile); 51 | int i = 0; 52 | for (RSObject object : objects) { 53 | Point real = ctx.calc.tileToScreen(object.getLocation()); 54 | if (!ctx.calc.pointOnScreen(real)) { 55 | continue; 56 | } 57 | if (screen.x > -1) { 58 | render.setColor(Color.GREEN); 59 | render.fillRect(screen.x - 1, screen.y - 1, 2, 2); 60 | render.setColor(Color.RED); 61 | render.drawLine(screen.x, screen.y, real.x, real.y); 62 | } 63 | final String s = "" + object.getID(); 64 | final int ty = real.y - tHeight / 2 - (i++) * 15; 65 | final int tx = real.x - metrics.stringWidth(s) / 2; 66 | render.setColor(color_map.get(object.getType())); 67 | render.drawString(s, tx, ty); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/org/rsbot/service/WebQueue.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.service; 2 | 3 | import org.rsbot.script.internal.wrappers.TileFlags; 4 | import org.rsbot.script.methods.Web; 5 | import org.rsbot.script.wrappers.RSTile; 6 | import org.rsbot.util.CacheWriter; 7 | import org.rsbot.util.GlobalConfiguration; 8 | 9 | import java.util.Collections; 10 | import java.util.HashMap; 11 | import java.util.Iterator; 12 | import java.util.Map; 13 | import java.util.logging.Logger; 14 | 15 | public class WebQueue { 16 | private static CacheWriter cacheWriter = null; 17 | private static final Logger log = Logger.getLogger("WebQueue"); 18 | public static boolean weAreBuffering = false; 19 | public static boolean speedBuffer = false; 20 | 21 | public static void Create() { 22 | if (cacheWriter == null) { 23 | cacheWriter = new CacheWriter(GlobalConfiguration.Paths.getWebCache()); 24 | } 25 | } 26 | 27 | public static void Add(final HashMap theFlagsList) { 28 | Web.map.putAll(theFlagsList); 29 | new Thread() { 30 | public void run() { 31 | try { 32 | String addedString = ""; 33 | final HashMap theFlagsList2 = new HashMap(); 34 | theFlagsList2.putAll(theFlagsList); 35 | final Map tl = Collections.unmodifiableMap(theFlagsList2); 36 | Iterator> tileFlagsIterator = tl.entrySet().iterator(); 37 | while (tileFlagsIterator.hasNext()) { 38 | TileFlags tileFlags = tileFlagsIterator.next().getValue(); 39 | if (tileFlags != null) { 40 | addedString += tileFlags.toString() + "\n"; 41 | try { 42 | weAreBuffering = true; 43 | if (!speedBuffer) { 44 | Thread.sleep(10); 45 | } 46 | } catch (InterruptedException ignored) { 47 | } 48 | } 49 | } 50 | cacheWriter.add(addedString); 51 | addedString = null; 52 | theFlagsList2.clear(); 53 | try { 54 | Thread.sleep(500);//Prevent data loss. 55 | } catch (InterruptedException ignored) { 56 | } 57 | weAreBuffering = false; 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | } 61 | } 62 | }.start(); 63 | } 64 | 65 | public static void Remove(final RSTile tile) { 66 | new Thread() { 67 | public void run() { 68 | cacheWriter.remove(tile.getX() + "," + tile.getY() + tile.getZ()); 69 | } 70 | }.start(); 71 | } 72 | 73 | public static boolean IsRunning() { 74 | return cacheWriter.IsRunning(); 75 | } 76 | 77 | public static void Destroy() { 78 | speedBuffer = true; 79 | cacheWriter.destroy(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/GEItemInfo.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | /** 4 | * Stores information about an item loaded from the Grand Exchange. 5 | * 6 | * @author Arbiter 7 | */ 8 | @Deprecated 9 | public class GEItemInfo { 10 | /** 11 | * The price change in 30 days. 12 | */ 13 | private final String change30; 14 | 15 | /** 16 | * The price change in 90 days. 17 | */ 18 | private final String change90; 19 | 20 | /** 21 | * The price change in 180 days. 22 | */ 23 | private final String change180; 24 | 25 | /** 26 | * Current market price. 27 | */ 28 | private final int marketPrice; 29 | 30 | /** 31 | * Maximum price. 32 | */ 33 | private final int maxPrice; 34 | 35 | /** 36 | * Minimum price. 37 | */ 38 | private final int minPrice; 39 | 40 | /** 41 | * Default constructor. 42 | * 43 | * @param id Item ID number 44 | * @param minPrice Current minimum price 45 | * @param maxPrice Current maximum price 46 | * @param marketPrice Current market price 47 | * @param change30 Change in the last thirty days 48 | * @param change90 Change in the last ninety days 49 | * @param change180 Change in the last 180 days 50 | */ 51 | public GEItemInfo(final int id, final int minPrice, final int maxPrice, final int marketPrice, final String change30, final String change90, final String change180) { 52 | this.minPrice = minPrice; 53 | this.maxPrice = maxPrice; 54 | this.marketPrice = marketPrice; 55 | this.change30 = change30; 56 | this.change90 = change90; 57 | this.change180 = change180; 58 | 59 | } 60 | 61 | /** 62 | * @return Price change in the last 30 days. 63 | */ 64 | public String getChange30Days() { 65 | return change30; 66 | } 67 | 68 | /** 69 | * @return Price change in the last 90 days. 70 | */ 71 | public String getChange90Days() { 72 | return change90; 73 | } 74 | 75 | /** 76 | * @return Price change in the last 180 days. 77 | */ 78 | public String getChange180Days() { 79 | return change180; 80 | } 81 | 82 | /** 83 | * @return Current market price. 84 | */ 85 | public int getMarketPrice() { 86 | return marketPrice; 87 | } 88 | 89 | /** 90 | * @return Current maximum price. 91 | */ 92 | public int getMaxPrice() { 93 | return maxPrice; 94 | } 95 | 96 | /** 97 | * @return Current minimum price 98 | */ 99 | public int getMinPrice() { 100 | return minPrice; 101 | } 102 | } -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSWebMap.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | /** 4 | * The web map data. 5 | * 6 | * @author Timer 7 | * @author Aut0r 8 | */ 9 | 10 | public class RSWebMap { 11 | /** 12 | * The tile array. 13 | */ 14 | private final RSWebTile[] tiles; 15 | 16 | public RSWebMap(final RSWebTile[] tiles) { 17 | this.tiles = tiles; 18 | } 19 | 20 | /** 21 | * Gets a web tile by index. 22 | * 23 | * @param index The index of the tile in the map. 24 | * @return The tile. 25 | */ 26 | public RSWebTile getWebTile(final int index) { 27 | try { 28 | return tiles[index]; 29 | } catch (Exception e) { 30 | return null; 31 | } 32 | } 33 | 34 | /** 35 | * Returns this maps tile array; 36 | * 37 | * @return The tile array. 38 | */ 39 | public RSWebTile[] getTiles() { 40 | return tiles; 41 | } 42 | 43 | /** 44 | * The nearest web tile. 45 | * 46 | * @param tile The web tile from a tile. 47 | * @return The resulting web tile. 48 | */ 49 | public RSWebTile getWebTile(final RSTile tile) { 50 | double maxDist = 999999.0; 51 | RSWebTile webTile = null; 52 | for (RSWebTile ctrl : tiles) { 53 | if (maxDist == 0.0) { 54 | break; 55 | } 56 | double sqrt = Math.sqrt((ctrl.getX() - tile.getX()) 57 | * (ctrl.getX() - tile.getX()) 58 | + (ctrl.getY() - tile.getY()) 59 | * (ctrl.getY() - tile.getY())); 60 | if (sqrt < maxDist) { 61 | webTile = ctrl; 62 | maxDist = sqrt; 63 | } 64 | } 65 | return webTile; 66 | } 67 | 68 | /** 69 | * Finds the heuristic. 70 | * 71 | * @param start The starting tile. 72 | * @param end The ending tile. 73 | * @return The heuristic. 74 | */ 75 | public double heuristic(RSWebTile start, RSWebTile end) { 76 | double dx = start.getX() - end.getX(); 77 | double dy = start.getY() - end.getY(); 78 | if (dx < 0) { 79 | dx = -dx; 80 | } 81 | if (dy < 0) { 82 | dy = -dy; 83 | } 84 | return dx < dy ? dy : dx; 85 | } 86 | 87 | /** 88 | * Gets the dist. 89 | * 90 | * @param start Starting web tile. 91 | * @param end Ending web tile. 92 | * @return The dist. 93 | */ 94 | public double dist(RSWebTile start, RSWebTile end) { 95 | if (start.getX() != end.getX() && start.getY() != end.getY()) { 96 | RSTile curr = start.tile(); 97 | RSTile dest = end.tile(); 98 | return Math.sqrt((curr.getX() - dest.getX()) 99 | * (curr.getX() - dest.getX()) 100 | + (curr.getY() - dest.getY()) 101 | * (curr.getY() - dest.getY())); 102 | } else { 103 | return 1.0; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSPath.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.script.methods.MethodContext; 4 | import org.rsbot.script.methods.MethodProvider; 5 | 6 | import java.util.EnumSet; 7 | 8 | /** 9 | * Represents a path to walk along in game. 10 | * 11 | * @author Jacmob 12 | */ 13 | public abstract class RSPath extends MethodProvider { 14 | 15 | /** 16 | * Defines the path traversal options. 17 | */ 18 | public static enum TraversalOption { 19 | HANDLE_RUN, SPACE_ACTIONS 20 | } 21 | 22 | public RSPath(MethodContext ctx) { 23 | super(ctx); 24 | } 25 | 26 | /** 27 | * Takes a step along this path if appropriate. 28 | * If the path cannot be traversed due to the player 29 | * being too far from its vertices or already at the 30 | * end vertex, false will be returned. In all 31 | * other cases, true will be returned, but 32 | * an action will not necessarily be performed (based 33 | * on the given options). 34 | * 35 | * @param options Walking style options. 36 | * @return true if this path is currently 37 | * valid for the player; otherwise false. 38 | */ 39 | public abstract boolean traverse(EnumSet options); 40 | 41 | /** 42 | * Takes a step along this path if appropriate. 43 | * Specifies only TraversalOption.SPACE_ACTIONS. 44 | * 45 | * @return true if this path is currently 46 | * valid for the player; otherwise false. 47 | * @see #traverse(EnumSet) 48 | */ 49 | public boolean traverse() { 50 | return traverse(EnumSet.of( 51 | TraversalOption.HANDLE_RUN, 52 | TraversalOption.SPACE_ACTIONS)); 53 | } 54 | 55 | /** 56 | * Checks whether or not this path can be traversed 57 | * by the player. This will be the case provided 58 | * that the player near to one of its vertices, but 59 | * not already standing on the end vertex. 60 | * 61 | * @return true if the player can walk 62 | * along this path; otherwise false. 63 | */ 64 | public abstract boolean isValid(); 65 | 66 | /** 67 | * Gets the next immediately available vertex 68 | * in this path. 69 | * 70 | * @return The next walkable RSTile. 71 | */ 72 | public abstract RSTile getNext(); 73 | 74 | /** 75 | * Gets the start tile of this path. 76 | * 77 | * @return The start RSTile. 78 | */ 79 | public abstract RSTile getStart(); 80 | 81 | /** 82 | * Gets the end tile of this path. 83 | * 84 | * @return The end RSTile. 85 | */ 86 | public abstract RSTile getEnd(); 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/asm/ClassAdapter.java: -------------------------------------------------------------------------------- 1 | /*** 2 | * ASM: a very small and fast Java bytecode manipulation framework 3 | * Copyright (c) 2000-2007 INRIA, France Telecom 4 | * All rights reserved. 5 | */ 6 | package org.rsbot.loader.asm; 7 | 8 | 9 | /** 10 | * An empty {@link ClassVisitor} that delegates to another {@link ClassVisitor}. 11 | * This class can be used as a super class to quickly implement usefull class 12 | * adapter classes, just by overriding the necessary methods. 13 | * 14 | * @author Eric Bruneton 15 | */ 16 | public class ClassAdapter implements ClassVisitor { 17 | 18 | /** 19 | * The {@link ClassVisitor} to which this adapter delegates calls. 20 | */ 21 | protected ClassVisitor cv; 22 | 23 | /** 24 | * Constructs a new {@link ClassAdapter} object. 25 | * 26 | * @param cv the class visitor to which this adapter must delegate calls. 27 | */ 28 | public ClassAdapter(final ClassVisitor cv) { 29 | this.cv = cv; 30 | } 31 | 32 | public void visit( 33 | final int version, 34 | final int access, 35 | final String name, 36 | final String signature, 37 | final String superName, 38 | final String[] interfaces) { 39 | cv.visit(version, access, name, signature, superName, interfaces); 40 | } 41 | 42 | public void visitSource(final String source, final String debug) { 43 | cv.visitSource(source, debug); 44 | } 45 | 46 | public void visitOuterClass( 47 | final String owner, 48 | final String name, 49 | final String desc) { 50 | cv.visitOuterClass(owner, name, desc); 51 | } 52 | 53 | public AnnotationVisitor visitAnnotation( 54 | final String desc, 55 | final boolean visible) { 56 | return cv.visitAnnotation(desc, visible); 57 | } 58 | 59 | public void visitAttribute(final Attribute attr) { 60 | cv.visitAttribute(attr); 61 | } 62 | 63 | public void visitInnerClass( 64 | final String name, 65 | final String outerName, 66 | final String innerName, 67 | final int access) { 68 | cv.visitInnerClass(name, outerName, innerName, access); 69 | } 70 | 71 | public FieldVisitor visitField( 72 | final int access, 73 | final String name, 74 | final String desc, 75 | final String signature, 76 | final Object value) { 77 | return cv.visitField(access, name, desc, signature, value); 78 | } 79 | 80 | public MethodVisitor visitMethod( 81 | final int access, 82 | final String name, 83 | final String desc, 84 | final String signature, 85 | final String[] exceptions) { 86 | return cv.visitMethod(access, name, desc, signature, exceptions); 87 | } 88 | 89 | public void visitEnd() { 90 | cv.visitEnd(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSGroundItem.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.client.RSGroundEntity; 4 | import org.rsbot.client.RSGroundObject; 5 | import org.rsbot.script.methods.MethodContext; 6 | import org.rsbot.script.methods.MethodProvider; 7 | 8 | /** 9 | * Represents an item on a tile. 10 | * 11 | * @author Jacmob 12 | */ 13 | public class RSGroundItem extends MethodProvider { 14 | 15 | private final RSItem groundItem; 16 | private final RSTile location; 17 | 18 | public RSGroundItem(final MethodContext ctx, final RSTile location, final RSItem groundItem) { 19 | super(ctx); 20 | this.location = location; 21 | this.groundItem = groundItem; 22 | } 23 | 24 | /** 25 | * Gets the top model on the tile of this ground item. 26 | * 27 | * @return The top model on the tile of this ground item. 28 | */ 29 | public RSModel getModel() { 30 | int x = location.getX() - methods.game.getBaseX(); 31 | int y = location.getY() - methods.game.getBaseY(); 32 | int plane = methods.client.getPlane(); 33 | org.rsbot.client.RSGround rsGround = methods.client.getRSGroundArray()[plane][x][y]; 34 | 35 | if (rsGround != null) { 36 | RSGroundEntity obj = rsGround.getGroundObject(); 37 | if (obj != null) { 38 | org.rsbot.client.Model model = ((RSGroundObject) rsGround.getGroundObject()).getModel(); 39 | if (model != null) { 40 | return new RSAnimableModel(methods, model, obj); 41 | } 42 | } 43 | } 44 | return null; 45 | } 46 | 47 | /** 48 | * Performs the given action on this RSGroundItem. 49 | * 50 | * @param action The menu action to click. 51 | * @return true if the action was clicked; otherwise false. 52 | */ 53 | public boolean doAction(final String action) { 54 | return doAction(action, null); 55 | } 56 | 57 | /** 58 | * Performs the given action on this RSGroundItem. 59 | * 60 | * @param action The menu action to click. 61 | * @param option The option of the menu action to click. 62 | * @return true if the action was clicked; otherwise false. 63 | */ 64 | public boolean doAction(final String action, final String option) { 65 | RSModel model = getModel(); 66 | if (model != null) { 67 | return model.doAction(action, option); 68 | } 69 | return methods.tiles.doAction(getLocation(), random(0.45, 0.55), random(0.45, 0.55), 0, 70 | action, option); 71 | } 72 | 73 | public RSItem getItem() { 74 | return groundItem; 75 | } 76 | 77 | public RSTile getLocation() { 78 | return location; 79 | } 80 | 81 | public boolean isOnScreen() { 82 | RSModel model = getModel(); 83 | if (model == null) { 84 | return methods.calc.tileOnScreen(location); 85 | } else { 86 | return methods.calc.pointOnScreen(model.getPoint()); 87 | } 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/org/rsbot/util/IniParser.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.BufferedWriter; 5 | import java.io.IOException; 6 | import java.util.HashMap; 7 | import java.util.Map.Entry; 8 | 9 | /** 10 | * @author Paris 11 | */ 12 | public class IniParser { 13 | 14 | private static final char sectionOpen = '['; 15 | private static final char sectionClose = ']'; 16 | private static final char keyBound = '='; 17 | private static final char[] comments = {'#', ';'}; 18 | public static final String emptySection = ""; 19 | 20 | private IniParser() { 21 | } 22 | 23 | public static void serialise(HashMap> data, BufferedWriter out) throws IOException { 24 | if (data.containsKey(emptySection)) { 25 | writeSection(emptySection, data.get(emptySection), out); 26 | out.newLine(); 27 | } 28 | for (Entry> entry : data.entrySet()) { 29 | String section = entry.getKey(); 30 | if (section.equals(emptySection)) { 31 | continue; 32 | } 33 | writeSection(section, entry.getValue(), out); 34 | out.newLine(); 35 | } 36 | } 37 | 38 | private static void writeSection(String section, HashMap map, BufferedWriter out) throws IOException { 39 | if (!(section == null || section.isEmpty())) { 40 | out.write(sectionOpen); 41 | out.write(section); 42 | out.write(sectionClose); 43 | out.newLine(); 44 | } 45 | for (Entry entry : map.entrySet()) { 46 | out.write(entry.getKey()); 47 | out.write(keyBound); 48 | out.write(entry.getValue()); 49 | out.newLine(); 50 | } 51 | } 52 | 53 | public static HashMap> deserialise(BufferedReader input) throws IOException { 54 | HashMap> data = new HashMap>(); 55 | String line, section = emptySection; 56 | 57 | while ((line = input.readLine()) != null) { 58 | line = line.trim(); 59 | if (line.isEmpty()) { 60 | continue; 61 | } 62 | int z, l = line.length(); 63 | char t = line.charAt(0); 64 | if (t == sectionOpen) { 65 | z = line.indexOf(sectionClose, 1); 66 | z = z == -1 ? l : z; 67 | section = z == 1 ? "" : line.substring(1, z - 1).trim(); 68 | } else { 69 | boolean skip = false; 70 | for (char c : comments) { 71 | if (t == c) { 72 | skip = true; 73 | break; 74 | } 75 | } 76 | if (skip) { 77 | continue; 78 | } 79 | z = line.indexOf(keyBound); 80 | z = z == -1 ? l : z; 81 | String key, value = ""; 82 | key = line.substring(0, z).trim(); 83 | if (++z < l) { 84 | value = line.substring(z).trim(); 85 | } 86 | if (!data.containsKey(section)) { 87 | data.put(section, new HashMap()); 88 | } 89 | data.get(section).put(key, value); 90 | } 91 | } 92 | 93 | return data; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/org/rsbot/script/randoms/Pinball.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.randoms; 2 | 3 | import org.rsbot.script.Random; 4 | import org.rsbot.script.ScriptManifest; 5 | import org.rsbot.script.wrappers.RSComponent; 6 | import org.rsbot.script.wrappers.RSModel; 7 | import org.rsbot.script.wrappers.RSObject; 8 | 9 | import java.awt.*; 10 | 11 | 12 | @ScriptManifest(authors = {"Iscream", "Aelin", "LM3", "IceCandle", "Taha"}, name = "Pinball", version = 2.7) 13 | public class Pinball extends Random { 14 | 15 | private static final int[] OBJ_PILLARS = {15000, 15002, 15004, 15006, 15008}; 16 | 17 | private static final int[] OBJ_ACTIVATE = {15000, 15002, 15004, 15006, 15007, 15008}; 18 | 19 | private static final int INTERFACE_PINBALL = 263; 20 | 21 | public boolean activateCondition() { 22 | return game.isLoggedIn() && objects.getNearest(OBJ_ACTIVATE) != null; 23 | } 24 | 25 | private int getScore() { 26 | RSComponent score = interfaces.get(INTERFACE_PINBALL).getComponent(1); 27 | try { 28 | return Integer.parseInt(score.getText().split(" ")[1]); 29 | } catch (java.lang.ArrayIndexOutOfBoundsException t) { 30 | return 10; 31 | } 32 | } 33 | 34 | public int loop() { 35 | if (!activateCondition()) { 36 | return -1; 37 | } 38 | if (getMyPlayer().isMoving() || getMyPlayer().getAnimation() != -1) { 39 | return random(300, 500); 40 | } 41 | if (getScore() >= 10) { 42 | int OBJ_EXIT = 15010; 43 | RSObject exit = objects.getNearest(OBJ_EXIT); 44 | if (exit != null) { 45 | if (calc.tileOnScreen(exit.getLocation()) && exit.doAction("Exit")) { 46 | sleep(random(2000, 2200)); 47 | exit.doAction("Exit"); 48 | return random(2000, 2100); 49 | } else { 50 | camera.setCompass('s'); 51 | walking.walkTileOnScreen(exit.getLocation()); 52 | return random(1400, 1500); 53 | } 54 | 55 | } 56 | } 57 | RSObject pillar = objects.getNearest(OBJ_PILLARS); 58 | if (pillar != null) { 59 | if (calc.distanceTo(pillar) > 2 && !pillar.isOnScreen()) { 60 | walking.walkTileOnScreen(pillar.getLocation()); 61 | return random(500, 600); 62 | } 63 | if (pillar != null) { 64 | doClick(pillar); 65 | } 66 | int before = getScore(); 67 | for (int i = 0; i < 50; i++) { 68 | if (getScore() > before) { 69 | return random(50, 100); 70 | } 71 | sleep(100, 200); 72 | } 73 | } 74 | return random(50, 100); 75 | } 76 | 77 | private void doClick(RSObject pillar) { 78 | RSModel model = pillar.getModel(); 79 | if (model != null) { 80 | Point central = model.getCentralPoint(); 81 | mouse.click(central.x, central.y, 4, 4, true); 82 | return; 83 | } else { 84 | Point p = calc.tileToScreen(pillar.getLocation()); 85 | if (calc.pointOnScreen(p)) { 86 | mouse.click(p.x, p.y, 4, 20, true); 87 | } 88 | return; 89 | } 90 | } 91 | 92 | 93 | } -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/wrappers/TileFlags.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal.wrappers; 2 | 3 | import org.rsbot.script.wrappers.RSTile; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | 9 | public class TileFlags { 10 | public static interface Keys { 11 | static final int TILE_CLEAR = 0; 12 | static final int TILE_WATER = 1280; 13 | static final int WALL_NORTH_WEST = 1; 14 | static final int WALL_NORTH = 2; 15 | static final int WALL_NORTH_EAST = 4; 16 | static final int WALL_EAST = 8; 17 | static final int WALL_SOUTH_EAST = 10; 18 | static final int WALL_SOUTH = 20; 19 | static final int WALL_SOUTH_WEST = 40; 20 | static final int WALL_WEST = 80; 21 | static final int BLOCKED = 100; 22 | } 23 | 24 | public static interface Flags { 25 | public static final int WALL_NORTH_WEST = 0x1; 26 | public static final int WALL_NORTH = 0x2; 27 | public static final int WALL_NORTH_EAST = 0x4; 28 | public static final int WALL_EAST = 0x8; 29 | public static final int WALL_SOUTH_EAST = 0x10; 30 | public static final int WALL_SOUTH = 0x20; 31 | public static final int WALL_SOUTH_WEST = 0x40; 32 | public static final int WALL_WEST = 0x80; 33 | public static final int BLOCKED = 0x100; 34 | public static final int WATER = 0x1280100; 35 | } 36 | 37 | private RSTile tile; 38 | private List keys = new ArrayList(); 39 | 40 | public TileFlags(RSTile tile) { 41 | this.tile = tile; 42 | } 43 | 44 | public RSTile getTile() { 45 | return tile; 46 | } 47 | 48 | public boolean isQuestionable() { 49 | return keys.size() > 0 && !keys.contains(Keys.TILE_CLEAR); 50 | } 51 | 52 | public boolean isWalkable() { 53 | return !keys.contains(Keys.TILE_WATER) && !keys.contains(Keys.BLOCKED); 54 | } 55 | 56 | public boolean isWater() { 57 | return keys.contains(Keys.TILE_WATER); 58 | } 59 | 60 | public void addKey(final int key) { 61 | keys.add(key); 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | String flags = ""; 67 | Iterator keysIterator = keys.listIterator(); 68 | while (keysIterator.hasNext()) { 69 | int flag = keysIterator.next(); 70 | flags += flag + "="; 71 | } 72 | return tile.getX() + "," + tile.getY() + "," + tile.getZ() + "tile=data" + flags; 73 | } 74 | 75 | @Override 76 | public boolean equals(Object o) { 77 | if (o instanceof TileFlags) { 78 | TileFlags tileFlags = (TileFlags) o; 79 | return getTile().equals(tileFlags.getTile()) && flagsEqual(tileFlags, this); 80 | } 81 | return false; 82 | } 83 | 84 | private static final boolean flagsEqual(final TileFlags c, final TileFlags v) { 85 | if (c.keys.size() == v.keys.size()) { 86 | Iterator keysIterator = c.keys.listIterator(); 87 | while (keysIterator.hasNext()) { 88 | int flag = keysIterator.next(); 89 | if (!v.keys.contains(flag)) { 90 | return false; 91 | } 92 | } 93 | return true; 94 | } 95 | return false; 96 | } 97 | } -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSNPC.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.script.methods.MethodContext; 4 | 5 | import java.lang.ref.SoftReference; 6 | 7 | /** 8 | * Represents a non-player character. 9 | */ 10 | public class RSNPC extends RSCharacter { 11 | 12 | private final SoftReference npc; 13 | 14 | public RSNPC(final MethodContext ctx, final org.rsbot.client.RSNPC npc) { 15 | super(ctx); 16 | this.npc = new SoftReference(npc); 17 | } 18 | 19 | @Override 20 | protected org.rsbot.client.RSCharacter getAccessor() { 21 | return npc.get(); 22 | } 23 | 24 | public String[] getActions() { 25 | org.rsbot.client.RSNPCDef def = getDefInternal(); 26 | if (def != null) { 27 | return def.getActions(); 28 | } 29 | return new String[0]; 30 | } 31 | 32 | public int getID() { 33 | org.rsbot.client.RSNPCDef def = getDefInternal(); 34 | if (def != null) { 35 | return def.getType(); 36 | } 37 | return -1; 38 | } 39 | 40 | @Override 41 | public String getName() { 42 | org.rsbot.client.RSNPCDef def = getDefInternal(); 43 | if (def != null) { 44 | return def.getName(); 45 | } 46 | return ""; 47 | } 48 | 49 | @Override 50 | public int getLevel() { 51 | org.rsbot.client.RSNPC c = npc.get(); 52 | if (c == null) { 53 | return -1; 54 | } else { 55 | return c.getLevel(); 56 | } 57 | } 58 | 59 | /** 60 | * @return true if RSNPC is interacting with RSPlayer; otherwise 61 | * false. 62 | */ 63 | @Override 64 | public boolean isInteractingWithLocalPlayer() { 65 | RSNPC npc = methods.npcs.getNearest(getID()); 66 | return npc.getInteracting() != null && npc.getInteracting().equals( 67 | methods.players.getMyPlayer()); 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | StringBuilder sb = new StringBuilder(); 73 | for (final String act : getActions()) { 74 | sb.append(act); 75 | sb.append(","); 76 | } 77 | if (sb.length() > 0) { 78 | sb.setLength(sb.length() - 1); 79 | } 80 | return "NPC[" + getName() + "],actions=[" + sb.toString() + "]" 81 | + super.toString(); 82 | } 83 | 84 | org.rsbot.client.RSNPCDef getDefInternal() { 85 | org.rsbot.client.RSNPC c = npc.get(); 86 | if (c == null) { 87 | return null; 88 | } else { 89 | return c.getRSNPCDef(); 90 | } 91 | } 92 | 93 | /** 94 | * Turns towards the RSNPC. 95 | * @author LastCoder 96 | * @return true - If RSNPC is on screen after attempting to move camera angle. 97 | */ 98 | public boolean turnTo() { 99 | final RSNPC n = methods.npcs.getNearest(getID()); 100 | if(n != null) { 101 | if(!n.isOnScreen()) { 102 | methods.camera.turnTo(n); 103 | return n.isOnScreen(); 104 | } 105 | } 106 | return false; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /src/org/rsbot/loader/asm/AnnotationVisitor.java: -------------------------------------------------------------------------------- 1 | /*** 2 | * ASM: a very small and fast Java bytecode manipulation framework 3 | * Copyright (c) 2000-2007 INRIA, France Telecom 4 | * All rights reserved. 5 | */ 6 | package org.rsbot.loader.asm; 7 | 8 | /** 9 | * A visitor to visit a Java annotation. The methods of this interface must be 10 | * called in the following order: (visit | visitEnum | 11 | * visitAnnotation | visitArray)* visitEnd. 12 | * 13 | * @author Eric Bruneton 14 | * @author Eugene Kuleshov 15 | */ 16 | public interface AnnotationVisitor { 17 | 18 | /** 19 | * Visits a primitive value of the annotation. 20 | * 21 | * @param name the value name. 22 | * @param value the actual value, whose type must be {@link Byte}, 23 | * {@link Boolean}, {@link Character}, {@link Short}, 24 | * {@link Integer}, {@link Long}, {@link Float}, {@link Double}, 25 | * {@link String} or {@link Type}. This value can also be an array 26 | * of byte, boolean, short, char, int, long, float or double values 27 | * (this is equivalent to using {@link #visitArray visitArray} and 28 | * visiting each array element in turn, but is more convenient). 29 | */ 30 | void visit(String name, Object value); 31 | 32 | /** 33 | * Visits an enumeration value of the annotation. 34 | * 35 | * @param name the value name. 36 | * @param desc the class descriptor of the enumeration class. 37 | * @param value the actual enumeration value. 38 | */ 39 | void visitEnum(String name, String desc, String value); 40 | 41 | /** 42 | * Visits a nested annotation value of the annotation. 43 | * 44 | * @param name the value name. 45 | * @param desc the class descriptor of the nested annotation class. 46 | * @return a visitor to visit the actual nested annotation value, or 47 | * null if this visitor is not interested in visiting 48 | * this nested annotation. The nested annotation value must be 49 | * fully visited before calling other methods on this annotation 50 | * visitor. 51 | */ 52 | AnnotationVisitor visitAnnotation(String name, String desc); 53 | 54 | /** 55 | * Visits an array value of the annotation. Note that arrays of primitive 56 | * types (such as byte, boolean, short, char, int, long, float or double) 57 | * can be passed as value to {@link #visit visit}. This is what 58 | * {@link ClassReader} does. 59 | * 60 | * @param name the value name. 61 | * @return a visitor to visit the actual array value elements, or 62 | * null if this visitor is not interested in visiting 63 | * these values. The 'name' parameters passed to the methods of this 64 | * visitor are ignored. All the array values must be visited 65 | * before calling other methods on this annotation visitor. 66 | */ 67 | AnnotationVisitor visitArray(String name); 68 | 69 | /** 70 | * Visits the end of the annotation. 71 | */ 72 | void visitEnd(); 73 | } 74 | -------------------------------------------------------------------------------- /src/org/rsbot/script/wrappers/RSWebPath.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.wrappers; 2 | 3 | import org.rsbot.script.methods.MethodContext; 4 | 5 | import java.util.EnumSet; 6 | import java.util.logging.Logger; 7 | 8 | /** 9 | * A wrapper for traversing on a web path. 10 | * 11 | * @author Timer 12 | * @author Aut0r 13 | */ 14 | 15 | public class RSWebPath extends RSWebSkeleton { 16 | /** 17 | * The web tile array. 18 | */ 19 | private final RSWebTile[] web; 20 | 21 | private final Logger log = Logger.getLogger(RSWebPath.class.getName()); 22 | 23 | public RSWebPath(final MethodContext ctx, final RSWebTile[] tiles) { 24 | super(ctx); 25 | this.web = tiles; 26 | } 27 | 28 | /** 29 | * Traverses on the path. 30 | * 31 | * @param options The flags to take into account while traversing the path. 32 | * @return True if walked, otherwise false. 33 | */ 34 | public boolean traverse(EnumSet options) { 35 | if (options.contains( 36 | TraversalOption.HANDLE_RUN) && !methods.walking.isRunEnabled() && methods.walking.getEnergy() > 40) { 37 | methods.walking.setRun(true); 38 | sleep(random(500, 800)); 39 | } 40 | if (options.contains( 41 | TraversalOption.SPACE_ACTIONS) && methods.walking.getDestination() != null && methods.calc.distanceTo( 42 | methods.walking.getDestination()) > random(2, 8)) { 43 | return true; 44 | } 45 | int nextTileIndex = getNextIndex(); 46 | if (nextTileIndex != -1) { 47 | if (nextTileIndex < web.length - 1 && methods.walking.isLocal(web[nextTileIndex + 1])) { 48 | nextTileIndex++; 49 | } 50 | RSLocalPath path = new RSLocalPath(methods, web[nextTileIndex]); 51 | path.random(2, 2); 52 | return path.traverse(null); 53 | } else { 54 | log.severe("No next tile!"); 55 | } 56 | return false; 57 | } 58 | 59 | /** 60 | * Gets the tiles of the web skeleton. 61 | * 62 | * @return The tiles in a RSTile[]. 63 | */ 64 | public RSTile[] getTiles() { 65 | return web; 66 | } 67 | 68 | /** 69 | * Get next tile index off screen. 70 | * 71 | * @return The next tile in the skeleton. 72 | */ 73 | public int getNextIndex() { 74 | for (int i = web.length - 1; i > -1; i--) { 75 | if (methods.calc.tileOnMap(web[i])) { 76 | return i; 77 | } 78 | } 79 | return -1; 80 | } 81 | 82 | /** 83 | * Gets the next start tile. 84 | * 85 | * @return The start tile. 86 | */ 87 | public RSTile getStart() { 88 | return web != null && web.length > 0 ? web[0] : null; 89 | } 90 | 91 | /** 92 | * The end tile. 93 | * 94 | * @return The end tile. 95 | */ 96 | public RSTile getEnd() { 97 | return web != null && web.length > 0 ? web[web.length - 1] : null; 98 | } 99 | 100 | /** 101 | * Returns if you're at your destination. 102 | * 103 | * @return true if at destination, otherwise false. 104 | */ 105 | public boolean atDestination() { 106 | return getEnd() != null ? methods.calc.distanceTo(getEnd()) < 8 : false; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/org/rsbot/script/internal/PassiveScriptHandler.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.internal; 2 | 3 | import org.rsbot.bot.Bot; 4 | import org.rsbot.script.PassiveScript; 5 | import org.rsbot.script.PassiveScriptManifest; 6 | import org.rsbot.script.internal.event.PassiveScriptListener; 7 | 8 | import java.util.*; 9 | 10 | public class PassiveScriptHandler { 11 | private final HashMap scripts = new HashMap(); 12 | private final HashMap scriptThreads = new HashMap(); 13 | 14 | private final Set listeners = Collections.synchronizedSet(new HashSet()); 15 | 16 | private final Bot bot; 17 | 18 | public PassiveScriptHandler(Bot bot) { 19 | this.bot = bot; 20 | } 21 | 22 | public void addScriptListener(PassiveScriptListener l) { 23 | listeners.add(l); 24 | } 25 | 26 | public void removeScriptListener(PassiveScriptListener l) { 27 | listeners.remove(l); 28 | } 29 | 30 | private void addScriptToPool(PassiveScript ss, Thread t) { 31 | for (int off = 0; off < scripts.size(); ++off) { 32 | if (!scripts.containsKey(off)) { 33 | scripts.put(off, ss); 34 | ss.setID(off); 35 | scriptThreads.put(off, t); 36 | return; 37 | } 38 | } 39 | ss.setID(scripts.size()); 40 | scripts.put(scripts.size(), ss); 41 | scriptThreads.put(scriptThreads.size(), t); 42 | } 43 | 44 | public Bot getBot() { 45 | return bot; 46 | } 47 | 48 | public Map getRunningScripts() { 49 | return Collections.unmodifiableMap(scripts); 50 | } 51 | 52 | public void stopScript(int id) { 53 | PassiveScript script = scripts.get(id); 54 | if (script != null) { 55 | script.deactivate(id); 56 | scripts.remove(id); 57 | scriptThreads.remove(id); 58 | for (PassiveScriptListener l : listeners) { 59 | l.scriptStopped(this, script); 60 | } 61 | } 62 | } 63 | 64 | public void runScript(PassiveScript script) { 65 | script.init(bot.getMethodContext()); 66 | for (PassiveScriptListener l : listeners) { 67 | l.scriptStarted(this, script); 68 | } 69 | PassiveScriptManifest prop = script.getClass().getAnnotation(PassiveScriptManifest.class); 70 | Thread t = new Thread(script, "PassiveScript-" + prop.name()); 71 | addScriptToPool(script, t); 72 | t.start(); 73 | } 74 | 75 | public void stopAllScripts() { 76 | Set theSet = scripts.keySet(); 77 | int[] arr = new int[theSet.size()]; 78 | int c = 0; 79 | for (int i : theSet) { 80 | arr[c] = i; 81 | c++; 82 | } 83 | for (int id : arr) { 84 | stopScript(id); 85 | } 86 | } 87 | 88 | public void stopScript() { 89 | Thread curThread = Thread.currentThread(); 90 | for (int i = 0; i < scripts.size(); i++) { 91 | PassiveScript script = scripts.get(i); 92 | if (script != null && script.isRunning()) { 93 | if (scriptThreads.get(i) == curThread) { 94 | stopScript(i); 95 | } 96 | } 97 | } 98 | if (curThread == null) { 99 | throw new ThreadDeath(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/org/rsbot/script/methods/MethodProvider.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.methods; 2 | 3 | /** 4 | * A class that provides methods that use data from the game client. For 5 | * internal use. 6 | * 7 | * @author Jacmob 8 | */ 9 | public abstract class MethodProvider { 10 | 11 | protected final MethodContext methods; 12 | 13 | public MethodProvider(MethodContext ctx) { 14 | this.methods = ctx; 15 | } 16 | 17 | /** 18 | * Returns a linearly distributed pseudorandom integer. 19 | * 20 | * @param min The inclusive lower bound. 21 | * @param max The exclusive upper bound. 22 | * @return Random integer min <= n < max. 23 | */ 24 | public int random(int min, int max) { 25 | return min + (max == min ? 0 : methods.random.nextInt(max - min)); 26 | } 27 | 28 | /** 29 | * Returns a normally distributed pseudorandom integer about a mean centered 30 | * between min and max with a provided standard deviation. 31 | * 32 | * @param min The inclusive lower bound. 33 | * @param max The exclusive upper bound. 34 | * @param sd The standard deviation. A higher value will increase the 35 | * probability of numbers further from the mean being returned. 36 | * @return Random integer min <= n < max from the normal distribution 37 | * described by the parameters. 38 | */ 39 | public int random(int min, int max, int sd) { 40 | int mean = min + (max - min) / 2; 41 | int rand; 42 | do { 43 | rand = (int) (methods.random.nextGaussian() * sd + mean); 44 | } while (rand < min || rand >= max); 45 | return rand; 46 | } 47 | 48 | /** 49 | * Returns a normally distributed pseudorandom integer with a provided 50 | * standard deviation about a provided mean. 51 | * 52 | * @param min The inclusive lower bound. 53 | * @param max The exclusive upper bound. 54 | * @param mean The mean (>= min and < max). 55 | * @param sd The standard deviation. A higher value will increase the 56 | * probability of numbers further from the mean being returned. 57 | * @return Random integer min <= n < max from the normal distribution 58 | * described by the parameters. 59 | */ 60 | public int random(int min, int max, int mean, int sd) { 61 | int rand; 62 | do { 63 | rand = (int) (methods.random.nextGaussian() * sd + mean); 64 | } while (rand < min || rand >= max); 65 | return rand; 66 | } 67 | 68 | /** 69 | * Returns a linearly distributed pseudorandom double. 70 | * 71 | * @param min The inclusive lower bound. 72 | * @param max The exclusive upper bound. 73 | * @return Random min <= n < max. 74 | */ 75 | public double random(double min, double max) { 76 | return min + methods.random.nextDouble() * (max - min); 77 | } 78 | 79 | /** 80 | * @param toSleep The time to sleep in milliseconds. 81 | */ 82 | public void sleep(int toSleep) { 83 | try { 84 | long start = System.currentTimeMillis(); 85 | Thread.sleep(toSleep); 86 | long now; // Guarantee minimum sleep 87 | while (start + toSleep > (now = System.currentTimeMillis())) { 88 | Thread.sleep(start + toSleep - now); 89 | } 90 | } catch (InterruptedException ignored) { 91 | } 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/org/rsbot/client/Client.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.client; 2 | 3 | import org.rsbot.client.input.Keyboard; 4 | import org.rsbot.client.input.Mouse; 5 | 6 | import java.awt.*; 7 | 8 | public interface Client { 9 | 10 | ChatLine[] getChatLines(); 11 | 12 | boolean isMenuCollapsed(); 13 | 14 | NodeDeque getMenuItems(); 15 | 16 | NodeSubQueue getCollapsedMenuItems(); 17 | 18 | int getBaseX(); 19 | 20 | int getBaseY(); 21 | 22 | Callback getCallBack(); 23 | 24 | Canvas getCanvas(); 25 | 26 | int getCameraPitch(); 27 | 28 | int getCameraYaw(); 29 | 30 | int getCamPosX(); 31 | 32 | int getCamPosY(); 33 | 34 | int getCamPosZ(); 35 | 36 | String getCurrentPassword(); 37 | 38 | String getCurrentUsername(); 39 | 40 | int getDestX(); 41 | 42 | int getDestY(); 43 | 44 | DetailInfoNode getDetailInfoNode(); 45 | 46 | byte[][][] getGroundByteArray(); 47 | 48 | int getGUIRSInterfaceIndex(); 49 | 50 | int getIdleTime(); 51 | 52 | Keyboard getKeyboard(); 53 | 54 | int getLoginIndex(); 55 | 56 | int getLoopCycle(); 57 | 58 | int getMenuOptionsCount(); 59 | 60 | int getMenuX(); 61 | 62 | int getMenuY(); 63 | 64 | MenuGroupNode getCurrentMenuGroupNode(); 65 | 66 | int getSubMenuX(); 67 | 68 | int getSubMenuY(); 69 | 70 | int getSubMenuWidth(); 71 | 72 | int getMinimapAngle(); 73 | 74 | float getMinimapOffset(); 75 | 76 | int getMinimapScale(); 77 | 78 | int getMinimapSetting(); 79 | 80 | Mouse getMouse(); 81 | 82 | //MouseWheel getMouseWheel(); 83 | 84 | RSPlayer getMyRSPlayer(); 85 | 86 | int getPlane(); 87 | 88 | int getPublicChatMode(); 89 | 90 | RSGround[][][] getRSGroundArray(); 91 | 92 | RSGroundData[] getRSGroundDataArray(); 93 | 94 | StatusNodeList getRSInteractingDefList(); 95 | 96 | Rectangle[] getRSInterfaceBoundsArray(); 97 | 98 | RSInterface[][] getRSInterfaceCache(); 99 | 100 | HashTable getRSInterfaceNC(); 101 | 102 | HashTable getRSItemHashTable(); 103 | 104 | HashTable getRSNPCNC(); 105 | 106 | int getRSNPCCount(); 107 | 108 | int[] getRSNPCIndexArray(); 109 | 110 | RSPlayer[] getRSPlayerArray(); 111 | 112 | int getRSPlayerCount(); 113 | 114 | int[] getRSPlayerIndexArray(); 115 | 116 | String getSelectedItemName(); 117 | 118 | int getSelfInteracting(); 119 | 120 | Settings getSettingArray(); 121 | 122 | Signlink getSignLink(); 123 | 124 | int[] getSkillExperiences(); 125 | 126 | int[] getSkillExperiencesMax(); 127 | 128 | int[] getSkillLevelMaxes(); 129 | 130 | int[] getSkillLevels(); 131 | 132 | TileData[] getTileData(); 133 | 134 | boolean[] getValidRSInterfaceArray(); 135 | 136 | boolean isFlagged(); 137 | 138 | int isItemSelected(); 139 | 140 | boolean isMenuOpen(); 141 | 142 | boolean isSpellSelected(); 143 | 144 | RSItemDefLoader getRSItemDefLoader(); 145 | 146 | RSObjectDefLoader getRSObjectDefLoader(); 147 | 148 | StatusNodeListLoader getRSInteractableDefListLoader(); 149 | 150 | Signlink getSignlink(); 151 | 152 | ServerData getWorldData(); 153 | 154 | void setCallback(Callback cb); 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/org/rsbot/script/randoms/CloseAllInterface.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.randoms; 2 | 3 | import org.rsbot.script.Random; 4 | import org.rsbot.script.ScriptManifest; 5 | import org.rsbot.script.wrappers.RSComponent; 6 | 7 | import java.util.LinkedList; 8 | import java.util.List; 9 | 10 | 11 | /** 12 | * Closes interfaces that scripts may open by mistake. 13 | */ 14 | @ScriptManifest(authors = {"Jacmob", "HeyyamaN", "Pervy Shuya"}, name = "InterfaceCloser", version = 1.9) 15 | public class CloseAllInterface extends Random { 16 | 17 | static class ComponentDef { 18 | 19 | final int parent; 20 | final int child; 21 | final boolean text; 22 | 23 | public ComponentDef(int parent, int child, boolean text) { 24 | this.parent = parent; 25 | this.child = child; 26 | this.text = text; 27 | } 28 | 29 | } 30 | 31 | private final List components = new LinkedList(); 32 | 33 | { 34 | addChild(743, 20); // Audio 35 | addChild(767, 10); // Bank help 36 | addChild(499, 29); // Stats 37 | addChild(594, 48); // Report 38 | addChild(275, 8); // Quest 39 | addChild(206, 13); // Price check 40 | addChild(266, 1); // Tombstone 41 | addChild(266, 11); // Grove 42 | addChild(102, 13); // Death items 43 | addChild(14, 88, true); // New pin 44 | addChild(14, 11); // Pin settings 45 | addChild(157, 13); // Quick chat help 46 | addChild(764, 2); // Objectives 47 | addChild(895, 19); // Advisor 48 | addChild(109, 14); // Grand exchange collection 49 | addChild(667, 74); // Equipment Bonus 50 | addChild(742, 14); // Graphic 51 | addChild(917, 69); // Task List 52 | addChild(1107, 174); // Clan Vexillum 53 | } 54 | 55 | private void addChild(int parent, int idx) { 56 | components.add(new ComponentDef(parent, idx, false)); 57 | } 58 | 59 | private void addChild(int parent, int idx, boolean text) { 60 | components.add(new ComponentDef(parent, idx, text)); 61 | } 62 | 63 | @Override 64 | public boolean activateCondition() { 65 | if (game.isLoggedIn()) { 66 | if (interfaces.get(755).getComponent(44).isValid()) { // World map 67 | if (interfaces.getComponent(755, 0).getComponents().length > 0) { 68 | return true; 69 | } 70 | } 71 | for (ComponentDef c : components) { 72 | RSComponent comp = interfaces.getComponent(c.parent, c.child); 73 | if (comp.isValid() && !(c.text && (comp.getText() == null || comp.getText().isEmpty()))) { 74 | return true; 75 | } 76 | } 77 | } 78 | return false; 79 | } 80 | 81 | @Override 82 | public int loop() { 83 | sleep(random(500, 900)); 84 | if (interfaces.get(755).isValid() && (interfaces.getComponent(755, 0).getComponents().length > 0)) { 85 | interfaces.getComponent(755, 44).doClick(); 86 | return random(500, 900); 87 | } 88 | for (ComponentDef c : components) { 89 | if (interfaces.getComponent(c.parent, c.child).isValid()) { 90 | interfaces.getComponent(c.parent, c.child).doClick(); 91 | sleep(random(500, 900)); 92 | if (random(0, 3) == 0) { 93 | mouse.moveSlightly(); 94 | } 95 | break; 96 | } 97 | } 98 | return -1; 99 | } 100 | } -------------------------------------------------------------------------------- /src/org/rsbot/loader/script/adapter/AddGetterAdapter.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.loader.script.adapter; 2 | 3 | import org.rsbot.loader.asm.ClassAdapter; 4 | import org.rsbot.loader.asm.ClassVisitor; 5 | import org.rsbot.loader.asm.MethodVisitor; 6 | import org.rsbot.loader.asm.Opcodes; 7 | 8 | /** 9 | * @author Jacmob 10 | */ 11 | public class AddGetterAdapter extends ClassAdapter implements Opcodes { 12 | 13 | public static class Field { 14 | public int getter_access; 15 | public String getter_name; 16 | public String getter_desc; 17 | public String owner; 18 | public String name; 19 | public String desc; 20 | } 21 | 22 | private boolean virtual; 23 | private Field[] fields; 24 | 25 | private String owner; 26 | 27 | public AddGetterAdapter(ClassVisitor delegate, boolean virtual, Field[] fields) { 28 | super(delegate); 29 | this.virtual = virtual; 30 | this.fields = fields; 31 | } 32 | 33 | public void visit( 34 | final int version, 35 | final int access, 36 | final String name, 37 | final String signature, 38 | final String superName, 39 | final String[] interfaces) { 40 | this.owner = name; 41 | cv.visit(version, access, name, signature, superName, interfaces); 42 | } 43 | 44 | public void visitEnd() { 45 | if (virtual) { 46 | for (Field f : fields) { 47 | visitGetter(f.getter_access, f.getter_name, f.getter_desc, f.name, f.desc); 48 | } 49 | } else { 50 | for (Field f : fields) { 51 | visitGetter(f.getter_access, f.getter_name, f.getter_desc, f.owner, f.name, f.desc); 52 | } 53 | } 54 | cv.visitEnd(); 55 | } 56 | 57 | private void visitGetter( 58 | final int getter_access, 59 | final String getter_name, 60 | final String getter_desc, 61 | final String name, 62 | final String desc) { 63 | MethodVisitor mv = cv.visitMethod(getter_access, getter_name, getter_desc, null, null); 64 | mv.visitCode(); 65 | mv.visitVarInsn(ALOAD, 0); 66 | mv.visitFieldInsn(GETFIELD, owner, name, desc); 67 | int op = getReturnOpcode(desc); 68 | mv.visitInsn(op); 69 | mv.visitMaxs(op == LRETURN || op == DRETURN ? 2 : 1, (getter_access & ACC_STATIC) == 0 ? 1 : 0); 70 | mv.visitEnd(); 71 | } 72 | 73 | private void visitGetter( 74 | final int getter_access, 75 | final String getter_name, 76 | final String getter_desc, 77 | final String owner, 78 | final String name, 79 | final String desc) { 80 | MethodVisitor mv = cv.visitMethod(getter_access, getter_name, getter_desc, null, null); 81 | mv.visitCode(); 82 | mv.visitFieldInsn(GETSTATIC, owner, name, desc); 83 | int op = getReturnOpcode(desc); 84 | mv.visitInsn(op); 85 | mv.visitMaxs(op == LRETURN || op == DRETURN ? 2 : 1, (getter_access & ACC_STATIC) == 0 ? 1 : 0); 86 | mv.visitEnd(); 87 | } 88 | 89 | private int getReturnOpcode(String desc) { 90 | desc = desc.substring(desc.indexOf(")") + 1); 91 | if (desc.length() > 1) { 92 | return ARETURN; 93 | } 94 | char c = desc.charAt(0); 95 | switch (c) { 96 | case 'I': 97 | case 'Z': 98 | case 'B': 99 | case 'S': 100 | case 'C': 101 | return IRETURN; 102 | case 'J': 103 | return LRETURN; 104 | case 'F': 105 | return FRETURN; 106 | case 'D': 107 | return DRETURN; 108 | } 109 | throw new RuntimeException("eek"); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/org/rsbot/gui/BotHome.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.gui; 2 | 3 | import org.rsbot.bot.Bot; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import java.awt.image.BufferedImage; 8 | import java.util.Collection; 9 | 10 | /** 11 | * @author Jacmob 12 | */ 13 | public class BotHome { 14 | 15 | private static final Font FONT = new Font("Helvetica", 1, 13); 16 | private int width; 17 | private int height; 18 | private Bot[] bots = new Bot[0]; 19 | 20 | public void setBots(final Collection col) { 21 | SwingUtilities.invokeLater(new Runnable() { 22 | 23 | public void run() { 24 | bots = col.toArray(new Bot[col.size()]); 25 | } 26 | }); 27 | } 28 | 29 | public void setSize(int width, int height) { 30 | this.width = width; 31 | this.height = height; 32 | } 33 | 34 | // TODO: Replace; temporary preview. 35 | public void paint(Graphics g) { 36 | g.setColor(Color.black); 37 | g.fillRect(0, 0, width, height); 38 | int len = Math.min(bots.length, 6); 39 | if (len == 1) { 40 | draw(g, 0, 0, 0, width, height); 41 | } else if (len == 2) { 42 | draw(g, 0, 0, 0, width, height / 2); 43 | draw(g, 1, 0, height / 2, width, height / 2); 44 | } else if (len == 3) { 45 | draw(g, 0, 0, 0, width / 2, height / 2); 46 | draw(g, 1, width / 2, 0, width / 2, height / 2); 47 | draw(g, 2, 0, height / 2, width, height / 2); 48 | } else if (len == 4) { 49 | draw(g, 0, 0, 0, width / 2, height / 2); 50 | draw(g, 1, width / 2, 0, width / 2, height / 2); 51 | draw(g, 2, 0, height / 2, width / 2, height / 2); 52 | draw(g, 3, width / 2, height / 2, width / 2, height / 2); 53 | } else if (len == 5) { 54 | draw(g, 0, 0, 0, width / 3, height / 2); 55 | draw(g, 1, width / 3, 0, width / 3, height / 2); 56 | draw(g, 2, (width * 2) / 3, 0, width / 3, height / 2); 57 | draw(g, 3, 0, height / 2, width / 2, height / 2); 58 | draw(g, 4, width / 2, height / 2, width / 2, height / 2); 59 | } else if (len == 6) { 60 | draw(g, 0, 0, 0, width / 3, height / 2); 61 | draw(g, 1, width / 3, 0, width / 3, height / 2); 62 | draw(g, 2, (width * 2) / 3, 0, width / 3, height / 2); 63 | draw(g, 3, 0, height / 2, width / 3, height / 2); 64 | draw(g, 4, width / 3, height / 2, width / 3, height / 2); 65 | draw(g, 5, (width * 2) / 3, height / 2, width / 3, height / 2); 66 | } else { 67 | return; 68 | } 69 | FontMetrics metrics = g.getFontMetrics(FONT); 70 | g.setColor(new Color(0, 0, 0, 170)); 71 | g.fillRect(0, height - 30, width, 30); 72 | g.setColor(Color.white); 73 | g.drawString("Spectating " + (bots.length == 1 ? "1 bot." : bots.length + " bots."), 5, height + metrics.getDescent() - 14); 74 | } 75 | 76 | public void draw(Graphics g, int idx, int x, int y, int width, int height) { 77 | BufferedImage img = bots[idx].getImage(); 78 | if (img != null && img.getWidth() > 0) { 79 | int w_img = img.getWidth(), h_img = img.getHeight(); 80 | float img_ratio = (float) w_img / (float) h_img; 81 | float bound_ratio = (float) width / (float) height; 82 | int w, h; 83 | if (img_ratio < bound_ratio) { 84 | h = height; 85 | w = (int) (((float) w_img / (float) h_img) * h); 86 | } else { 87 | w = width; 88 | h = (int) (((float) h_img / (float) w_img) * w); 89 | } 90 | g.drawImage(img.getScaledInstance(w, h, Image.SCALE_SMOOTH), x + width / 2 - w / 2, y + height / 2 - h / 2, null); 91 | g.setColor(Color.gray); 92 | g.drawRect(x, y, width - 1, height - 1); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /src/org/rsbot/script/util/Timer.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.script.util; 2 | 3 | /** 4 | * A Timer 5 | */ 6 | public class Timer { 7 | 8 | private long end; 9 | private final long start; 10 | private final long period; 11 | 12 | /** 13 | * Instantiates a new Timer with a given time 14 | * period in milliseconds. 15 | * 16 | * @param period Time period in milliseconds. 17 | */ 18 | public Timer(long period) { 19 | this.period = period; 20 | this.start = System.currentTimeMillis(); 21 | this.end = start + period; 22 | } 23 | 24 | /** 25 | * Returns the number of milliseconds elapsed since 26 | * the start time. 27 | * 28 | * @return The elapsed time in milliseconds. 29 | */ 30 | public long getElapsed() { 31 | return (System.currentTimeMillis() - start); 32 | } 33 | 34 | /** 35 | * Returns the number of milliseconds remaining 36 | * until the timer is up. 37 | * 38 | * @return The remaining time in milliseconds. 39 | */ 40 | public long getRemaining() { 41 | if (isRunning()) { 42 | return (end - System.currentTimeMillis()); 43 | } 44 | return 0; 45 | } 46 | 47 | /** 48 | * Returns true if this timer's time period 49 | * has not yet elapsed. 50 | * 51 | * @return true if the time period has not yet passed. 52 | */ 53 | public boolean isRunning() { 54 | return (System.currentTimeMillis() < end); 55 | } 56 | 57 | /** 58 | * Restarts this timer using its period. 59 | */ 60 | public void reset() { 61 | this.end = System.currentTimeMillis() + period; 62 | } 63 | 64 | /** 65 | * Sets the end time of this timer to a given number of 66 | * milliseconds from the time it is called. This does 67 | * not edit the period of the timer (so will not affect 68 | * operation after reset). 69 | * 70 | * @param ms The number of milliseconds before the timer 71 | * should stop running. 72 | * @return The new end time. 73 | */ 74 | public long setEndIn(long ms) { 75 | this.end = System.currentTimeMillis() + ms; 76 | return this.end; 77 | } 78 | 79 | /** 80 | * Returns a formatted String of the time elapsed. 81 | * 82 | * @return The elapsed time formatted hh:mm:ss. 83 | */ 84 | public String toElapsedString() { 85 | return format(getElapsed()); 86 | } 87 | 88 | /** 89 | * Returns a formatted String of the time remaining. 90 | * 91 | * @return The remaining time formatted hh:mm:ss. 92 | */ 93 | public String toRemainingString() { 94 | return format(getRemaining()); 95 | } 96 | 97 | /** 98 | * Converts milliseconds to a String in the format 99 | * hh:mm:ss. 100 | * 101 | * @param time The number of milliseconds. 102 | * @return The formatted String. 103 | */ 104 | public static String format(long time) { 105 | StringBuilder t = new StringBuilder(); 106 | long total_secs = time / 1000; 107 | long total_mins = total_secs / 60; 108 | long total_hrs = total_mins / 60; 109 | int secs = (int) total_secs % 60; 110 | int mins = (int) total_mins % 60; 111 | int hrs = (int) total_hrs % 60; 112 | if (hrs < 10) { 113 | t.append("0"); 114 | } 115 | t.append(hrs); 116 | t.append(":"); 117 | if (mins < 10) { 118 | t.append("0"); 119 | } 120 | t.append(mins); 121 | t.append(":"); 122 | if (secs < 10) { 123 | t.append("0"); 124 | } 125 | t.append(secs); 126 | return t.toString(); 127 | } 128 | } -------------------------------------------------------------------------------- /src/org/rsbot/bot/Crawler.java: -------------------------------------------------------------------------------- 1 | package org.rsbot.bot; 2 | 3 | import org.rsbot.util.GlobalConfiguration; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.InputStreamReader; 7 | import java.net.HttpURLConnection; 8 | import java.net.URL; 9 | import java.util.HashMap; 10 | import java.util.logging.Logger; 11 | import java.util.regex.Matcher; 12 | import java.util.regex.Pattern; 13 | 14 | class Crawler { 15 | private static final Logger log = Logger.getLogger(Crawler.class.getName()); 16 | 17 | private static HashMap parameters; 18 | private final String world_prefix; 19 | 20 | public Crawler(String root) { 21 | final String index = firstMatch( 22 | "Continue to Full Site for News and Game Help", 23 | downloadPage(root, null)); 24 | 25 | final String frame = root + "game.ws"; 26 | 27 | final String game = firstMatch( 28 | "]*)\"?>", 35 | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); 36 | final Matcher matcher = pattern.matcher(downloadPage(game, frame)); 37 | parameters = new HashMap(); 38 | while (matcher.find()) { 39 | final String key = removeTrailingChar(matcher.group(1), '"'); 40 | final String value = removeTrailingChar(matcher.group(2), '"'); 41 | if (!parameters.containsKey(key)) { 42 | parameters.put(key, value); 43 | } 44 | } 45 | 46 | final String ie = "haveie6"; 47 | if (parameters.containsKey(ie)) { 48 | parameters.remove(ie); 49 | } 50 | parameters.put("haveie6", "0"); 51 | 52 | log.fine("Parameters: " + parameters); 53 | } 54 | 55 | private String downloadPage(final String url, final String referer) { 56 | try { 57 | HttpURLConnection con = GlobalConfiguration.getHttpConnection(new URL(url)); 58 | if (referer != null && !referer.isEmpty()) 59 | con.addRequestProperty("Referer", referer); 60 | final BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream())); 61 | final StringBuilder buf = new StringBuilder(); 62 | String line; 63 | while ((line = reader.readLine()) != null) { 64 | buf.append(line); 65 | } 66 | reader.close(); 67 | return buf.toString(); 68 | } catch (final Exception e) { 69 | e.printStackTrace(); 70 | } 71 | return null; 72 | } 73 | 74 | private String firstMatch(final String regex, final String str) { 75 | final Pattern pattern = Pattern.compile(regex); 76 | final Matcher matcher = pattern.matcher(str); 77 | while (matcher.find()) { 78 | return matcher.group(1); 79 | } 80 | return null; 81 | } 82 | 83 | public HashMap getParameters() { 84 | return parameters; 85 | } 86 | 87 | public String getWorldPrefix() { 88 | return world_prefix; 89 | } 90 | 91 | private String removeTrailingChar(final String str, final char ch) { 92 | if ((str == null) || str.isEmpty()) { 93 | return str; 94 | } else if (str.length() == 1) { 95 | return str.charAt(0) == ch ? "" : str; 96 | } 97 | try { 98 | final int l = str.length() - 1; 99 | if (str.charAt(l) == ch) { 100 | return str.substring(0, l); 101 | } 102 | return str; 103 | } catch (final Exception e) { 104 | return str; 105 | } 106 | } 107 | } 108 | --------------------------------------------------------------------------------