Repository reorganisation
Unified kotlin and java into just src/main Unified the rs09 and core packages Took all content out of the core package, and placed it into the new content package Reorganised all source code relating to content to be easier to find and explore
This commit is contained in:
@@ -0,0 +1,560 @@
|
||||
package content.global.skill.agility.pyramid;
|
||||
|
||||
import core.cache.def.impl.VarbitDefinition;
|
||||
import core.cache.def.impl.SceneryDefinition;
|
||||
import core.game.global.action.ClimbActionHandler;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import content.global.skill.agility.AgilityCourse;
|
||||
import content.global.skill.agility.AgilityHandler;
|
||||
import core.game.node.Node;
|
||||
import core.game.node.entity.impl.ForceMovement;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.GameWorld;
|
||||
import core.game.world.map.Direction;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.ClassScanner;
|
||||
|
||||
/**
|
||||
* Handles the agility pryamid course.
|
||||
* @author Vexia
|
||||
*/
|
||||
@Initializable
|
||||
public final class AgilityPyramidCourse extends AgilityCourse {
|
||||
|
||||
/**
|
||||
* The pyramid top item.
|
||||
*/
|
||||
private static final Item PYRAMID_TOP = new Item(6970);
|
||||
|
||||
/**
|
||||
* The config id to use.
|
||||
*/
|
||||
private static final int CONFIG_ID = 640;
|
||||
|
||||
/**
|
||||
* The jump gap location data.
|
||||
*/
|
||||
private static final Location[][] GAP_LOCATIONS = new Location[][] { { new Location(3356, 2847, 2), Location.create(3357, 2847, 2), Location.create(3356, 2846, 2), Location.create(3357, 2846, 2), Location.create(3356, 2849, 2), Location.create(3357, 2849, 2) }, { new Location(3364, 2833, 2), Location.create(3364, 2834, 2), Location.create(3366, 2834, 2), Location.create(3366, 2833, 2), Location.create(3363, 2834, 2), Location.create(3363, 2833, 2) }, { new Location(3370, 2841, 3), new Location(3371, 2841, 3), Location.create(3370, 2840, 3), Location.create(3371, 2840, 3), Location.create(3370, 2843, 3), Location.create(3371, 2843, 3) }, { new Location(3040, 4697, 2), Location.create(3041, 4697, 2), Location.create(3041, 4696, 2), Location.create(3040, 4696, 2), Location.create(3041, 4699, 2), Location.create(3040, 4699, 2) }, { new Location(3048, 4695, 2), Location.create(3049, 4695, 2), Location.create(3048, 4694, 2), Location.create(3049, 4694, 2), Location.create(3048, 4697, 2), Location.create(3049, 4697, 2) }, { Location.create(3046, 4697, 3), Location.create(3047, 4697, 3), Location.create(3046, 4696, 3), Location.create(3047, 4696, 3), Location.create(3046, 4699, 3), Location.create(3047, 4699, 3) } };
|
||||
|
||||
/**
|
||||
* The ledge crossing location data.
|
||||
*/
|
||||
private static final Location[][] LEDGE_LOCATIONS = new Location[][] { { new Location(3366, 2851, 1), new Location(3364, 2851, 1), Location.create(3368, 2851, 1), Location.create(3363, 2851, 1), Location.create(3367, 2851, 1), Location.create(3364, 2851, 1) }, { new Location(3362, 2831, 1), new Location(3360, 2831, 1), Location.create(3364, 2832, 1), Location.create(3359, 2832, 1), Location.create(3360, 2832, 1), Location.create(3363, 2832, 1) }, { new Location(3372, 2837, 2), new Location(3372, 2839, 2), Location.create(3372, 2841, 2), Location.create(3372, 2836, 2), Location.create(3372, 2837, 2), Location.create(3372, 2840, 2) }, { new Location(3358, 2843, 3), new Location(3358, 2845, 3), Location.create(3359, 2842, 3), Location.create(3359, 2847, 3), Location.create(3359, 2846, 3), Location.create(3359, 2843, 3) } };
|
||||
|
||||
/**
|
||||
* The gap crossing location data.
|
||||
*/
|
||||
private static final Location[][] GAP_CROSS_LOCATIONS = new Location[][] { { new Location(3368, 2831, 1), new Location(3370, 2831, 1), Location.create(3372, 2832, 1), Location.create(3367, 2832, 1), Location.create(3371, 2832, 1), Location.create(3368, 2832, 1) }, { new Location(3356, 2837, 2), new Location(3356, 2839, 2), Location.create(3357, 2841, 2), Location.create(3357, 2836, 2), Location.create(3357, 2840, 2), Location.create(3357, 2837, 2) }, { new Location(3360, 2849, 2), new Location(3362, 2849, 2), Location.create(3359, 2849, 2), Location.create(3364, 2849, 2), Location.create(3363, 2849, 2), Location.create(3360, 2849, 2) } };
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AgilityPyramidCourse} {@code Object}.
|
||||
*/
|
||||
public AgilityPyramidCourse() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AgilityPyramidCourse} {@code Object}.
|
||||
* @param player the player.
|
||||
*/
|
||||
public AgilityPyramidCourse(Player player) {
|
||||
super(player, 5, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure() {
|
||||
SceneryDefinition.forId(16535).getHandlers().put("option:climb", this);
|
||||
SceneryDefinition.forId(16536).getHandlers().put("option:climb", this);
|
||||
SceneryDefinition.forId(10851).getHandlers().put("option:climb", this);
|
||||
SceneryDefinition.forId(10855).getHandlers().put("option:enter", this);
|
||||
SceneryDefinition.forId(10856).getHandlers().put("option:enter", this);
|
||||
SceneryDefinition.forId(10860).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10861).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10862).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10863).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10864).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10868).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10867).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10882).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10883).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10884).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10885).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10886).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10887).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10888).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10889).getHandlers().put("option:cross", this);
|
||||
SceneryDefinition.forId(10859).getHandlers().put("option:jump", this);
|
||||
SceneryDefinition.forId(10857).getHandlers().put("option:climb-up", this);
|
||||
SceneryDefinition.forId(10858).getHandlers().put("option:climb-down", this);
|
||||
SceneryDefinition.forId(10865).getHandlers().put("option:climb-over", this);
|
||||
RollingBlock.BlockSets.values();
|
||||
ClassScanner.definePlugin(new MovingBlockNPC());
|
||||
ClassScanner.definePlugin(new AgilityPyramidZone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final Player player, Node node, String option) {
|
||||
getCourse(player); // Sets the extension.
|
||||
final Scenery object = (Scenery) node;
|
||||
if (object.getLocation().getDistance(player.getLocation()) >= 3) {
|
||||
player.getPacketDispatch().sendMessage("I can't reach that!");
|
||||
return true;
|
||||
}
|
||||
switch (object.getId()) {
|
||||
case 16535:
|
||||
case 16536:
|
||||
handleRockClimb(player, object);
|
||||
break;
|
||||
case 10865:
|
||||
handleLowWall(player, object);
|
||||
break;
|
||||
case 10888:
|
||||
case 10889:
|
||||
case 10860:
|
||||
case 10886:
|
||||
case 10887:
|
||||
handleLedge(player, object);
|
||||
break;
|
||||
case 10868:
|
||||
case 10867:
|
||||
handlePlank(player, object);
|
||||
break;
|
||||
case 10882:
|
||||
case 10883:
|
||||
case 10884:
|
||||
case 10885:
|
||||
case 10861:
|
||||
case 10862:
|
||||
case 10863:
|
||||
case 10864:
|
||||
handleGapCross(player, object);
|
||||
break;
|
||||
case 10857:
|
||||
case 10858:
|
||||
handleStairs(player, object);
|
||||
break;
|
||||
case 10851:
|
||||
handlePyramidTop(player, object);
|
||||
break;
|
||||
case 10859:
|
||||
handleJumpGap(player, object);
|
||||
break;
|
||||
case 10855:
|
||||
case 10856:
|
||||
addConfig(player, 10869, 0, true);
|
||||
if (player.getConfigManager().get(640) == 505 || player.getConfigManager().get(640) == 515) {
|
||||
player.getSkills().addExperience(Skills.AGILITY, 300, true);
|
||||
}
|
||||
player.getDialogueInterpreter().sendDialogue("You climb down the steep passage. It leads to the base of the", "pyramid.");
|
||||
player.getProperties().setTeleportLocation(Location.create(3364, 2830, 0));
|
||||
player.getSavedData().getActivityData().setTopGrabbed(false);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the stairs.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handleStairs(final Player player, final Scenery object) {
|
||||
Direction dir = Direction.getLogicalDirection(player.getLocation(), object.getLocation());
|
||||
Location dest = null;
|
||||
if (dir == Direction.NORTH) {
|
||||
dest = object.getLocation().transform(0, 2, 1);
|
||||
} else if (dir == Direction.SOUTH) {
|
||||
dest = object.getLocation().transform(0, -1, -1);
|
||||
}
|
||||
if (object.getLocation().equals(Location.create(3360, 2837, 3))) {
|
||||
dest = Location.create(3040, 4695, 2);
|
||||
} else if (object.getLocation().equals(Location.create(3040, 4693, 2))) {
|
||||
dest = Location.create(3360, 2836, 3);
|
||||
} else if (object.getLocation().equals(new Location(3354, 2831, 0))) {
|
||||
addConfig(player, 10869, 0, true);
|
||||
}
|
||||
ClimbActionHandler.climb(player, null, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the rock climbing obstacle.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handleRockClimb(final Player player, final Scenery object) {
|
||||
final boolean scale = player.getLocation().getX() < object.getLocation().getX();
|
||||
final Location end = object.getLocation().transform(scale ? 2 : -2, 0, 0);
|
||||
if (object.getId() == 16536 && player.getSkills().getStaticLevel(Skills.AGILITY) < 30) {
|
||||
player.getPacketDispatch().sendMessage("You must be level 30 agility or higher to climb down the rocks.");
|
||||
return;
|
||||
}
|
||||
if (!scale) {
|
||||
ForceMovement.run(player, player.getLocation(), end, Animation.create(740), Animation.create(740), Direction.WEST, 13).setEndAnimation(Animation.RESET);
|
||||
} else {
|
||||
ForceMovement.run(player, player.getLocation(), end, Animation.create(1148), Animation.create(1148), Direction.WEST, 13).setEndAnimation(Animation.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the low wall obstacle.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handleLowWall(final Player player, final Scenery object) {
|
||||
Direction d = Direction.getDirection(player.getLocation(), object.getLocation());
|
||||
final boolean fail = player.getSkills().getLevel(Skills.AGILITY) >= 75 ? false : hasFailed(player) ;
|
||||
if (player.getLocation().equals(Location.create(3355, 2848, 1)) || player.getLocation().equals(Location.create(3359, 2838, 3))) {
|
||||
d = Direction.NORTH;
|
||||
} else if (player.getLocation().equals(Location.create(3355, 2850, 1)) || player.getLocation().equals(Location.create(3359, 2840, 3))) {
|
||||
d = Direction.SOUTH;
|
||||
} else if (player.getLocation().equals(Location.create(3046, 4694, 2)) || player.getLocation().equals(Location.create(3355, 2850, 1)) || player.getLocation().equals(Location.create(3041, 4702, 2)) || player.getLocation().equals(new Location(3369, 2834, 2))) {
|
||||
d = Direction.EAST;
|
||||
} else if (player.getLocation().equals(Location.create(3048, 4694, 2)) || player.getLocation().equals(Location.create(3371, 2834, 2)) || player.getLocation().equals(Location.create(3043, 4702, 2))) {
|
||||
d = Direction.WEST;
|
||||
}
|
||||
player.lock(4);
|
||||
player.getPacketDispatch().sendMessage("You climb the low wall...");
|
||||
if (fail) {
|
||||
Location end = player.getLocation().transform(d, 1);
|
||||
player.lock(3);
|
||||
AgilityHandler.failWalk(player, 2, player.getLocation(), end, end, Animation.create(1106), 15, getHitAmount(player), "You lost your balance!");
|
||||
AgilityHandler.forceWalk(player, -1, end, player.getLocation(), ForceMovement.WALK_ANIMATION, 10, 0.0, null, 4);
|
||||
return;
|
||||
}
|
||||
AgilityHandler.forceWalk(player, 0, player.getLocation(), player.getLocation().transform(d, 2), Animation.create(1252), 6, 8, "... and make it over.");
|
||||
player.animate(Animation.RESET, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the ledge crossing obstacle.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handleLedge(final Player player, final Scenery object) {
|
||||
Direction d = Direction.getLogicalDirection(player.getLocation(), getLedgeLocation(player, object));
|
||||
final Direction dir = d;
|
||||
final int diff = object.getRotation() == 3 && dir == Direction.EAST ? 1 : object.getRotation() == 3 && dir == Direction.WEST ? 0 : d == Direction.EAST || (d == Direction.SOUTH && object.getRotation() != 0) || d == Direction.NORTH ? 0 : 1;
|
||||
final boolean fail = player.getSkills().getLevel(Skills.AGILITY) < 75 && hasFailed(player);
|
||||
final Location end = player.getLocation().transform(dir.getStepX() * (fail ? 3 : 5), dir.getStepY() * (fail ? 3 : 5), 0);
|
||||
player.getPacketDispatch().sendMessage("You put your foot on the ledge and try to edge across...");
|
||||
if (fail) {
|
||||
player.lock(4);
|
||||
AgilityHandler.walk(player, -1, player.getLocation(), end, Animation.create(157 - diff), 0.0, "You slip and fall to the level below.");
|
||||
GameWorld.getPulser().submit(new Pulse(3, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
Location dest = end;
|
||||
int x = 0, y = 0;
|
||||
switch (dir) {
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
if (object.getRotation() == 2) {
|
||||
x = 2;
|
||||
} else {
|
||||
x = -2;
|
||||
}
|
||||
break;
|
||||
case WEST:
|
||||
case EAST:
|
||||
if (object.getRotation() == 3) {
|
||||
y = -2;
|
||||
} else if (object.getRotation() == 1) {
|
||||
y = 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
AgilityHandler.fail(player, 1, transformLevel(dest.transform(x, y, 0)), Animation.create(761 - diff), 10, null);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
AgilityHandler.walk(player, 3, player.getLocation(), end, Animation.create(157 - diff), 52, "You skillfully edge across the gap.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the plank crossin obstacle.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handlePlank(final Player player, final Scenery object) {
|
||||
final boolean custom = object.getLocation().equals(new Location(3365, 2835, 3)) || object.getLocation().equals(new Location(3370, 2835, 3));
|
||||
final Direction dir = custom ? Direction.EAST : Direction.getLogicalDirection(player.getLocation(), object.getLocation());
|
||||
final boolean fail = player.getSkills().getLevel(Skills.AGILITY) >= 75 ? false : hasFailed(player) ;
|
||||
final Location end = object.getLocation().transform(object.getId() != 10868 ? dir : dir.getOpposite(), fail ? 2 : 5);
|
||||
AgilityHandler.walk(player, fail ? -1 : 1, player.getLocation(), end, Animation.create(155), fail ? 0.0 : 56.4, fail ? null : "You walk carefully across the slippery plank...");
|
||||
if (fail) {
|
||||
GameWorld.getPulser().submit(new Pulse(2, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
final Location dest = transformLevel(end.transform(!custom ? 2 : 0, custom ? -2 : 0, 0));
|
||||
AgilityHandler.failWalk(player, 2, end, dest, dest, Animation.create(764), 10, 10, null);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the gab crossing obstacle.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handleJumpGap(Player player, Scenery object) {
|
||||
final Direction dir = Direction.getDirection(player.getLocation(), getGapLocation(player, object));
|
||||
final boolean fail = player.getSkills().getLevel(Skills.AGILITY) >= 75 ? false : hasFailed(player) ;
|
||||
player.getPacketDispatch().sendMessage("You jump the gap...");
|
||||
if (fail) {
|
||||
final boolean regular = object.getRotation() == 0 || object.getRotation() == 3;
|
||||
Location end = player.getLocation().transform(dir, 1);
|
||||
Location dest = object.getLocation().transform(dir, 1);
|
||||
if (!regular) {
|
||||
dest = dest.transform(dir == Direction.NORTH || dir == Direction.SOUTH ? 2 : 0, dir == Direction.SOUTH ? 1 : 0, 0);
|
||||
} else {
|
||||
dest = dest.transform(dir == Direction.NORTH || dir == Direction.SOUTH ? -1 : dir == Direction.WEST ? 1 : 0, dir == Direction.SOUTH ? 1 : dir == Direction.WEST || dir == Direction.EAST ? -1 : 0, 0);
|
||||
}
|
||||
dest = transformLevel(dest);
|
||||
player.lock(8);
|
||||
AgilityHandler.forceWalk(player, -1, player.getLocation(), end, Animation.create(3068), 10, 0.0, "... and miss your footing.");
|
||||
AgilityHandler.fail(player, 8, dest, null, 8, null);
|
||||
return;
|
||||
}
|
||||
player.lock(4);
|
||||
AgilityHandler.forceWalk(player, 2, player.getLocation(), player.getLocation().transform(dir, 3), Animation.create(3067), 20, 22, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the gap cross obstacle.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handleGapCross(final Player player, final Scenery object) {
|
||||
final Direction dir = Direction.getLogicalDirection(player.getLocation(), getGapCrossLocation(player, object));
|
||||
final boolean fail = player.getSkills().getLevel(Skills.AGILITY) >= 75 ? false : hasFailed(player) ;
|
||||
final Location end = player.getLocation().transform(dir, fail ? 4 : 5);
|
||||
final int rot = object.getRotation();
|
||||
int mod = player.getLocation().equals(new Location(3359, 2849, 2)) ? 0 : player.getLocation().equals(new Location(3357, 2841, 2)) ? 1 : player.getLocation().equals(new Location(3367, 2832, 1)) ? 1 : player.getLocation().equals(new Location(3372, 2832, 1)) ? 0 : object.getLocation().equals(new Location(3370, 2831, 1)) ? 0 : rot == 1 && dir == Direction.EAST ? 0 : rot == 3 && (dir == Direction.WEST || dir == Direction.EAST) ? 1 : rot == 0 && dir == Direction.SOUTH ? 1 : dir == Direction.WEST && rot != 3 || dir == Direction.EAST ? 1 : 0;
|
||||
final Animation animation = Animation.create(387 - mod);
|
||||
if (fail) {
|
||||
Location dest = object.getLocation().transform(dir, 1);
|
||||
dest = rot == 1 && dir == Direction.EAST ? dest.transform(1, 2, 0) : rot == 1 && dir == Direction.WEST ? dest.transform(0, -2, 0) : dest.transform(dir == Direction.NORTH || dir == Direction.SOUTH ? -1 : dir == Direction.WEST ? 1 : 0, dir == Direction.SOUTH ? 1 : dir == Direction.WEST || dir == Direction.EAST ? -1 : 0, 0);
|
||||
AgilityHandler.walk(player, -1, player.getLocation(), end, animation, 10, null);
|
||||
AgilityHandler.fail(player, 3, transformLevel(dest), null, 8, null);
|
||||
// player.animate(Animation.create(3056 - mod), 2);
|
||||
GameWorld.getPulser().submit(new Pulse(3, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
player.getAppearance().setDefaultAnimations();
|
||||
player.getAppearance().sync();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
AgilityHandler.walk(player, 4, player.getLocation(), end, animation, 22, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the pyramid top obstacle.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
*/
|
||||
private void handlePyramidTop(final Player player, final Scenery object) {
|
||||
if(player.getSavedData().getActivityData().isTopGrabbed() == true){
|
||||
player.getPacketDispatch().sendMessage("You've already claimed this!");
|
||||
return;
|
||||
} else {
|
||||
player.animate(Animation.create(3063));
|
||||
GameWorld.getPulser().submit(new Pulse(3, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
player.getSkills().addExperience(Skills.AGILITY, 1000);
|
||||
if (player.getConfigManager().get(640) == 505 || player.getConfigManager().get(640) == 515) {
|
||||
player.getPacketDispatch().sendMessage("You find nothing on top of the pyramid.");
|
||||
return true;
|
||||
}
|
||||
addConfig(player, 10869, 1, true);
|
||||
player.getSavedData().getActivityData().setTopGrabbed(true);
|
||||
player.getInventory().add(PYRAMID_TOP, player);
|
||||
player.getDialogueInterpreter().sendItemMessage(PYRAMID_TOP, "You find a golden pyramid!");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a pyramid level.
|
||||
* @param location the location.
|
||||
* @return the location.
|
||||
*/
|
||||
public static Location transformLevel(Location location) {
|
||||
int xDiff = 320;
|
||||
int yDiff = 1856;
|
||||
if (location.getRegionId() == 12105 && location.getZ() == 2) {
|
||||
return new Location(location.getX() + xDiff, location.getY() - yDiff, 3);
|
||||
}
|
||||
return location.transform(0, 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gap location.
|
||||
* @param player the player.
|
||||
* @param object the obejct.
|
||||
* @return the location.
|
||||
*/
|
||||
private Location getGapLocation(Player player, Scenery object) {
|
||||
final Location[] data = getLocationData(GAP_LOCATIONS, object.getLocation());
|
||||
return getClosest(new Location[] { data[0], data[1] }, player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gap cross location.
|
||||
* @param player the player.
|
||||
* @param object the obejct.
|
||||
* @return the location.
|
||||
*/
|
||||
private Location getGapCrossLocation(Player player, Scenery object) {
|
||||
final Location[] data = getLocationData(GAP_CROSS_LOCATIONS, object.getLocation());
|
||||
return getClosest(new Location[] { data[4], data[5] }, player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ledge location.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
* @return the location.
|
||||
*/
|
||||
private Location getLedgeLocation(final Player player, final Scenery object) {
|
||||
final Location[] data = getLocationData(LEDGE_LOCATIONS, object.getLocation());
|
||||
return getClosest(new Location[] { data[4], data[5] }, player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the closest location.
|
||||
* @param data the data.
|
||||
* @param location the location.
|
||||
* @return the closest location.
|
||||
*/
|
||||
private Location getClosest(Location[] data, Location location) {
|
||||
Location closest = null;
|
||||
for (Location l : data) {
|
||||
if (closest == null || l.getDistance(location) < closest.getDistance(location)) {
|
||||
closest = l;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location data.
|
||||
* @param data the data.
|
||||
* @param location the location.
|
||||
* @return the data.
|
||||
*/
|
||||
private Location[] getLocationData(Location[][] data, Location location) {
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
for (Location l : data[i]) {
|
||||
if (l.equals(location)) {
|
||||
return data[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has failed.
|
||||
* @param player the player.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
private boolean hasFailed(final Player player) {
|
||||
return hasFailed(player, 0.009000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has failed.
|
||||
* @param player the player.
|
||||
* @param mod the mod.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
private boolean hasFailed(final Player player, double mod) {
|
||||
return AgilityHandler.hasFailed(player, 10, mod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the config id.
|
||||
* @param player the player.
|
||||
* @param objectId the object.
|
||||
* @param value the value.
|
||||
*/
|
||||
public static void addConfig(final Player player, final int objectId, final int value, boolean save) {
|
||||
final VarbitDefinition definition = VarbitDefinition.forObjectID(SceneryDefinition.forId(objectId).getVarbitID());
|
||||
final int oldVal = (definition.getValue(player) << definition.getStartBit());
|
||||
final int newVal = (value << definition.getStartBit());
|
||||
player.getConfigManager().set(CONFIG_ID, (player.getConfigManager().get(CONFIG_ID) - oldVal) + newVal, save);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the config id.
|
||||
* @param player the player.
|
||||
* @param object the object.
|
||||
* @param value the value.
|
||||
* @param save if we save.
|
||||
*/
|
||||
public static void addConfig(final Player player, final Scenery object, final int value, boolean save) {
|
||||
addConfig(player, object.getId(), value, save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getDestination(Node node, Node n) {
|
||||
switch (n.getId()) {
|
||||
case 16535:
|
||||
case 16536:
|
||||
return n.getLocation().transform(node.getLocation().getX() < n.getLocation().getX() ? -1 : 1, 0, 0);
|
||||
case 10865:
|
||||
return null;
|
||||
case 10857:
|
||||
return n.getLocation().transform(0, -1, 0);
|
||||
case 10858:
|
||||
return n.getLocation().transform(0, 2, 0);
|
||||
case 10859:
|
||||
return getClosest(getLocationData(GAP_LOCATIONS, n.getLocation()), node.getLocation());
|
||||
case 10860:
|
||||
case 10886:
|
||||
case 10887:
|
||||
case 10888:
|
||||
case 10889:
|
||||
return getClosest(getLocationData(LEDGE_LOCATIONS, n.getLocation()), node.getLocation());
|
||||
case 10868:
|
||||
case 10867:
|
||||
return n.getLocation();
|
||||
case 10882:
|
||||
case 10883:
|
||||
case 10884:
|
||||
case 10885:
|
||||
case 10861:
|
||||
case 10862:
|
||||
case 10863:
|
||||
case 10864:
|
||||
if (n.getId() == 10863 && n.getLocation().equals(new Location(3372, 2832, 1))) {
|
||||
return Location.create(3372, 2832, 1);
|
||||
}
|
||||
return getClosest(getLocationData(GAP_CROSS_LOCATIONS, n.getLocation()), node.getLocation());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgilityCourse createInstance(Player player) {
|
||||
return new AgilityPyramidCourse(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package content.global.skill.agility.pyramid;
|
||||
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.system.task.MovementHook;
|
||||
import core.game.world.map.Direction;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.zone.MapZone;
|
||||
import core.game.world.map.zone.ZoneBorders;
|
||||
import core.game.world.map.zone.ZoneBuilder;
|
||||
import core.plugin.Plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the agility pyramid area.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public final class AgilityPyramidZone extends MapZone implements Plugin<Object> {
|
||||
|
||||
/**
|
||||
* The location based traps.
|
||||
*/
|
||||
public static final Map<Location, MovementHook> LOCATION_TRAPS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AgilityPyramid} {@code Object}.
|
||||
*/
|
||||
public AgilityPyramidZone() {
|
||||
super("agility pyramid", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ZoneBuilder.configure(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enter(Entity e) {
|
||||
if (e instanceof Player) {
|
||||
final Player player = (Player) e;
|
||||
AgilityPyramidCourse.addConfig(player, 10872, 1, true);
|
||||
AgilityPyramidCourse.addConfig(player, 10873, 3, true);
|
||||
}
|
||||
return super.enter(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean move(Entity e, Location loc, Location dest) {
|
||||
if (!e.getLocks().isMovementLocked() && e instanceof Player) {
|
||||
MovementHook hook = LOCATION_TRAPS.get(loc);
|
||||
if (hook != null) {
|
||||
e.setDirection(Direction.getLogicalDirection(loc, dest));
|
||||
return hook.handle(e, loc);
|
||||
}
|
||||
}
|
||||
return super.move(e, loc, dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fireEvent(String identifier, Object... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure() {
|
||||
register(new ZoneBorders(3352, 2826, 3378, 2854));
|
||||
register(new ZoneBorders(3007, 4672, 3071, 4735));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package content.global.skill.agility.pyramid;
|
||||
|
||||
import content.global.skill.agility.AgilityHandler;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.npc.AbstractNPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.system.task.MovementHook;
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.GameWorld;
|
||||
import core.game.world.map.Direction;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* The moving block npc.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public final class MovingBlockNPC extends AbstractNPC {
|
||||
|
||||
/**
|
||||
* The tile locations.
|
||||
*/
|
||||
private static final Location[][] LOCATIONS = new Location[][] { { Location.create(3366, 2847, 3), Location.create(3367, 2847, 3), Location.create(3367, 2848, 3), Location.create(3366, 2848, 3), Location.create(3365, 2847, 3), Location.create(3365, 2848, 3), Location.create(3368, 2847, 3), Location.create(3368, 2848, 3) }, { Location.create(3374, 2847, 1), Location.create(3374, 2848, 1), Location.create(3375, 2848, 1), Location.create(3375, 2847, 1), Location.create(3374, 2849, 1), Location.create(3375, 2849, 1), Location.create(3374, 2846, 1), Location.create(3375, 2846, 1) } };
|
||||
|
||||
/**
|
||||
* The next move delay.
|
||||
*/
|
||||
private int nextMove;
|
||||
|
||||
/**
|
||||
* If its moving.
|
||||
*/
|
||||
private boolean moving;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MovingBlockNPC} {@code Object}.
|
||||
*/
|
||||
public MovingBlockNPC() {
|
||||
super(-1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MovingBlockNPC} {@code Object}.
|
||||
* @param id the id.
|
||||
* @param location the location.
|
||||
*/
|
||||
public MovingBlockNPC(int id, Location location) {
|
||||
super(id, location, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (nextMove < GameWorld.getTicks() && nextMove != -1) {
|
||||
Direction dir = getId() == 3124 ? Direction.EAST : Direction.NORTH;
|
||||
Location loc = getLocation().transform(dir, 2);
|
||||
getWalkingQueue().reset();
|
||||
getWalkingQueue().addPath(loc.getX(), loc.getY());
|
||||
for (Player p : RegionManager.getLocalPlayers(getTileLocations()[0], 2)) {
|
||||
checkBlock(p);
|
||||
}
|
||||
moving = true;
|
||||
GameWorld.getPulser().submit(new Pulse(1, this) {
|
||||
int counter;
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
switch (++counter) {
|
||||
case 1:
|
||||
for (Player p : RegionManager.getLocalPlayers(getTileLocations()[0], 2)) {
|
||||
checkBlock(p);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
getWalkingQueue().reset();
|
||||
getWalkingQueue().addPath(getProperties().getSpawnLocation().getX(), getProperties().getSpawnLocation().getY());
|
||||
nextMove = GameWorld.getTicks() + 13;
|
||||
break;
|
||||
case 5:
|
||||
moving = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
nextMove = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
final MovingBlockTrap trap = new MovingBlockTrap();
|
||||
for (Location l : getTileLocations()) {
|
||||
AgilityPyramidZone.LOCATION_TRAPS.put(l, trap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractNPC construct(int id, Location location, Object... objects) {
|
||||
return new MovingBlockNPC(id, location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is going to get hit by a block.
|
||||
* @param player the player.
|
||||
*/
|
||||
public void checkBlock(final Player player) {
|
||||
if (player.getAttribute("block-move", -1) > GameWorld.getTicks()) {
|
||||
return;
|
||||
}
|
||||
Location[] locs = getTileLocations();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (locs[i].equals(player.getLocation())) {
|
||||
GameWorld.getPulser().submit(new Pulse(1, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
boolean close = getProperties().getSpawnLocation().getDistance(player.getLocation()) > (getId() == 3124 ? 2 : 2.3);
|
||||
Location dest = null;
|
||||
if (getId() == 3124) {
|
||||
if (player.getLocation().getY() == 2847) {
|
||||
dest = Location.create(3376, 2847, 1);
|
||||
} else if (player.getLocation().getY() == 2848) {
|
||||
dest = Location.create(3376, 2848, 1);
|
||||
}
|
||||
} else {
|
||||
if (player.getLocation().getX() == 3366) {
|
||||
dest = Location.create(3366, 2849, 3);
|
||||
} else if (player.getLocation().getX() == 3367) {
|
||||
dest = Location.create(3367, 2849, 3);
|
||||
}
|
||||
}
|
||||
player.lock(4);
|
||||
player.setAttribute("block-move", GameWorld.getTicks() + 4);
|
||||
if(dest != null) {
|
||||
AgilityHandler.failWalk(player, close ? 1 : 3, player.getLocation(), dest, AgilityPyramidCourse.transformLevel(dest), Animation.create(3066), 10, 8, null, getId() == 3124 ? Direction.WEST : Direction.SOUTH);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tile locations.
|
||||
* @return the locations.
|
||||
*/
|
||||
public Location[] getTileLocations() {
|
||||
return LOCATIONS[3125 - getId()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 3124, 3125 };
|
||||
}
|
||||
|
||||
/**
|
||||
* The movement hook to handle a moving block.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public final class MovingBlockTrap implements MovementHook {
|
||||
|
||||
@Override
|
||||
public boolean handle(Entity e, Location l) {
|
||||
if (moving) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package content.global.skill.agility.pyramid;
|
||||
|
||||
import content.global.skill.agility.AgilityHandler;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.system.task.MovementHook;
|
||||
import core.game.system.task.Pulse;
|
||||
import kotlin.Unit;
|
||||
import core.game.world.GameWorld;
|
||||
import core.game.world.map.Direction;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
|
||||
/**
|
||||
* Represents the rolling block obstacle.
|
||||
* @author 'Vexia
|
||||
* @version 1.0
|
||||
*/
|
||||
public final class RollingBlock implements MovementHook {
|
||||
|
||||
@Override
|
||||
public boolean handle(final Entity e, final Location dest) {
|
||||
final Player player = (Player) e;
|
||||
final BlockSets set = BlockSets.forLocation(dest);
|
||||
final Scenery stone = RegionManager.getObject(set.getBlockLocation());
|
||||
final boolean backwards = isBackwards(stone.getDirection(), player.getDirection(), stone.getRotation());
|
||||
final boolean fail = backwards || AgilityHandler.hasFailed(player, 2, 0.3);
|
||||
player.lock(5);
|
||||
AgilityPyramidCourse.addConfig(player, stone, 1, false);
|
||||
if(e.isPlayer())
|
||||
{
|
||||
((Player) e).logoutListeners.put("rolling-block", p -> {
|
||||
p.setLocation(e.getLocation().transform(0,0,0));
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
if (fail) {
|
||||
GameWorld.getPulser().submit(new Pulse(1, player) {
|
||||
int counter;
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
switch (++counter) {
|
||||
case 1:
|
||||
final Location end = player.getLocation().transform(stone.getDirection(), -2);
|
||||
final int hit = backwards ? 1 : 6;
|
||||
if (set == BlockSets.FOUR) {
|
||||
AgilityHandler.failWalk(player, 3, dest, end, AgilityPyramidCourse.transformLevel(end), Animation.create(1116), 10, hit, null);
|
||||
} else {
|
||||
AgilityHandler.failWalk(player, -1, dest, AgilityPyramidCourse.transformLevel(end), AgilityPyramidCourse.transformLevel(end), Animation.create(1116), 10, hit, null);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
AgilityPyramidCourse.addConfig(player, stone, 0, true);
|
||||
player.logoutListeners.remove("rolling-block");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
AgilityHandler.forceWalk(player, -1, dest, dest.transform(player.getDirection(), 2), Animation.create(1115), 20, 12, null);
|
||||
GameWorld.getPulser().submit(new Pulse(3, player) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
AgilityPyramidCourse.addConfig(player, stone, 0, true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player is going backwards.
|
||||
* @param direction the object dir.
|
||||
* @param dir the player dir.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public boolean isBackwards(Direction direction, Direction dir, int rot) {
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
return rot == 2 & dir == Direction.WEST;
|
||||
case EAST:
|
||||
return rot == 1 && dir == Direction.SOUTH;
|
||||
case WEST:
|
||||
return rot == 3 && dir == Direction.NORTH;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A block set.
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public enum BlockSets {
|
||||
ONE(Location.create(3354, 2841, 0), Location.create(3354, 2842, 1), Location.create(3355, 2842, 1), Location.create(3355, 2841, 1), Location.create(3354, 2841, 1)), TWO(Location.create(3374, 2835, 0), Location.create(3374, 2835, 1), Location.create(3374, 2836, 1), Location.create(3375, 2836, 1), Location.create(3375, 2835, 1)), THREE(Location.create(3368, 2849, 1), Location.create(3368, 2849, 2), Location.create(3369, 2849, 2), Location.create(3369, 2850, 2), Location.create(3368, 2850, 2)), FOUR(Location.create(3048, 4699, 1), Location.create(3048, 4700, 2), Location.create(3049, 4700, 2), Location.create(3049, 4699, 2), Location.create(3048, 4699, 2)), FIVE(Location.create(3044, 4699, 2), Location.create(3044, 4700, 3), Location.create(3045, 4700, 3), Location.create(3045, 4699, 3), Location.create(3044, 4699, 3));
|
||||
|
||||
/**
|
||||
* The block location.
|
||||
*/
|
||||
private final Location blockLocation;
|
||||
|
||||
/**
|
||||
* The tile locations.
|
||||
*/
|
||||
private final Location[] tiles;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BlockSets} {@code Object}.
|
||||
* @param blockLocation the block location.
|
||||
* @param tiles the tiles.
|
||||
*/
|
||||
private BlockSets(Location blockLocation, Location... tiles) {
|
||||
this.blockLocation = blockLocation;
|
||||
this.tiles = tiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set for the location.
|
||||
* @param location the location.
|
||||
* @return the block sets.
|
||||
*/
|
||||
public static BlockSets forLocation(Location location) {
|
||||
for (BlockSets set : values()) {
|
||||
for (Location loc : set.getTiles()) {
|
||||
if (loc.equals(location)) {
|
||||
return set;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the blockLocation.
|
||||
* @return The blockLocation.
|
||||
*/
|
||||
public Location getBlockLocation() {
|
||||
return blockLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tiles.
|
||||
* @return The tiles.
|
||||
*/
|
||||
public Location[] getTiles() {
|
||||
return tiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* static-block to load block traps.
|
||||
*/
|
||||
static {
|
||||
final RollingBlock block = new RollingBlock();
|
||||
for (BlockSets set : values()) {
|
||||
for (Location l : set.getTiles()) {
|
||||
AgilityPyramidZone.LOCATION_TRAPS.put(l, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user