Jump to content
Sign in to follow this  
Neo

Alora Alora wizard teleporting

Recommended Posts

 

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");

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×