Obelisk improvements
Made the wilderness teleport obelisks roll the destination obelisk fairly Improved obelisk teleport positioning logic Made the obelisk teleport capture a 3-by-3 bounding box of players, in accordance with the teleport animation
This commit is contained in:
@@ -19,8 +19,8 @@ import core.tools.RandomFunction;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the wilderness obelisk plugin.
|
* Represents the wilderness obelisk plugin.
|
||||||
* @author 'Vexia
|
* @author 'Vexia, small changes by Player Name
|
||||||
* @version 1.0
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
@Initializable
|
@Initializable
|
||||||
public final class WildernessObeliskPlugin extends OptionHandler {
|
public final class WildernessObeliskPlugin extends OptionHandler {
|
||||||
@@ -90,20 +90,23 @@ public final class WildernessObeliskPlugin extends OptionHandler {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int index = RandomFunction.random(Obelisk.values().length);
|
// Determine new obelisk
|
||||||
Obelisk newObelisk = Obelisk.values()[index];
|
Obelisk[] newObelisks = Obelisk.values();
|
||||||
if (newObelisk == stationObelisk) {
|
for (int i = 0; i < newObelisks.length; i++) {
|
||||||
newObelisk = Obelisk.values()[index++ % Obelisk.values().length];
|
// Find our current obelisk and remove it from the candidate set by replacing it with the last obelisk
|
||||||
|
if (newObelisks[i] == stationObelisk) {
|
||||||
|
newObelisks[i] = newObelisks[newObelisks.length - 1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
for (Player player : RegionManager.getLocalPlayers(center, 1)) {
|
}
|
||||||
|
int index = RandomFunction.random(0, newObelisks.length - 1); //cutting out the last one that is now duplicated
|
||||||
|
Obelisk newObelisk = newObelisks[index];
|
||||||
|
// Teleport players standing within a 3-by-3 bounding box
|
||||||
|
for (Player player : RegionManager.getLocalPlayersBoundingBox(center, 1, 1)) {
|
||||||
player.getPacketDispatch().sendMessage("Ancient magic teleports you somewhere in the wilderness.");
|
player.getPacketDispatch().sendMessage("Ancient magic teleports you somewhere in the wilderness.");
|
||||||
int xDif = stationObelisk.getLocation().getX() - player.getLocation().getX();
|
int xOffset = player.getLocation().getX() - center.getX();
|
||||||
int yDif = stationObelisk.getLocation().getY() - player.getLocation().getY();
|
int yOffset = player.getLocation().getY() - center.getY();
|
||||||
if (xDif > 0 || yDif > 0) {
|
player.getTeleporter().send(Location.create(newObelisk.getLocation().getX() + xOffset, newObelisk.getLocation().getY() + yOffset, 0), TeleportType.OBELISK, 2);
|
||||||
player.getTeleporter().send(Location.create(newObelisk.getLocation().getX() - xDif, newObelisk.getLocation().getY() - yDif, 0), TeleportType.OBELISK, 2);
|
|
||||||
} else {
|
|
||||||
player.getTeleporter().send(Location.create(newObelisk.getLocation().getX() + xDif, newObelisk.getLocation().getY() + yDif, 0), TeleportType.OBELISK, 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
super.setDelay(1);
|
super.setDelay(1);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -756,6 +756,31 @@ object RegionManager {
|
|||||||
return players
|
return players
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of local players within a symmetric bounding box.
|
||||||
|
* @param l The location.
|
||||||
|
* @param xdist The distance from the location on the x plane that is considered within bounds.
|
||||||
|
* @param ydist The distance from the location on the y plane that is considered within bounds.
|
||||||
|
* @return The list of players.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun getLocalPlayersBoundingBox(l: Location, xdist: Int, ydist: Int): MutableList<Player> {
|
||||||
|
val players: MutableList<Player> = LinkedList()
|
||||||
|
for (regionX in ((l.regionX - 6) shr 3)..((l.regionX + 6) shr 3)) {
|
||||||
|
for (regionY in ((l.regionY - 6) shr 3)..((l.regionY + 6) shr 3)) {
|
||||||
|
for (player in forId((regionX shl 8) or regionY).planes[l.z].players) {
|
||||||
|
if (player.location.x >= l.getX() - xdist &&
|
||||||
|
player.location.x <= l.getX() + xdist &&
|
||||||
|
player.location.y >= l.getY() - ydist &&
|
||||||
|
player.location.y <= l.getY() + ydist) {
|
||||||
|
players.add(player)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return players
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of local players.
|
* Gets a list of local players.
|
||||||
* @param l The location.
|
* @param l The location.
|
||||||
|
|||||||
Reference in New Issue
Block a user