public int getParentId() { final Object inter = getInternal(); if (inter == null) { return -1; } final Client client = Context.client(); final Multipliers multipliers = Context.multipliers(); final int parentId = ((RSInterfaceParentID) ((RSInterfaceInts) inter).getRSInterfaceInts()) .getRSInterfaceParentID() * multipliers.INTERFACE_PARENTID; if (parentId != -1) { return parentId; } final int mainID = getId() >>> 0x10; final HashTable ncI = new HashTable(client.getRSInterfaceNC()); for (RSInterfaceNode node = (RSInterfaceNode) ncI.getFirst(); node != null; node = (RSInterfaceNode) ncI.getNext()) { if (mainID == ((RSInterfaceNodeMainID) ((RSInterfaceNodeInts) node.getData()).getRSInterfaceNodeInts()) .getRSInterfaceNodeMainID() * multipliers.INTERFACENODE_MAINID) { final long multiplier = (((long) multipliers.NODE_ID) << 32) + ((multipliers.NODE_ID_p2 & 0xffffffffL)); return (int) (node.getID() * multiplier); } } return -1; }
public int getRelativeY() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceY) ((RSInterfaceInts) widget).getRSInterfaceInts()).getRSInterfaceY() * Context.multipliers().INTERFACE_Y : -1; }
public int getType() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceType) ((RSInterfaceInts) widget).getRSInterfaceInts()).getRSInterfaceType() * Context.multipliers().INTERFACE_TYPE : -1; }
public Point getAbsoluteLocation() { if (getInternal() == null) { return new Point(-1, -1); } final Client client = Context.client(); final int parentId = getParentId(); int x = 0, y = 0; if (parentId != -1) { final Point point = Widgets.get(parentId >> 0x10, parentId & 0xffff).getAbsoluteLocation(); x = point.x; y = point.y; } else { final Rectangle[] bounds = client.getRSInterfaceBoundsArray(); final int index = getBoundsArrayIndex(); if (bounds != null && index > 0 && index < bounds.length && bounds[index] != null) { return new Point(bounds[index].x, bounds[index].y); } // x = getMasterX(); // y = getMasterY(); } if (parentId != -1) { final WidgetChild child = Widgets.getChild(parentId); final int horizontalScrollSize = child.getScrollableContentWidth(), verticalScrollSize = child.getScrollableContentHeight(); if (horizontalScrollSize > 0 || verticalScrollSize > 0) { x -= child.getHorizontalScrollPosition(); y -= child.getVerticalScrollPosition(); } } x += getRelativeX(); y += getRelativeY(); return new Point(x, y); }
public int getScrollableContentWidth() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceHorizontalScrollbarSize) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceHorizontalScrollbarSize() * Context.multipliers().INTERFACE_HORIZONTALSCROLLBARSIZE : -1; }
public int getBoundsArrayIndex() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceBoundsArrayIndex) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceBoundsArrayIndex() * Context.multipliers().INTERFACE_BOUNDSARRAYINDEX : -1; }
public int getVerticalScrollPosition() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceVerticalScrollbarPosition) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceVerticalScrollbarPosition() * Context.multipliers().INTERFACE_VERTICALSCROLLBARTHUMBPOSITION : -1; }
public int getChildIndex() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceComponentIndex) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceComponentIndex() * Context.multipliers().INTERFACE_COMPONENTINDEX : -1; }
public int getZRotation() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceZRotation) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceZRotation() * Context.multipliers().INTERFACE_ZROTATION : -1; }
public int getModelZoom() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceModelZoom) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceModelZoom() * Context.multipliers().INTERFACE_MODELZOOM : -1; }
public int getChildStackSize() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceComponentStackSize) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceComponentStackSize() * Context.multipliers().INTERFACE_COMPONENTSTACKSIZE : -1; }
public int getBorderThickness() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceBorderThinkness) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceBorderThinkness() * Context.multipliers().INTERFACE_BORDERTHICKNESS : -1; }
public int getShadowColor() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceShadowColor) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceShadowColor() * Context.multipliers().INTERFACE_SHADOWCOLOR : -1; }
public int getTextureId() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceTextureID) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceTextureID() * Context.multipliers().INTERFACE_TEXTUREID : -1; }
public int getVerticalScrollThumbSize() { final Object widget = getInternal(); return widget != null ? ((RSInterfaceVerticalScrollbarThumbSize) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceVerticalScrollbarThumbSize() * Context.multipliers().INTERFACE_VERTICALSCROLLBARTHUMBSIZE : -1; }
public static Tile getDestination() { final Client client = Context.client(); final int lx = client.getDestX(); final int ly = client.getDestY(); if (lx == -1 || ly == -1) { return new Tile(-1, -1, -1); } return new Tile(Game.getBaseX() + lx, Game.getBaseY() + ly, Game.getPlane()); }
private Record() { client = Context.client(); index_widget = -1; index_map = -1; index_compass = -1; for (int i = 0; i < 17; i++) { indices_tabs[i] = -1; } }
public Point getRelativeLocation() { final Object widget = getInternal(); if (widget == null) { return new Point(-1, -1); } final Object rsInterfaceInts = ((RSInterfaceInts) widget).getRSInterfaceInts(); final Multipliers multipliers = Context.multipliers(); return new Point( ((RSInterfaceX) rsInterfaceInts).getRSInterfaceX() * multipliers.INTERFACE_X, ((RSInterfaceY) rsInterfaceInts).getRSInterfaceY() * multipliers.INTERFACE_Y); }
public int getWidth() { if (!isInScrollableArea()) { return getHorizontalScrollThumbSize(); } final Object widget = getInternal(); return widget != null ? (((RSInterfaceWidth) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceWidth() * Context.multipliers().INTERFACE_WIDTH) - 4 : -1; }
public int getHeight() { if (!isInScrollableArea()) { return getVerticalScrollThumbSize(); } final Object widget = getInternal(); return widget != null ? (((RSInterfaceHeight) ((RSInterfaceInts) widget).getRSInterfaceInts()) .getRSInterfaceHeight() * Context.multipliers().INTERFACE_HEIGHT) - 4 : -1; }
public SceneObjectDefinition getDefinition() { final HashTable rsObjectDefLoaders = (HashTable) ((RSInfo) Context.client().getRSGroundInfo()).getRSObjectDefLoaders(); final Node ref = Nodes.lookup(rsObjectDefLoaders, getId()); if (ref != null) { if (ref instanceof HardReference) { return new SceneObjectDefinition((RSObjectDef) ((HardReference) ref).get()); } else if (ref instanceof SoftReference) { final Object def = ((SoftReference<?>) ref).get(); if (def != null) { return new SceneObjectDefinition((RSObjectDef) def); } } } return null; }
/** * @param filter The filtering <code>Filter</code> to accept all the Npcs through. * @return An array of the currently loaded Npcs in the game that are accepted by the provided * filter. */ public static NPC[] getLoaded(final Filter<NPC> filter) { final Client client = Context.client(); final int[] indices = client.getRSNPCIndexArray(); final Set<NPC> npcs = new HashSet<>(); for (final int index : indices) { final Node node = Nodes.lookup((HashTable) client.getRSNPCNC(), index); if (node != null) { NPC npc = null; if (node instanceof RSNPCNode) { npc = new NPC((RSNPC) ((RSNPCNode) node).getRSNPC()); } else if (node instanceof SoftReference) { npc = new NPC( (RSNPC) ((java.lang.ref.SoftReference<?>) ((SoftReference) node).get()).get()); } if (filter.accept(npc)) { npcs.add(npc); } } } return npcs.toArray(new NPC[npcs.size()]); }
/** * @param filter The filtering <code>Filter</code> NPCs have to pass. * @return The nearest Npc passing the filter if any present, else <i>null</i>. */ public static NPC getNearest(final Filter<NPC> filter) { final Client client = Context.client(); final int[] indices = client.getRSNPCIndexArray(); NPC npc = null; double distance = Double.MAX_VALUE; final RegionOffset position = Players.getLocal().getRegionOffset(); for (final int index : indices) { final Node node = Nodes.lookup((HashTable) client.getRSNPCNC(), index); if (node != null && node instanceof RSNPCNode) { final NPC t_npc = new NPC((RSNPC) ((RSNPCNode) node).getRSNPC()); try { if (filter.accept(t_npc)) { final double dist = Calculations.distance(position, t_npc.getRegionOffset()); if (dist < distance) { distance = dist; npc = t_npc; } } } catch (final Exception ignored) { } } } return npc; }
/** * @param plane The plane of which to provide the collision flags for. * @return The collision flags of the current map block. */ public static int[][] getCollisionFlags(final int plane) { final RSInfo info = Context.client().getRSGroundInfo(); final RSGroundData data = info.getGroundData()[plane]; return data.getBlocks(); }
/** * @param plane The plane of which to determine the collision offset for. * @return The <code>Tile</code> of the offset location (different than map base!). */ public static Tile getCollisionOffset(final int plane) { final RSInfo info = Context.client().getRSGroundInfo(); final RSGroundData data = info.getGroundData()[plane]; return new Tile(data.getX(), data.getY(), plane); }
@Override public void execute() { if (GlobalConstant.WIELDED_ID != -1 && Settings.get(300) == 1000 && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 10 - 200) { if (Players.getLocal().getAppearance()[GlobalConstant.WEAPON] != GlobalConstant.EXCALIBUR && (Tabs.getCurrent().equals(Tabs.INVENTORY) || Tabs.INVENTORY.open())) { final Item excalibur = Inventory.getItem(GlobalConstant.EXCALIBUR); if (excalibur != null) { excalibur.getWidgetChild().click(true); PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Players.getLocal().getAppearance()[GlobalConstant.WEAPON] == GlobalConstant.EXCALIBUR; } }, (long) Random.nextInt(750, 1500)); } } else if (Tabs.getCurrent().equals(Tabs.ATTACK) || Tabs.ATTACK.open()) { final WidgetChild bar = Widgets.get(884, 4); if (bar.validate()) { bar.click(true); PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Settings.get(300) != 1000; } }, (long) Random.nextInt(400, 800)); } } return; } if (GlobalConstant.KEEP_ALIVE && Checks.getLP() < Skills.getRealLevel(Skills.CONSTITUTION) * 0.4f * 10) { if (Checks.isOutside()) { if (Players.getLocal().getAnimation() == -1) { final WidgetChild[] widgets = {Widgets.get(750, 2), Widgets.get(750, 6)}; if (widgets[0].validate() && widgets[1].validate()) { if (widgets[Random.nextInt(0, widgets.length)].interact("Rest")) PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Players.getLocal().getAnimation() != -1; } }, (long) Random.nextInt(750, 1500)); } } Task.sleep(400, 800); } else { if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 5) { if (Traverse.walk(GlobalConstant.TILE_BANK)) { PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Walking.getDestination() == null || Calculations.distanceTo(Walking.getDestination()) < 8; } }, (long) Random.nextInt(500, 1000)); } } } } else { if (Checks.isOutside()) { final SceneObject ladder = SceneEntities.getNearest(GlobalConstant.ROPE_DOWN_ID); if (ladder != null && ladder.interact("Climb")) PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return !Checks.isOutside(); } }, 750l); else if (ladder != null && Calculations.distanceTo(ladder) > 5) PauseHandler.walk(ladder, (long) Random.nextInt(250, 750)); } else if (inCombat() || Players.getLocal().isInCombat()) { final Tile rockTile = GlobalConstant.TILE_ROCKS[Checks.isGold()][Mine.getCurrent()]; if (true || Calculations.distanceTo(GlobalConstant.TILE_BANK) < Calculations.distanceTo(rockTile)) { if (Calculations.distanceTo(GlobalConstant.TILE_BANK) > 6 && Traverse.walk(GlobalConstant.TILE_BANK)) { PauseHandler.pause( new PauseHandler.Condition() { @Override public boolean validate() { return Walking.getDestination() == null || Calculations.distanceTo(Walking.getDestination()) < 8; } }, (long) Random.nextInt(200, 500)); } } else { final SceneObject rock = SceneEntities.getAt(rockTile); final NPC npc = NPCs.getNearest( new Filter<NPC>() { @Override public boolean accept(final NPC npc) { return npc.getInteracting() != null && npc.getInteracting().equals(Players.getLocal()) && Arrays.binarySearch(GlobalConstant.LRC_NPC, npc.getId()) >= 0; } }); if (rock != null && npc != null) { final Tile hardcodedSafe = GlobalConstant.MINE_GOLD && Mine.getCurrent() == 0 ? GlobalConstant.GOLD_SAFE_SPOT : !GlobalConstant.MINE_GOLD && Mine.getCurrent() == 2 ? GlobalConstant.COAL_SAFE_SPOT : null; if (hardcodedSafe != null) { hardcodedSafe .randomize(0, Mine.getCurrent() == 2 ? 4 : 1, 1, Mine.getCurrent() == 0 ? -4 : 1) .clickOnMap(); } else { final Tile[] bounds = rock.getArea().getBoundingTiles(); Arrays.sort( bounds, new Comparator<Tile>() { @Override public int compare(final Tile t1, final Tile t2) { return Calculations.distance(t1, npc.getLocation()) < Calculations.distance(t2, npc.getLocation()) ? 1 : -1; } }); final int[][] flags = Walking.getCollisionFlags(Game.getPlane()); final Tile colOffset = Walking.getCollisionOffset(Game.getPlane()) .derive(Game.getBaseX(), Game.getBaseY()); Tile toWalk = null; for (final int[] offset : new int[][] {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}) { final Tile derive = bounds[0].derive(offset[0], offset[1]); if (Nodes.walkable(flags, colOffset, derive)) { if (toWalk == null || Calculations.distance(derive, npc) > Calculations.distance(toWalk, npc)) toWalk = derive; } } if (toWalk != null) { if (!toWalk.isOnScreen()) Camera.turnTo(toWalk); toWalk.interact("Walk here"); } } Task.sleep(100, 300); final int lp = Checks.getLP(); final Timer timer = new Timer((long) Random.nextInt(7500, 10000)); while (Players.getLocal().isInCombat() && Checks.getLP() >= lp && !Context.get().getScriptHandler().isPaused() && timer.isRunning()) Task.sleep(200, 800); } } } } }