Neo Posted March 3, 2018 Share Posted March 3, 2018 Teleports to a location by talking to the wizard (or using 'previous' if it was your last destination) Spoiler /** * Teleports to a location by talking to the wizard at home * @param location The location you want to teleport to */ public void teleport(String location) { final NPC wizard = NPCs.getNearest(4397); if(wizard != null) { final WidgetChild prev = Widgets.getWidgetChild(42860954); if(prev != null && prev.getText().toLowerCase().contains(location.toLowerCase())) { wizard.interact("prev"); return; }else { if(Widgets.isVisible(654)) { WidgetChild[] options = Widgets.get(654).getChildren(); for(WidgetChild option : options) { final String text = option.getText(); if(text != null && !text.isEmpty() && text.toLowerCase().contains(location.toLowerCase())) { Packets.sendAction(0, option.getId(), 8, 0, "", "Ok"); Time.sleep(150); Packets.sendAction(0, 42860643, 28, 0, "", "Close"); } } }else { wizard.interact("talk-to"); Time.sleep(() -> Widgets.isVisible(654), 750); Time.sleep(150); teleport(location); } } } } Updated version to differ better between similar names (e.g slayer tower and varrock slayer tower) public static void teleport(String location) { final NPC wizard = NPCs.getNearest(4397); if(wizard != null) { final WidgetChild prev = Widgets.getWidgetChild(42860954); if(prev != null && prev.getText().toLowerCase().startsWith(location.toLowerCase())) { wizard.interact("prev"); return; }else { if(Widgets.isVisible(654)) { WidgetChild[] options = Widgets.get(654).getChildren(); for(WidgetChild option : options) { final String text = option.getText(); if(text != null && !text.isEmpty() && text.toLowerCase().trim().startsWith(location.toLowerCase())) { Packets.sendAction(0, option.getId(), 8, 0, "", "Ok"); Time.sleep(150); Packets.sendAction(0, 42860643, 28, 0, "", "Close"); } } }else { wizard.interact("talk-to"); Time.sleep(() -> Widgets.isVisible(654), 750); Time.sleep(150); teleport(location); } } } } Usage examples; teleport("karamja"); teleport("rock crabs"); teleport("steel dragons"); teleport("falad"); 2 Link to comment Share on other sites More sharing options...
Jake Posted May 13, 2018 Share Posted May 13, 2018 Soulplay teleport snippet (same concept) public boolean teleport(String destination) { Widget container = Widgets.get(25411); if (container != null) { WidgetChild[] children = container.getChildren(); for (WidgetChild child : children) { WidgetChild[] grandChildren = child.getChildren(); for (WidgetChild grandChild : grandChildren) { String text = grandChild.getText(); if (text != null && !text.isEmpty() && text.trim().toLowerCase().equals(destination.toLowerCase())) { Packets.sendAction(315, 0, 0, grandChild.getParentId() - 1); return true; } } } } return false; } uses: if (teleport("daemonheim")) { Time.sleep(250); // ... wait to lose teleport animation ... Time.sleep(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return Players.getMyPlayer().getAnimation() == -1; } }, 4000); // ... do other stuff ... } spelling must be correct but capitalization doesn't matter Link to comment Share on other sites More sharing options...
Jake Posted November 28, 2018 Share Posted November 28, 2018 dawntained tele public boolean teleport(String category, String location) { //opens teleport on any spell book Packets.sendAction(315, 0, 0, 1164, 0); Packets.sendAction(315, 0, 0, 13035, 0); Packets.sendAction(646, 0, 0, 30064, 0); if (Time.sleep(() -> Widgets.getOpenInterface() == 19700, 4500)) { final Widget widgetCategory = Widgets.get(19700); if (widgetCategory != null) { final WidgetChild[] categoryChildren = widgetCategory.getChildren(); int categoryOffset = 0; for (int i = 0; i < categoryChildren.length; i++) { final WidgetChild categoryChild = categoryChildren[i]; if (categoryChild != null) { if (categoryChild.getText().trim().toLowerCase().equals(category.toLowerCase())) { Packets.sendAction(315, 0, 0, 19698 + i + categoryOffset, 0); Time.sleep(2000); //2 second wait to wait for spells on right side to update final Widget widgetLocation = Widgets.get(19734); if (widgetLocation != null) { final WidgetChild[] locationChildren = widgetLocation.getChildren(); int locationOffset = 0; for (int j = 0; j < locationChildren.length; j++) { final WidgetChild locationChild = locationChildren[j]; if (locationChild != null) { if (locationChild.getText().trim().toLowerCase().equals(location.toLowerCase())) { Packets.sendAction(315, 0, 0, 19732 + j + locationOffset, 0); return true; } if (locationChild.getChildren().length > 0) { locationOffset++; } } } } } if (categoryChild.getChildren().length > 0) { categoryOffset++; } } } } } return false; } 1 Link to comment Share on other sites More sharing options...
Recommended Posts