PDA

View Full Version : Better Teleporting ; Using ENUMS.



Vhince
October 9th, 2010, 21:59
Thought i'd convert Shamon's teleporting system for Hyperion for wL


import com.rs2.model.player.Client;
import java.util.HashMap;
import java.util.Map;

public class ActionTeleports {

public enum Teleports {


TEST(29031, 3200, 3200);


//
private int x;
private int y;
private int z;
private int button;

private Teleports(int button, int x, int y) {
this.button = button;
this.x = x;
this.y = y;
}

public int getButton() {
return button;
}

public int getX() {
return x;
}

public int getY() {
return y;
}

public int getZ() {
return z;
}
}
private static Map<Integer, Teleports> actionButton = new HashMap<Integer, Teleports>();

public static Teleports forId(int object) {
return actionButton.get(object);
}

static {
for (Teleports teles : Teleports.values()) {
actionButton.put(teles.getButton(), teles);
}
}

public static void teleport(final Client player, final int button) {
if (forId(button) == null) {
return;
}
player.teleportToX = forId(button).getX();
player.teleportToY = forId(button).getY();

}
}


ClickingButtons/ActionButton packet


ActionTeleports.teleport(client, actionButtonId);



Now you don't need to be adding all these JUNK case switches like

case 1:
VarrockTele


some stuff like that.

Simply just do this to add more TelePorts.
Example


LUMBRIDGE(29031, 3200, 3200);

29031 - ActionButton ID
3200, 3200 - X and Y Coordinates

Network
October 9th, 2010, 22:01
What is this even for..?

Vhince
October 9th, 2010, 22:03
I can't explain. L0l hold up

Relapse
October 9th, 2010, 22:03
What is this even for..?

Teleporting...

Network
October 9th, 2010, 22:04
Teleporting...

Whoa really? I had no fucking idea.. I mean the base you dumbass

Relapse
October 9th, 2010, 22:05
Thought i'd convert Shamon's teleporting system for Hyperion for wL


wL = winterLove = delta

There you go... please read next time

Vhince
October 9th, 2010, 22:18
Works on any base

girofsilgar
October 9th, 2010, 23:38
horrible way to do teleports

do you have any idea how much memory is used from hashmaps and enums?


why would u even need to use this
teleport(falador)
rather do
teleport(falladors coords);/falador duh


long story short: this is bad.

Vhince
October 10th, 2010, 12:39
horrible way to do teleports

do you have any idea how much memory is used from hashmaps and enums?


why would u even need to use this
teleport(falador)
rather do
teleport(falladors coords);/falador duh


long story short: this is bad.

It's
FALADOR(ACTIONBUTTONID, X, Y); ?

I like it cause it is neater (in my opinion) than arrays.

I just hate doing stuff like this


case 4140:
TeleportHandler.teleportTo(client, "Varrock");
break;

case 4143:
TeleportHandler.teleportTo(client, "Lumbridge");
break;

case 4146:
TeleportHandler.teleportTo(client, "Falador");
break;