mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-23 19:35:10 -06:00
Restore incorrect spaces to tabs to facilitate review
This commit is contained in:
parent
08b5e4cb8e
commit
b0445b8750
11 changed files with 4249 additions and 4249 deletions
|
|
@ -21,127 +21,127 @@ import java.util.Objects;
|
|||
@Initializable
|
||||
public final class SoftclayPlugin extends UseWithHandler {
|
||||
|
||||
/**
|
||||
* Represents the clay item.
|
||||
*/
|
||||
private static final Item CLAY = new Item(Items.CLAY_434);
|
||||
/**
|
||||
* Represents the clay item.
|
||||
*/
|
||||
private static final Item CLAY = new Item(Items.CLAY_434);
|
||||
|
||||
/**
|
||||
* Represents the soft clay item.
|
||||
*/
|
||||
private static final Item SOFT_CLAY = new Item(Items.SOFT_CLAY_1761);
|
||||
/**
|
||||
* Represents the soft clay item.
|
||||
*/
|
||||
private static final Item SOFT_CLAY = new Item(Items.SOFT_CLAY_1761);
|
||||
|
||||
/**
|
||||
* Represents the bowl of water item.
|
||||
*/
|
||||
private static final Item BOWL_OF_WATER = new Item(Items.BOWL_OF_WATER_1921);
|
||||
/**
|
||||
* Represents the bowl of water item.
|
||||
*/
|
||||
private static final Item BOWL_OF_WATER = new Item(Items.BOWL_OF_WATER_1921);
|
||||
|
||||
/**
|
||||
* Represents the empty bowl item.
|
||||
*/
|
||||
private static final Item BOWL = new Item(Items.BOWL_1923);
|
||||
/**
|
||||
* Represents the empty bowl item.
|
||||
*/
|
||||
private static final Item BOWL = new Item(Items.BOWL_1923);
|
||||
|
||||
/**
|
||||
* Represents the empty bucket item.
|
||||
*/
|
||||
private static final Item BUCKET = new Item(Items.BUCKET_1925);
|
||||
/**
|
||||
* Represents the empty bucket item.
|
||||
*/
|
||||
private static final Item BUCKET = new Item(Items.BUCKET_1925);
|
||||
|
||||
/**
|
||||
* Represents the bucket of water item.
|
||||
*/
|
||||
private static final Item BUCKET_OF_WATER = new Item(Items.BUCKET_OF_WATER_1929);
|
||||
/**
|
||||
* Represents the bucket of water item.
|
||||
*/
|
||||
private static final Item BUCKET_OF_WATER = new Item(Items.BUCKET_OF_WATER_1929);
|
||||
|
||||
/**
|
||||
* Represents the jug item.
|
||||
*/
|
||||
private static final Item JUG = new Item(Items.JUG_1935);
|
||||
/**
|
||||
* Represents the jug item.
|
||||
*/
|
||||
private static final Item JUG = new Item(Items.JUG_1935);
|
||||
|
||||
/**
|
||||
* Represents the jug of water item.
|
||||
*/
|
||||
private static final Item JUG_OF_WATER = new Item(Items.JUG_OF_WATER_1937);
|
||||
/**
|
||||
* Represents the jug of water item.
|
||||
*/
|
||||
private static final Item JUG_OF_WATER = new Item(Items.JUG_OF_WATER_1937);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SoftclayPlugin} {@code Object}.
|
||||
*/
|
||||
public SoftclayPlugin() {
|
||||
super(434);
|
||||
}
|
||||
/**
|
||||
* Constructs a new {@code SoftclayPlugin} {@code Object}.
|
||||
*/
|
||||
public SoftclayPlugin() {
|
||||
super(434);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(1921, ITEM_TYPE, this);
|
||||
addHandler(1929, ITEM_TYPE, this);
|
||||
addHandler(1937, ITEM_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
addHandler(1921, ITEM_TYPE, this);
|
||||
addHandler(1929, ITEM_TYPE, this);
|
||||
addHandler(1937, ITEM_TYPE, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(final NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, SOFT_CLAY) {
|
||||
@Override
|
||||
public void create(final int amount, int index) {
|
||||
player.getPulseManager().run(new Pulse(2, player) {
|
||||
int count;
|
||||
@Override
|
||||
public boolean handle(final NodeUsageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
SkillDialogueHandler handler = new SkillDialogueHandler(player, SkillDialogue.ONE_OPTION, SOFT_CLAY) {
|
||||
@Override
|
||||
public void create(final int amount, int index) {
|
||||
player.getPulseManager().run(new Pulse(2, player) {
|
||||
int count;
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (!SoftclayPlugin.this.create(player, event)) {
|
||||
return true;
|
||||
}
|
||||
return ++count >= amount;
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (!SoftclayPlugin.this.create(player, event)) {
|
||||
return true;
|
||||
}
|
||||
return ++count >= amount;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAll(int index) {
|
||||
return player.getInventory().getAmount(CLAY);
|
||||
}
|
||||
};
|
||||
if (player.getInventory().getAmount(CLAY) == 1) {
|
||||
create(player, event);
|
||||
} else {
|
||||
handler.open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int getAll(int index) {
|
||||
return player.getInventory().getAmount(CLAY);
|
||||
}
|
||||
};
|
||||
if (player.getInventory().getAmount(CLAY) == 1) {
|
||||
create(player, event);
|
||||
} else {
|
||||
handler.open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a soft clay.
|
||||
* @param player the player.
|
||||
* @param event the event.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
private boolean create(final Player player, NodeUsageEvent event) {
|
||||
Item removeItem = null;
|
||||
Item returnItem = null;
|
||||
if (event.getUsedItem().getId() == Items.BUCKET_OF_WATER_1929 || event.getBaseItem().getId() == Items.BUCKET_OF_WATER_1929) {
|
||||
removeItem = BUCKET_OF_WATER;
|
||||
returnItem = BUCKET;
|
||||
}
|
||||
if (event.getUsedItem().getId() == Items.BOWL_OF_WATER_1921 || event.getBaseItem().getId() == Items.BOWL_OF_WATER_1921) {
|
||||
removeItem = BOWL_OF_WATER;
|
||||
returnItem = BOWL;
|
||||
}
|
||||
if (event.getUsedItem().getId() == Items.JUG_OF_WATER_1937 || event.getBaseItem().getId() == Items.JUG_OF_WATER_1937) {
|
||||
removeItem = JUG_OF_WATER;
|
||||
returnItem = JUG;
|
||||
}
|
||||
/**
|
||||
* Creates a soft clay.
|
||||
* @param player the player.
|
||||
* @param event the event.
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
private boolean create(final Player player, NodeUsageEvent event) {
|
||||
Item removeItem = null;
|
||||
Item returnItem = null;
|
||||
if (event.getUsedItem().getId() == Items.BUCKET_OF_WATER_1929 || event.getBaseItem().getId() == Items.BUCKET_OF_WATER_1929) {
|
||||
removeItem = BUCKET_OF_WATER;
|
||||
returnItem = BUCKET;
|
||||
}
|
||||
if (event.getUsedItem().getId() == Items.BOWL_OF_WATER_1921 || event.getBaseItem().getId() == Items.BOWL_OF_WATER_1921) {
|
||||
removeItem = BOWL_OF_WATER;
|
||||
returnItem = BOWL;
|
||||
}
|
||||
if (event.getUsedItem().getId() == Items.JUG_OF_WATER_1937 || event.getBaseItem().getId() == Items.JUG_OF_WATER_1937) {
|
||||
removeItem = JUG_OF_WATER;
|
||||
returnItem = JUG;
|
||||
}
|
||||
|
||||
if (player.getInventory().containsItem(CLAY) && player.getInventory().containsItem(Objects.requireNonNull(removeItem))) {
|
||||
player.getInventory().remove(removeItem);
|
||||
player.getInventory().remove(CLAY);
|
||||
player.getPacketDispatch().sendMessage("You mix the clay and water. You now have some soft, workable clay.");
|
||||
player.getInventory().add(SOFT_CLAY);
|
||||
player.getInventory().add(returnItem);
|
||||
if (!player.getAchievementDiaryManager().hasCompletedTask(DiaryType.LUMBRIDGE, 0, 6) && player.getLocation().getRegionId() == 12341) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 0, 6);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (player.getInventory().containsItem(CLAY) && player.getInventory().containsItem(Objects.requireNonNull(removeItem))) {
|
||||
player.getInventory().remove(removeItem);
|
||||
player.getInventory().remove(CLAY);
|
||||
player.getPacketDispatch().sendMessage("You mix the clay and water. You now have some soft, workable clay.");
|
||||
player.getInventory().add(SOFT_CLAY);
|
||||
player.getInventory().add(returnItem);
|
||||
if (!player.getAchievementDiaryManager().hasCompletedTask(DiaryType.LUMBRIDGE, 0, 6) && player.getLocation().getRegionId() == 12341) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 0, 6);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,302 +38,302 @@ import static core.api.ContentAPIKt.*;
|
|||
@Initializable
|
||||
public final class BrimhavenArena extends MapZone implements Plugin<Object> {
|
||||
|
||||
/**
|
||||
* The location based traps.
|
||||
*/
|
||||
private static final Map<Location, MovementHook> LOCATION_TRAPS = new HashMap<>();
|
||||
/**
|
||||
* The location based traps.
|
||||
*/
|
||||
private static final Map<Location, MovementHook> LOCATION_TRAPS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The overlay component.
|
||||
*/
|
||||
private static final Component OVERLAY = new Component(5);
|
||||
/**
|
||||
* The overlay component.
|
||||
*/
|
||||
private static final Component OVERLAY = new Component(5);
|
||||
|
||||
/**
|
||||
* The ticket dispenser locations.
|
||||
*/
|
||||
private static final Location[] DISPENSERS = new Location[24];
|
||||
/**
|
||||
* The ticket dispenser locations.
|
||||
*/
|
||||
private static final Location[] DISPENSERS = new Location[24];
|
||||
|
||||
/**
|
||||
* The agility ticket reward item.
|
||||
*/
|
||||
private static final Item TICKET = new Item(2996);
|
||||
/**
|
||||
* The agility ticket reward item.
|
||||
*/
|
||||
private static final Item TICKET = new Item(2996);
|
||||
|
||||
/**
|
||||
* If the saw blade is currently active.
|
||||
*/
|
||||
public static boolean sawBladeActive;
|
||||
/**
|
||||
* If the saw blade is currently active.
|
||||
*/
|
||||
public static boolean sawBladeActive;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BrimhavenArena} {@code Object}.
|
||||
*/
|
||||
public BrimhavenArena() {
|
||||
super("Brimhaven agility arena", true);
|
||||
}
|
||||
/**
|
||||
* Constructs a new {@code BrimhavenArena} {@code Object}.
|
||||
*/
|
||||
public BrimhavenArena() {
|
||||
super("Brimhaven agility arena", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current ticket dispenser target.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
private void setDispenser(Player player) {
|
||||
if (!player.getAttribute("brim-tagged", false)) {
|
||||
player.setAttribute("brim-tagcount", 0);
|
||||
}
|
||||
player.setAttribute("brim-tagged", false);
|
||||
setVarp(player, 309, 0);
|
||||
int index = RandomFunction.randomize(DISPENSERS.length);
|
||||
if (index == player.getAttribute("brim-tag", -1)) {
|
||||
index = (index + 1) % DISPENSERS.length;
|
||||
}
|
||||
int iconSlot = player.getAttribute("brim-icon", -1);
|
||||
if (iconSlot > -1) {
|
||||
HintIconManager.removeHintIcon(player, iconSlot);
|
||||
}
|
||||
player.setAttribute("brim-tag", index);
|
||||
player.setAttribute("brim-icon", HintIconManager.registerHeightHintIcon(player, DISPENSERS[index], 50));
|
||||
}
|
||||
/**
|
||||
* Sets the current ticket dispenser target.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
private void setDispenser(Player player) {
|
||||
if (!player.getAttribute("brim-tagged", false)) {
|
||||
player.setAttribute("brim-tagcount", 0);
|
||||
}
|
||||
player.setAttribute("brim-tagged", false);
|
||||
setVarp(player, 309, 0);
|
||||
int index = RandomFunction.randomize(DISPENSERS.length);
|
||||
if (index == player.getAttribute("brim-tag", -1)) {
|
||||
index = (index + 1) % DISPENSERS.length;
|
||||
}
|
||||
int iconSlot = player.getAttribute("brim-icon", -1);
|
||||
if (iconSlot > -1) {
|
||||
HintIconManager.removeHintIcon(player, iconSlot);
|
||||
}
|
||||
player.setAttribute("brim-tag", index);
|
||||
player.setAttribute("brim-icon", HintIconManager.registerHeightHintIcon(player, DISPENSERS[index], 50));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enter(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
player.getInterfaceManager().openOverlay(OVERLAY);
|
||||
setDispenser(player);
|
||||
}
|
||||
return super.enter(entity);
|
||||
}
|
||||
@Override
|
||||
public boolean enter(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
player.getInterfaceManager().openOverlay(OVERLAY);
|
||||
setDispenser(player);
|
||||
}
|
||||
return super.enter(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leave(Entity entity, boolean logout) {
|
||||
if (entity instanceof Player && !logout) {
|
||||
Player player = (Player) entity;
|
||||
player.getInterfaceManager().closeOverlay();
|
||||
player.removeAttribute("brim-tag");
|
||||
player.removeAttribute("brim-tagcount");
|
||||
int iconSlot = player.getAttribute("brim-icon", -1);
|
||||
if (iconSlot > -1) {
|
||||
HintIconManager.removeHintIcon(player, iconSlot);
|
||||
player.removeAttribute("brim-icon");
|
||||
}
|
||||
}
|
||||
return super.enter(entity);
|
||||
}
|
||||
@Override
|
||||
public boolean leave(Entity entity, boolean logout) {
|
||||
if (entity instanceof Player && !logout) {
|
||||
Player player = (Player) entity;
|
||||
player.getInterfaceManager().closeOverlay();
|
||||
player.removeAttribute("brim-tag");
|
||||
player.removeAttribute("brim-tagcount");
|
||||
int iconSlot = player.getAttribute("brim-icon", -1);
|
||||
if (iconSlot > -1) {
|
||||
HintIconManager.removeHintIcon(player, iconSlot);
|
||||
player.removeAttribute("brim-icon");
|
||||
}
|
||||
}
|
||||
return super.enter(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interact(Entity entity, Node node, Option option) {
|
||||
if (node instanceof Scenery) {
|
||||
Scenery object = (Scenery) node;
|
||||
if (object.getId() == 3610) {
|
||||
ClimbActionHandler.climb((Player) entity, Animation.create(828), object.getLocation().transform(0, 0, 3));
|
||||
return true;
|
||||
}
|
||||
if (object.getId() == 3608 || object.getId() == 3581) {
|
||||
Player player = (Player) entity;
|
||||
if (!object.getLocation().equals(DISPENSERS[player.getAttribute("brim-tag", 0)])) {
|
||||
player.getPacketDispatch().sendMessage("Tag the pillar indicated by the yellow arrow to get an Agility ticket.");
|
||||
return true;
|
||||
}
|
||||
if (player.getAttribute("brim-tagged", false)) {
|
||||
player.getPacketDispatch().sendMessage("You have already tagged this pillar.");
|
||||
return true;
|
||||
}
|
||||
player.setAttribute("brim-tagged", true);
|
||||
int tags = player.getAttribute("brim-tagcount", 0) + 1;
|
||||
player.setAttribute("brim-tagcount", tags);
|
||||
setVarp(player, 309, 4);
|
||||
if (tags > 1) {
|
||||
int amount = 1;
|
||||
if (!player.getInventory().add(new Item(TICKET.getId(), amount))) {
|
||||
GroundItemManager.create(new GroundItem(new Item(TICKET.getId(), amount), player.getLocation(), player));
|
||||
}
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 0);
|
||||
player.getDialogueInterpreter().sendItemMessage(TICKET.getId(), "You have received an Agility Arena Ticket!");
|
||||
player.getPacketDispatch().sendMessage("You have received an Agility Arena Ticket!");
|
||||
return true;
|
||||
}
|
||||
player.getPacketDispatch().sendMessage("You get tickets by tagging more than one pillar in a row, tag the next pillar!");
|
||||
player.getDialogueInterpreter().sendDialogue("You get tickets by tagging more than one pillar in a row. <col=C04000>Tag the", "<col=C04000>next pillar for a ticket!</col>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean interact(Entity entity, Node node, Option option) {
|
||||
if (node instanceof Scenery) {
|
||||
Scenery object = (Scenery) node;
|
||||
if (object.getId() == 3610) {
|
||||
ClimbActionHandler.climb((Player) entity, Animation.create(828), object.getLocation().transform(0, 0, 3));
|
||||
return true;
|
||||
}
|
||||
if (object.getId() == 3608 || object.getId() == 3581) {
|
||||
Player player = (Player) entity;
|
||||
if (!object.getLocation().equals(DISPENSERS[player.getAttribute("brim-tag", 0)])) {
|
||||
player.getPacketDispatch().sendMessage("Tag the pillar indicated by the yellow arrow to get an Agility ticket.");
|
||||
return true;
|
||||
}
|
||||
if (player.getAttribute("brim-tagged", false)) {
|
||||
player.getPacketDispatch().sendMessage("You have already tagged this pillar.");
|
||||
return true;
|
||||
}
|
||||
player.setAttribute("brim-tagged", true);
|
||||
int tags = player.getAttribute("brim-tagcount", 0) + 1;
|
||||
player.setAttribute("brim-tagcount", tags);
|
||||
setVarp(player, 309, 4);
|
||||
if (tags > 1) {
|
||||
int amount = 1;
|
||||
if (!player.getInventory().add(new Item(TICKET.getId(), amount))) {
|
||||
GroundItemManager.create(new GroundItem(new Item(TICKET.getId(), amount), player.getLocation(), player));
|
||||
}
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 0);
|
||||
player.getDialogueInterpreter().sendItemMessage(TICKET.getId(), "You have received an Agility Arena Ticket!");
|
||||
player.getPacketDispatch().sendMessage("You have received an Agility Arena Ticket!");
|
||||
return true;
|
||||
}
|
||||
player.getPacketDispatch().sendMessage("You get tickets by tagging more than one pillar in a row, tag the next pillar!");
|
||||
player.getDialogueInterpreter().sendDialogue("You get tickets by tagging more than one pillar in a row. <col=C04000>Tag the", "<col=C04000>next pillar for a ticket!</col>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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 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 void locationUpdate(Entity e, Location last) {
|
||||
if (!e.getLocks().isMovementLocked() && e instanceof Player) {
|
||||
MovementHook hook = LOCATION_TRAPS.get(e.getLocation());
|
||||
if (hook != null) {
|
||||
if (!hook.handle(e, e.getLocation())) {
|
||||
if (e.getPulseManager().isMovingPulse()) {
|
||||
e.getPulseManager().clear();
|
||||
}
|
||||
e.getWalkingQueue().reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void locationUpdate(Entity e, Location last) {
|
||||
if (!e.getLocks().isMovementLocked() && e instanceof Player) {
|
||||
MovementHook hook = LOCATION_TRAPS.get(e.getLocation());
|
||||
if (hook != null) {
|
||||
if (!hook.handle(e, e.getLocation())) {
|
||||
if (e.getPulseManager().isMovingPulse()) {
|
||||
e.getPulseManager().clear();
|
||||
}
|
||||
e.getWalkingQueue().reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure() {
|
||||
registerRegion(11157);
|
||||
PressurePad pad = new PressurePad();
|
||||
LOCATION_TRAPS.put(Location.create(2800, 9579, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2799, 9579, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2800, 9557, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2799, 9557, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9585, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9584, 3), pad);
|
||||
FloorSpikes spikes = new FloorSpikes();
|
||||
LOCATION_TRAPS.put(Location.create(2800, 9568, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2799, 9568, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9552, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9551, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9573, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9574, 3), spikes);
|
||||
DartTrap dart = new DartTrap();
|
||||
LOCATION_TRAPS.put(Location.create(2788, 9557, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2789, 9557, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2794, 9573, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2794, 9574, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2777, 9568, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2778, 9568, 3), dart);
|
||||
SpinningBlades blade = new SpinningBlades();
|
||||
LOCATION_TRAPS.put(Location.create(2778, 9579, 3), blade);
|
||||
LOCATION_TRAPS.put(Location.create(2783, 9574, 3), blade);
|
||||
LOCATION_TRAPS.put(Location.create(2778, 9557, 3), blade);
|
||||
BladeTrap trap = new BladeTrap();
|
||||
LOCATION_TRAPS.put(Location.create(2788, 9579, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2789, 9579, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2783, 9551, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2783, 9552, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9584, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9585, 3), trap);
|
||||
int index = 0;
|
||||
for (int x = 2761; x < 2815; x += 11) {
|
||||
for (int y = 9546; y < 9600; y += 11) {
|
||||
if (x == 2805 && y == 9590) {
|
||||
continue;
|
||||
}
|
||||
DISPENSERS[index++] = Location.create(x, y, 3);
|
||||
}
|
||||
}
|
||||
GameWorld.getPulser().submit(new Pulse(1) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
Region r = RegionManager.forId(11157);
|
||||
if (!r.isActive()) {
|
||||
return false;
|
||||
}
|
||||
if (GameWorld.getTicks() % 100 == 0) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (Player player : r.assemblePlayerList(z)) {
|
||||
if (player != null) {
|
||||
setDispenser(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
handlePlankSwitching();
|
||||
}
|
||||
int ticks = 3;
|
||||
if (GameWorld.getTicks() % ticks == 0) {
|
||||
sawBladeActive = !sawBladeActive;
|
||||
if (sawBladeActive) {
|
||||
Scenery object = RegionManager.getObject(3, 2788, 9579);
|
||||
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
|
||||
object = RegionManager.getObject(3, 2789, 9579);
|
||||
SceneryBuilder.replace(object, object.transform(0), ticks);
|
||||
@Override
|
||||
public void configure() {
|
||||
registerRegion(11157);
|
||||
PressurePad pad = new PressurePad();
|
||||
LOCATION_TRAPS.put(Location.create(2800, 9579, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2799, 9579, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2800, 9557, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2799, 9557, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9585, 3), pad);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9584, 3), pad);
|
||||
FloorSpikes spikes = new FloorSpikes();
|
||||
LOCATION_TRAPS.put(Location.create(2800, 9568, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2799, 9568, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9552, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2772, 9551, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9573, 3), spikes);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9574, 3), spikes);
|
||||
DartTrap dart = new DartTrap();
|
||||
LOCATION_TRAPS.put(Location.create(2788, 9557, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2789, 9557, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2794, 9573, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2794, 9574, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2777, 9568, 3), dart);
|
||||
LOCATION_TRAPS.put(Location.create(2778, 9568, 3), dart);
|
||||
SpinningBlades blade = new SpinningBlades();
|
||||
LOCATION_TRAPS.put(Location.create(2778, 9579, 3), blade);
|
||||
LOCATION_TRAPS.put(Location.create(2783, 9574, 3), blade);
|
||||
LOCATION_TRAPS.put(Location.create(2778, 9557, 3), blade);
|
||||
BladeTrap trap = new BladeTrap();
|
||||
LOCATION_TRAPS.put(Location.create(2788, 9579, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2789, 9579, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2783, 9551, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2783, 9552, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9584, 3), trap);
|
||||
LOCATION_TRAPS.put(Location.create(2761, 9585, 3), trap);
|
||||
int index = 0;
|
||||
for (int x = 2761; x < 2815; x += 11) {
|
||||
for (int y = 9546; y < 9600; y += 11) {
|
||||
if (x == 2805 && y == 9590) {
|
||||
continue;
|
||||
}
|
||||
DISPENSERS[index++] = Location.create(x, y, 3);
|
||||
}
|
||||
}
|
||||
GameWorld.getPulser().submit(new Pulse(1) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
Region r = RegionManager.forId(11157);
|
||||
if (!r.isActive()) {
|
||||
return false;
|
||||
}
|
||||
if (GameWorld.getTicks() % 100 == 0) {
|
||||
for (int z = 0; z < 4; z++) {
|
||||
for (Player player : r.assemblePlayerList(z)) {
|
||||
if (player != null) {
|
||||
setDispenser(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
handlePlankSwitching();
|
||||
}
|
||||
int ticks = 3;
|
||||
if (GameWorld.getTicks() % ticks == 0) {
|
||||
sawBladeActive = !sawBladeActive;
|
||||
if (sawBladeActive) {
|
||||
Scenery object = RegionManager.getObject(3, 2788, 9579);
|
||||
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
|
||||
object = RegionManager.getObject(3, 2789, 9579);
|
||||
SceneryBuilder.replace(object, object.transform(0), ticks);
|
||||
|
||||
object = RegionManager.getObject(3, 2783, 9551);
|
||||
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
|
||||
object = RegionManager.getObject(3, 2783, 9552);
|
||||
SceneryBuilder.replace(object, object.transform(0), ticks);
|
||||
object = RegionManager.getObject(3, 2783, 9551);
|
||||
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
|
||||
object = RegionManager.getObject(3, 2783, 9552);
|
||||
SceneryBuilder.replace(object, object.transform(0), ticks);
|
||||
|
||||
object = RegionManager.getObject(3, 2761, 9584);
|
||||
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
|
||||
object = RegionManager.getObject(3, 2761, 9585);
|
||||
SceneryBuilder.replace(object, object.transform(0), ticks);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
object = RegionManager.getObject(3, 2761, 9584);
|
||||
SceneryBuilder.replace(object, object.transform(3567, object.getRotation(), 10), ticks);
|
||||
object = RegionManager.getObject(3, 2761, 9585);
|
||||
SceneryBuilder.replace(object, object.transform(0), ticks);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the plank states.
|
||||
*/
|
||||
private static void handlePlankSwitching() {
|
||||
boolean[] available = new boolean[3];
|
||||
for (int i = 0; i < 1 + RandomFunction.randomize(2); i++) {
|
||||
available[RandomFunction.randomize(3)] = true;
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
boolean avail = available[i];
|
||||
for (PlankSet set : PlankSet.values()) {
|
||||
Location l = set.entrance[i];
|
||||
for (int x = 1; x < set.exit[i].getX() - l.getX(); x++) {
|
||||
Scenery object = RegionManager.getObject(l.transform(x, 0, 0));
|
||||
if(object != null)
|
||||
SceneryBuilder.replace(object, object.transform(avail ? 3573 : 3576));
|
||||
}
|
||||
RegionManager.getObject(set.entrance[i]).setCharge(avail ? 1000 : 500);
|
||||
RegionManager.getObject(set.exit[i]).setCharge(avail ? 1000 : 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Switches the plank states.
|
||||
*/
|
||||
private static void handlePlankSwitching() {
|
||||
boolean[] available = new boolean[3];
|
||||
for (int i = 0; i < 1 + RandomFunction.randomize(2); i++) {
|
||||
available[RandomFunction.randomize(3)] = true;
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
boolean avail = available[i];
|
||||
for (PlankSet set : PlankSet.values()) {
|
||||
Location l = set.entrance[i];
|
||||
for (int x = 1; x < set.exit[i].getX() - l.getX(); x++) {
|
||||
Scenery object = RegionManager.getObject(l.transform(x, 0, 0));
|
||||
if(object != null)
|
||||
SceneryBuilder.replace(object, object.transform(avail ? 3573 : 3576));
|
||||
}
|
||||
RegionManager.getObject(set.entrance[i]).setCharge(avail ? 1000 : 500);
|
||||
RegionManager.getObject(set.exit[i]).setCharge(avail ? 1000 : 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The plank obstacles.
|
||||
*
|
||||
* @author Emperor
|
||||
*/
|
||||
private static enum PlankSet {
|
||||
FIRST(new Location[]{Location.create(2797, 9591, 3), Location.create(2797, 9590, 3), Location.create(2797, 9589, 3)}, new Location[]{Location.create(2802, 9591, 3), Location.create(2802, 9590, 3), Location.create(2802, 9589, 3)}), SECOND(new Location[]{Location.create(2764, 9558, 3), Location.create(2764, 9557, 3), Location.create(2764, 9556, 3)}, new Location[]{Location.create(2769, 9558, 3), Location.create(2769, 9557, 3), Location.create(2769, 9556, 3)});
|
||||
/**
|
||||
* The plank obstacles.
|
||||
*
|
||||
* @author Emperor
|
||||
*/
|
||||
private static enum PlankSet {
|
||||
FIRST(new Location[]{Location.create(2797, 9591, 3), Location.create(2797, 9590, 3), Location.create(2797, 9589, 3)}, new Location[]{Location.create(2802, 9591, 3), Location.create(2802, 9590, 3), Location.create(2802, 9589, 3)}), SECOND(new Location[]{Location.create(2764, 9558, 3), Location.create(2764, 9557, 3), Location.create(2764, 9556, 3)}, new Location[]{Location.create(2769, 9558, 3), Location.create(2769, 9557, 3), Location.create(2769, 9556, 3)});
|
||||
|
||||
/**
|
||||
* Constructs a new {@code PlankSet} {@code Object}.
|
||||
*
|
||||
* @param entrance The entrance locations for each plank.
|
||||
* @param exit The exit locations for each plank.
|
||||
*/
|
||||
private PlankSet(Location[] entrance, Location[] exit) {
|
||||
this.entrance = entrance;
|
||||
this.exit = exit;
|
||||
}
|
||||
/**
|
||||
* Constructs a new {@code PlankSet} {@code Object}.
|
||||
*
|
||||
* @param entrance The entrance locations for each plank.
|
||||
* @param exit The exit locations for each plank.
|
||||
*/
|
||||
private PlankSet(Location[] entrance, Location[] exit) {
|
||||
this.entrance = entrance;
|
||||
this.exit = exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The entrance location of the plank.
|
||||
*/
|
||||
Location[] entrance;
|
||||
/**
|
||||
* The entrance location of the plank.
|
||||
*/
|
||||
Location[] entrance;
|
||||
|
||||
/**
|
||||
* The exit location of the plank.
|
||||
*/
|
||||
Location[] exit;
|
||||
}
|
||||
/**
|
||||
* The exit location of the plank.
|
||||
*/
|
||||
Location[] exit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ZoneBuilder.configure(this);
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ZoneBuilder.configure(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fireEvent(String identifier, Object... args) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Object fireEvent(String identifier, Object... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,94 +20,94 @@ import static core.api.ContentAPIKt.playAudio;
|
|||
*/
|
||||
public final class SpinningPulse extends SkillPulse<Item> {
|
||||
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(896);
|
||||
/**
|
||||
* Represents the animation to use.
|
||||
*/
|
||||
private static final Animation ANIMATION = new Animation(896);
|
||||
|
||||
/**
|
||||
* Represents the type of spinning item.
|
||||
*/
|
||||
private final SpinningItem type;
|
||||
/**
|
||||
* Represents the type of spinning item.
|
||||
*/
|
||||
private final SpinningItem type;
|
||||
|
||||
/**
|
||||
* Represents the amount to spin.
|
||||
*/
|
||||
private int ammount;
|
||||
/**
|
||||
* Represents the amount to spin.
|
||||
*/
|
||||
private int ammount;
|
||||
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
/**
|
||||
* Represents the ticks passed.
|
||||
*/
|
||||
private int ticks;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SpinningPulse.java} {@Code Object}
|
||||
*
|
||||
* @param player
|
||||
* @param node
|
||||
*/
|
||||
public SpinningPulse(Player player, Item node, int ammount, SpinningItem def) {
|
||||
super(player, node);
|
||||
this.type = def;
|
||||
this.ammount = ammount;
|
||||
}
|
||||
/**
|
||||
* Constructs a new {@code SpinningPulse.java} {@Code Object}
|
||||
*
|
||||
* @param player
|
||||
* @param node
|
||||
*/
|
||||
public SpinningPulse(Player player, Item node, int ammount, SpinningItem def) {
|
||||
super(player, node);
|
||||
this.type = def;
|
||||
this.ammount = ammount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
player.getInterfaceManager().close();
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + type.getLevel() + " to make this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(type.getNeed(), 1)) {
|
||||
player.getPacketDispatch().sendMessage("You need " + ItemDefinition.forId(type.getNeed()).getName() + " to do this.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean checkRequirements() {
|
||||
player.getInterfaceManager().close();
|
||||
if (player.getSkills().getLevel(Skills.CRAFTING) < type.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a crafting level of " + type.getLevel() + " to make this.");
|
||||
return false;
|
||||
}
|
||||
if (!player.getInventory().contains(type.getNeed(), 1)) {
|
||||
player.getPacketDispatch().sendMessage("You need " + ItemDefinition.forId(type.getNeed()).getName() + " to do this.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
playAudio(player, Sounds.SPINNING_2590);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void animate() {
|
||||
if (ticks % 5 == 0) {
|
||||
player.animate(ANIMATION);
|
||||
playAudio(player, Sounds.SPINNING_2590);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reward() {
|
||||
int tickThreshhold = 4;
|
||||
if (player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(2)
|
||||
&& player.getLocation().withinDistance(Location.create(2711,3471,1))
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT) != null
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
|
||||
tickThreshhold = 2;
|
||||
}
|
||||
if (++ticks % tickThreshhold != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(type.getNeed(), 1))) {
|
||||
final Item item = new Item(type.getProduct(), 1);
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, type.getExp(), true);
|
||||
@Override
|
||||
public boolean reward() {
|
||||
int tickThreshhold = 4;
|
||||
if (player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(2)
|
||||
&& player.getLocation().withinDistance(Location.create(2711,3471,1))
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT) != null
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
|
||||
tickThreshhold = 2;
|
||||
}
|
||||
if (++ticks % tickThreshhold != 0) {
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().remove(new Item(type.getNeed(), 1))) {
|
||||
final Item item = new Item(type.getProduct(), 1);
|
||||
player.getInventory().add(item);
|
||||
player.getSkills().addExperience(Skills.CRAFTING, type.getExp(), true);
|
||||
|
||||
// Seers achievement diary
|
||||
if (player.getLocation().getRegionId() == 10806
|
||||
&& !player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(0, 4)) {
|
||||
if (player.getAttribute("diary:seers:bowstrings-spun", 0) >= 4) {
|
||||
player.setAttribute("/save:diary:seers:bowstrings-spun", 5);
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 0, 4);
|
||||
} else {
|
||||
player.setAttribute("/save:diary:seers:bowstrings-spun", player.getAttribute("diary:seers:bowstrings-spun", 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ammount--;
|
||||
return ammount < 1;
|
||||
}
|
||||
// Seers achievement diary
|
||||
if (player.getLocation().getRegionId() == 10806
|
||||
&& !player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(0, 4)) {
|
||||
if (player.getAttribute("diary:seers:bowstrings-spun", 0) >= 4) {
|
||||
player.setAttribute("/save:diary:seers:bowstrings-spun", 5);
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 0, 4);
|
||||
} else {
|
||||
player.setAttribute("/save:diary:seers:bowstrings-spun", player.getAttribute("diary:seers:bowstrings-spun", 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ammount--;
|
||||
return ammount < 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(int type) {
|
||||
}
|
||||
@Override
|
||||
public void message(int type) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,244 +39,244 @@ import static core.game.system.command.sets.StatAttributeKeysKt.STATS_LOGS;
|
|||
* @author ceik
|
||||
*/
|
||||
public class WoodcuttingSkillPulse extends Pulse {
|
||||
private int[] woodcuttingSounds = {
|
||||
Sounds.WOODCUTTING_HIT_3038,
|
||||
Sounds.WOODCUTTING_HIT_3039,
|
||||
Sounds.WOODCUTTING_HIT_3040,
|
||||
Sounds.WOODCUTTING_HIT_3041,
|
||||
Sounds.WOODCUTTING_HIT_3042
|
||||
};
|
||||
private int[] woodcuttingSounds = {
|
||||
Sounds.WOODCUTTING_HIT_3038,
|
||||
Sounds.WOODCUTTING_HIT_3039,
|
||||
Sounds.WOODCUTTING_HIT_3040,
|
||||
Sounds.WOODCUTTING_HIT_3041,
|
||||
Sounds.WOODCUTTING_HIT_3042
|
||||
};
|
||||
|
||||
private WoodcuttingNode resource;
|
||||
private int ticks;
|
||||
private Player player;
|
||||
private Scenery node;
|
||||
protected boolean resetAnimation = true;
|
||||
private WoodcuttingNode resource;
|
||||
private int ticks;
|
||||
private Player player;
|
||||
private Scenery node;
|
||||
protected boolean resetAnimation = true;
|
||||
|
||||
|
||||
public WoodcuttingSkillPulse(Player player, Scenery node) {
|
||||
super(1, player, node);
|
||||
this.player = player;
|
||||
this.node = node;
|
||||
super.stop();
|
||||
}
|
||||
public WoodcuttingSkillPulse(Player player, Scenery node) {
|
||||
super(1, player, node);
|
||||
this.player = player;
|
||||
this.node = node;
|
||||
super.stop();
|
||||
}
|
||||
|
||||
public void message(int type) {
|
||||
if (type == 0) {
|
||||
player.getPacketDispatch().sendMessage("You swing your axe at the tree...");
|
||||
}
|
||||
}
|
||||
public void message(int type) {
|
||||
if (type == 0) {
|
||||
player.getPacketDispatch().sendMessage("You swing your axe at the tree...");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (!checkRequirements()) {
|
||||
return true;
|
||||
}
|
||||
animate();
|
||||
return reward();
|
||||
}
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (!checkRequirements()) {
|
||||
return true;
|
||||
}
|
||||
animate();
|
||||
return reward();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (resetAnimation) {
|
||||
player.animate(new Animation(-1, Animator.Priority.HIGH));
|
||||
}
|
||||
super.stop();
|
||||
message(1);
|
||||
}
|
||||
@Override
|
||||
public void stop() {
|
||||
if (resetAnimation) {
|
||||
player.animate(new Animation(-1, Animator.Priority.HIGH));
|
||||
}
|
||||
super.stop();
|
||||
message(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
resource = WoodcuttingNode.forId(node.getId());
|
||||
if (resource == null) {
|
||||
return;
|
||||
}
|
||||
if (checkRequirements()) {
|
||||
super.start();
|
||||
message(0);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void start() {
|
||||
resource = WoodcuttingNode.forId(node.getId());
|
||||
if (resource == null) {
|
||||
return;
|
||||
}
|
||||
if (checkRequirements()) {
|
||||
super.start();
|
||||
message(0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.WOODCUTTING) < resource.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a woodcutting level of " + resource.getLevel() + " to chop this tree.");
|
||||
return false;
|
||||
}
|
||||
if (SkillingTool.getHatchet(player) == null) {
|
||||
player.getPacketDispatch().sendMessage("You do not have an axe to use.");
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().freeSlots() < 1) {
|
||||
player.getDialogueInterpreter().sendDialogue("Your inventory is too full to hold any more " + ItemDefinition.forId(resource.getReward()).getName().toLowerCase() + ".");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkRequirements() {
|
||||
if (player.getSkills().getLevel(Skills.WOODCUTTING) < resource.getLevel()) {
|
||||
player.getPacketDispatch().sendMessage("You need a woodcutting level of " + resource.getLevel() + " to chop this tree.");
|
||||
return false;
|
||||
}
|
||||
if (SkillingTool.getHatchet(player) == null) {
|
||||
player.getPacketDispatch().sendMessage("You do not have an axe to use.");
|
||||
return false;
|
||||
}
|
||||
if (player.getInventory().freeSlots() < 1) {
|
||||
player.getDialogueInterpreter().sendDialogue("Your inventory is too full to hold any more " + ItemDefinition.forId(resource.getReward()).getName().toLowerCase() + ".");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void animate() {
|
||||
if (!player.getAnimator().isAnimating()) {
|
||||
player.animate(SkillingTool.getHatchet(player).getAnimation());
|
||||
for (Player p : RegionManager.getLocalPlayers(player.getLocation(), 2)) {
|
||||
if (p.getName() == player.getName()) {
|
||||
continue;
|
||||
}
|
||||
int soundIndex = RandomFunction.random(0, woodcuttingSounds.length);
|
||||
playAudio(p, woodcuttingSounds[soundIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void animate() {
|
||||
if (!player.getAnimator().isAnimating()) {
|
||||
player.animate(SkillingTool.getHatchet(player).getAnimation());
|
||||
for (Player p : RegionManager.getLocalPlayers(player.getLocation(), 2)) {
|
||||
if (p.getName() == player.getName()) {
|
||||
continue;
|
||||
}
|
||||
int soundIndex = RandomFunction.random(0, woodcuttingSounds.length);
|
||||
playAudio(p, woodcuttingSounds[soundIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean reward() {
|
||||
if (++ticks % 4 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (node.getId() == 10041) {
|
||||
player.getDialogueInterpreter().sendDialogues(2574, FacialExpression.FURIOUS, RandomFunction.random(2) == 1 ? "You'll blow my cover! I'm meant to be hidden!" : "Will you stop that?");
|
||||
return true;
|
||||
}
|
||||
if (!checkReward(SkillingTool.getHatchet(player))) {
|
||||
return false;
|
||||
}
|
||||
public boolean reward() {
|
||||
if (++ticks % 4 != 0) {
|
||||
return false;
|
||||
}
|
||||
if (node.getId() == 10041) {
|
||||
player.getDialogueInterpreter().sendDialogues(2574, FacialExpression.FURIOUS, RandomFunction.random(2) == 1 ? "You'll blow my cover! I'm meant to be hidden!" : "Will you stop that?");
|
||||
return true;
|
||||
}
|
||||
if (!checkReward(SkillingTool.getHatchet(player))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 20% chance to auto burn logs when using "inferno adze" item
|
||||
if (SkillingTool.getHatchet(player).getId() == 13661 && RandomFunction.random(100) < 25) {
|
||||
player.sendMessage("You chop some logs. The heat of the inferno adze incinerates them.");
|
||||
Projectile.create(player, null, 1776, 35, 30, 20, 25).transform(player, new Location(player.getLocation().getX() + 2, player.getLocation().getY()), true, 25, 25).send();
|
||||
player.getSkills().addExperience(Skills.WOODCUTTING, resource.getExperience());
|
||||
player.getSkills().addExperience(Skills.FIREMAKING, resource.getExperience());
|
||||
return rollDepletion();
|
||||
}
|
||||
// 20% chance to auto burn logs when using "inferno adze" item
|
||||
if (SkillingTool.getHatchet(player).getId() == 13661 && RandomFunction.random(100) < 25) {
|
||||
player.sendMessage("You chop some logs. The heat of the inferno adze incinerates them.");
|
||||
Projectile.create(player, null, 1776, 35, 30, 20, 25).transform(player, new Location(player.getLocation().getX() + 2, player.getLocation().getY()), true, 25, 25).send();
|
||||
player.getSkills().addExperience(Skills.WOODCUTTING, resource.getExperience());
|
||||
player.getSkills().addExperience(Skills.FIREMAKING, resource.getExperience());
|
||||
return rollDepletion();
|
||||
}
|
||||
|
||||
//actual reward calculations
|
||||
int reward = resource.getReward();
|
||||
int rewardAmount = 0;
|
||||
if (reward > 0) {
|
||||
reward = calculateReward(reward); // calculate rewards
|
||||
rewardAmount = calculateRewardAmount(reward); // calculate amount
|
||||
//actual reward calculations
|
||||
int reward = resource.getReward();
|
||||
int rewardAmount = 0;
|
||||
if (reward > 0) {
|
||||
reward = calculateReward(reward); // calculate rewards
|
||||
rewardAmount = calculateRewardAmount(reward); // calculate amount
|
||||
|
||||
//add experience
|
||||
double experience = calculateExperience(resource.reward, rewardAmount);
|
||||
//add experience
|
||||
double experience = calculateExperience(resource.reward, rewardAmount);
|
||||
|
||||
player.getSkills().addExperience(Skills.WOODCUTTING, experience, true);
|
||||
player.getSkills().addExperience(Skills.WOODCUTTING, experience, true);
|
||||
|
||||
//send the message for the resource reward
|
||||
player.getPacketDispatch().sendMessage("You get some " + ItemDefinition.forId(reward).getName().toLowerCase() + ".");
|
||||
//give the reward
|
||||
player.getInventory().add(new Item(reward, rewardAmount));
|
||||
player.dispatch(new ResourceProducedEvent(reward, rewardAmount, node, -1));
|
||||
int cutLogs = player.getAttribute(STATS_BASE + ":" + STATS_LOGS,0);
|
||||
player.setAttribute("/save:" + STATS_BASE + ":" + STATS_LOGS,++cutLogs);
|
||||
//send the message for the resource reward
|
||||
player.getPacketDispatch().sendMessage("You get some " + ItemDefinition.forId(reward).getName().toLowerCase() + ".");
|
||||
//give the reward
|
||||
player.getInventory().add(new Item(reward, rewardAmount));
|
||||
player.dispatch(new ResourceProducedEvent(reward, rewardAmount, node, -1));
|
||||
int cutLogs = player.getAttribute(STATS_BASE + ":" + STATS_LOGS,0);
|
||||
player.setAttribute("/save:" + STATS_BASE + ":" + STATS_LOGS,++cutLogs);
|
||||
|
||||
//calculate bonus bird nest for mining
|
||||
int chance = 282;
|
||||
if (RandomFunction.random(chance) == chance / 2) {
|
||||
if(SkillcapePerks.isActive(SkillcapePerks.NEST_HUNTER,player)){
|
||||
if(!player.getInventory().add(BirdNest.getRandomNest(false).getNest())){
|
||||
BirdNest.drop(player);
|
||||
}
|
||||
} else {
|
||||
BirdNest.drop(player);
|
||||
}
|
||||
}
|
||||
//calculate bonus bird nest for mining
|
||||
int chance = 282;
|
||||
if (RandomFunction.random(chance) == chance / 2) {
|
||||
if(SkillcapePerks.isActive(SkillcapePerks.NEST_HUNTER,player)){
|
||||
if(!player.getInventory().add(BirdNest.getRandomNest(false).getNest())){
|
||||
BirdNest.drop(player);
|
||||
}
|
||||
} else {
|
||||
BirdNest.drop(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return rollDepletion();
|
||||
}
|
||||
return rollDepletion();
|
||||
}
|
||||
|
||||
private boolean rollDepletion() {
|
||||
//transform to depleted version
|
||||
//OSRS and RS3 Wikis both agree: All trees present in 2009 are a 1/8 fell chance, aside from normal trees/dead trees which are 100%
|
||||
//OSRS: https://oldschool.runescape.wiki/w/Woodcutting scroll down to the mechanics section
|
||||
//RS3 : https://runescape.wiki/w/Woodcutting scroll down to the mechanics section, and expand the tree felling chances table
|
||||
if (resource.getRespawnRate() > 0) {
|
||||
if (RandomFunction.roll(8) || resource.identifier == 1 || resource.identifier == 2 || resource.identifier == 3 || resource.identifier == 6) {
|
||||
if (resource.isFarming()) {
|
||||
FarmingPatch fPatch = FarmingPatch.forObject(node.asScenery());
|
||||
if(fPatch != null) {
|
||||
Patch patch = fPatch.getPatchFor(player, true);
|
||||
patch.setCurrentState(patch.getCurrentState() + 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (resource.getEmptyId() > -1) {
|
||||
SceneryBuilder.replace(node, node.transform(resource.getEmptyId()), resource.getRespawnDuration());
|
||||
} else {
|
||||
SceneryBuilder.replace(node, node.transform(0), resource.getRespawnDuration());
|
||||
}
|
||||
node.setActive(false);
|
||||
private boolean rollDepletion() {
|
||||
//transform to depleted version
|
||||
//OSRS and RS3 Wikis both agree: All trees present in 2009 are a 1/8 fell chance, aside from normal trees/dead trees which are 100%
|
||||
//OSRS: https://oldschool.runescape.wiki/w/Woodcutting scroll down to the mechanics section
|
||||
//RS3 : https://runescape.wiki/w/Woodcutting scroll down to the mechanics section, and expand the tree felling chances table
|
||||
if (resource.getRespawnRate() > 0) {
|
||||
if (RandomFunction.roll(8) || resource.identifier == 1 || resource.identifier == 2 || resource.identifier == 3 || resource.identifier == 6) {
|
||||
if (resource.isFarming()) {
|
||||
FarmingPatch fPatch = FarmingPatch.forObject(node.asScenery());
|
||||
if(fPatch != null) {
|
||||
Patch patch = fPatch.getPatchFor(player, true);
|
||||
patch.setCurrentState(patch.getCurrentState() + 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (resource.getEmptyId() > -1) {
|
||||
SceneryBuilder.replace(node, node.transform(resource.getEmptyId()), resource.getRespawnDuration());
|
||||
} else {
|
||||
SceneryBuilder.replace(node, node.transform(0), resource.getRespawnDuration());
|
||||
}
|
||||
node.setActive(false);
|
||||
|
||||
playAudio(player, Sounds.TREE_FALLING_2734);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
playAudio(player, Sounds.TREE_FALLING_2734);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int calculateRewardAmount(int reward) {
|
||||
int amount = 1;
|
||||
private int calculateRewardAmount(int reward) {
|
||||
int amount = 1;
|
||||
|
||||
// 3239: Hollow tree (bark) 10% chance of obtaining
|
||||
if (reward == 3239 && RandomFunction.random(100) >= 10) {
|
||||
amount = 0;
|
||||
}
|
||||
// 3239: Hollow tree (bark) 10% chance of obtaining
|
||||
if (reward == 3239 && RandomFunction.random(100) >= 10) {
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
// Seers village medium reward - extra normal log while in seer's village
|
||||
if (reward == 1511
|
||||
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
|
||||
&& player.getLocation().getRegionId() == 10806) {
|
||||
amount = 2;
|
||||
}
|
||||
// Seers village medium reward - extra normal log while in seer's village
|
||||
if (reward == 1511
|
||||
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
|
||||
&& player.getLocation().getRegionId() == 10806) {
|
||||
amount = 2;
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
private double calculateExperience(int reward, int amount) {
|
||||
double experience = resource.getExperience();
|
||||
private double calculateExperience(int reward, int amount) {
|
||||
double experience = resource.getExperience();
|
||||
|
||||
if(player.getLocation().getRegionId() == 10300){
|
||||
return 1.0;
|
||||
}
|
||||
if(player.getLocation().getRegionId() == 10300){
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
// Bark
|
||||
if (reward == 3239) {
|
||||
// If we receive the item, give the full experience points otherwise give the base amount
|
||||
if (amount >= 1) {
|
||||
experience = 275.2;
|
||||
} else {
|
||||
amount = 1;
|
||||
}
|
||||
}
|
||||
// Bark
|
||||
if (reward == 3239) {
|
||||
// If we receive the item, give the full experience points otherwise give the base amount
|
||||
if (amount >= 1) {
|
||||
experience = 275.2;
|
||||
} else {
|
||||
amount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Seers village medium reward - extra 10% xp from maples while wearing headband
|
||||
if (reward == 1517
|
||||
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT) != null
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
|
||||
experience *= 1.10;
|
||||
}
|
||||
// Seers village medium reward - extra 10% xp from maples while wearing headband
|
||||
if (reward == 1517
|
||||
&& player.getAchievementDiaryManager().getDiary(DiaryType.SEERS_VILLAGE).isComplete(1)
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT) != null
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HAT).getId() == 14631) {
|
||||
experience *= 1.10;
|
||||
}
|
||||
|
||||
return experience * amount;
|
||||
}
|
||||
return experience * amount;
|
||||
}
|
||||
|
||||
private int calculateReward(int reward) {
|
||||
return reward;
|
||||
}
|
||||
private int calculateReward(int reward) {
|
||||
return reward;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player gets rewarded.
|
||||
*
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
private boolean checkReward(SkillingTool tool) {
|
||||
int skill = Skills.WOODCUTTING;
|
||||
int level = player.getSkills().getLevel(skill) + player.getFamiliarManager().getBoost(skill);
|
||||
double hostRatio = RandomFunction.randomDouble(100.0);
|
||||
double lowMod = tool == SkillingTool.BLACK_AXE ? resource.tierModLow / 2 : resource.tierModLow;
|
||||
double low = resource.baseLow + (tool.ordinal() * lowMod);
|
||||
double highMod = tool == SkillingTool.BLACK_AXE ? resource.tierModHigh / 2 : resource.tierModHigh;
|
||||
double high = resource.baseHigh + (tool.ordinal() * highMod);
|
||||
double clientRatio = RandomFunction.getSkillSuccessChance(low,high,level);
|
||||
return hostRatio < clientRatio;
|
||||
}
|
||||
/**
|
||||
* Checks if the player gets rewarded.
|
||||
*
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
private boolean checkReward(SkillingTool tool) {
|
||||
int skill = Skills.WOODCUTTING;
|
||||
int level = player.getSkills().getLevel(skill) + player.getFamiliarManager().getBoost(skill);
|
||||
double hostRatio = RandomFunction.randomDouble(100.0);
|
||||
double lowMod = tool == SkillingTool.BLACK_AXE ? resource.tierModLow / 2 : resource.tierModLow;
|
||||
double low = resource.baseLow + (tool.ordinal() * lowMod);
|
||||
double highMod = tool == SkillingTool.BLACK_AXE ? resource.tierModHigh / 2 : resource.tierModHigh;
|
||||
double high = resource.baseHigh + (tool.ordinal() * highMod);
|
||||
double clientRatio = RandomFunction.getSkillSuccessChance(low,high,level);
|
||||
return hostRatio < clientRatio;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,122 +30,122 @@ import java.util.List;
|
|||
@Initializable
|
||||
public class NoraTHaggNPC extends AbstractNPC {
|
||||
|
||||
boolean walkdir;
|
||||
boolean walkdir;
|
||||
|
||||
public NoraTHaggNPC() {
|
||||
super(896, Location.create(2904, 3463, 0));
|
||||
}
|
||||
private Location getRespawnLocation() {
|
||||
return Location.create(2900, 3473, 0);
|
||||
}
|
||||
public NoraTHaggNPC() {
|
||||
super(896, Location.create(2904, 3463, 0));
|
||||
}
|
||||
private Location getRespawnLocation() {
|
||||
return Location.create(2900, 3473, 0);
|
||||
}
|
||||
|
||||
private NoraTHaggNPC(int id, Location location) {
|
||||
super(id, location);
|
||||
}
|
||||
private NoraTHaggNPC(int id, Location location) {
|
||||
super(id, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
this.configure();
|
||||
init();
|
||||
return super.newInstance(arg);
|
||||
}
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
this.configure();
|
||||
init();
|
||||
return super.newInstance(arg);
|
||||
}
|
||||
|
||||
private boolean canTeleport(Entity t) {
|
||||
int playerX = t.getLocation().getX();
|
||||
int npcX = getLocation().getX();
|
||||
int[] sectors = { 2904, 2907, 2910, 2914, 2918, 2922, 2926, 2928 };
|
||||
for (int i = 0; i < sectors.length -1; i++) {
|
||||
if (npcX >= sectors[i] && npcX <= sectors[i+1] && playerX >= sectors[i] && playerX <= sectors[i+1]) {
|
||||
if (playerX < npcX && getDirection() == Direction.WEST || playerX > npcX && getDirection() == Direction.EAST) {
|
||||
return true;
|
||||
}
|
||||
if (playerX == npcX) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean canTeleport(Entity t) {
|
||||
int playerX = t.getLocation().getX();
|
||||
int npcX = getLocation().getX();
|
||||
int[] sectors = { 2904, 2907, 2910, 2914, 2918, 2922, 2926, 2928 };
|
||||
for (int i = 0; i < sectors.length -1; i++) {
|
||||
if (npcX >= sectors[i] && npcX <= sectors[i+1] && playerX >= sectors[i] && playerX <= sectors[i+1]) {
|
||||
if (playerX < npcX && getDirection() == Direction.WEST || playerX > npcX && getDirection() == Direction.EAST) {
|
||||
return true;
|
||||
}
|
||||
if (playerX == npcX) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractNPC construct(int id, Location location, Object... objects) {
|
||||
return new NoraTHaggNPC(id, location);
|
||||
}
|
||||
@Override
|
||||
public AbstractNPC construct(int id, Location location, Object... objects) {
|
||||
return new NoraTHaggNPC(id, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 896 };
|
||||
}
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 896 };
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getWalkRadius() {
|
||||
return 50;
|
||||
}
|
||||
@Override
|
||||
public int getWalkRadius() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
|
||||
public void configure() {
|
||||
super.configure();
|
||||
setWalks(false);
|
||||
setPathBoundMovement(true);
|
||||
}
|
||||
public void configure() {
|
||||
super.configure();
|
||||
setWalks(false);
|
||||
setPathBoundMovement(true);
|
||||
}
|
||||
|
||||
private void sendTeleport(final Player player) {
|
||||
player.lock();
|
||||
GameWorld.getPulser().submit(new Pulse(1) {
|
||||
int delay = 0;
|
||||
private void sendTeleport(final Player player) {
|
||||
player.lock();
|
||||
GameWorld.getPulser().submit(new Pulse(1) {
|
||||
int delay = 0;
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (delay == 0) {
|
||||
face(player);
|
||||
player.getInventory().remove(WitchsHousePlugin.BALL);
|
||||
player.getInventory().remove(WitchsHousePlugin.KEY);
|
||||
player.getInventory().remove(WitchsHousePlugin.DOOR_KEY);
|
||||
sendChat("Stop! Thief!");
|
||||
player.getPacketDispatch().sendMessage("You've been spotted by the witch.");
|
||||
player.graphics(new Graphics(110, 100));
|
||||
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2));
|
||||
} else if (delay == 2) {
|
||||
sendChat("Klarata... Seppteno... Valkan!");
|
||||
face(null);
|
||||
} else if (delay == 4) {
|
||||
player.getProperties().setTeleportLocation(Location.create(getRespawnLocation()));
|
||||
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0));
|
||||
face(null);
|
||||
player.unlock();
|
||||
return true;
|
||||
}
|
||||
delay++;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
if (delay == 0) {
|
||||
face(player);
|
||||
player.getInventory().remove(WitchsHousePlugin.BALL);
|
||||
player.getInventory().remove(WitchsHousePlugin.KEY);
|
||||
player.getInventory().remove(WitchsHousePlugin.DOOR_KEY);
|
||||
sendChat("Stop! Thief!");
|
||||
player.getPacketDispatch().sendMessage("You've been spotted by the witch.");
|
||||
player.graphics(new Graphics(110, 100));
|
||||
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 2));
|
||||
} else if (delay == 2) {
|
||||
sendChat("Klarata... Seppteno... Valkan!");
|
||||
face(null);
|
||||
} else if (delay == 4) {
|
||||
player.getProperties().setTeleportLocation(Location.create(getRespawnLocation()));
|
||||
PacketRepository.send(MinimapState.class, new MinimapStateContext(player, 0));
|
||||
face(null);
|
||||
player.unlock();
|
||||
return true;
|
||||
}
|
||||
delay++;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
List<Player> players = RegionManager.getLocalPlayers(location);
|
||||
if(getLocation().getX() == 2930){
|
||||
walkdir = false;
|
||||
} else if(getLocation().getX() == 2904){
|
||||
walkdir = true;
|
||||
}
|
||||
for (Player player : players) {
|
||||
if (player == null || !player.isActive() || player.getLocks().isInteractionLocked() || DeathTask.isDead(player) || !canTeleport(player) || !CombatSwingHandler.isProjectileClipped(this, player, false)) {
|
||||
continue;
|
||||
}
|
||||
animate(new Animation(5803));
|
||||
sendTeleport(player);
|
||||
player.getPacketDispatch().sendMessage("" + getLocation() + " matches? " + (getLocation().getX() == 2904));
|
||||
}
|
||||
if (location.getX() != 2930 && walkdir) {
|
||||
this.getWalkingQueue().reset();
|
||||
this.getWalkingQueue().addPath(location.getX() + 1,3463,true);
|
||||
} else if (location.getX() != 2904 && !walkdir) {
|
||||
this.getWalkingQueue().reset();
|
||||
this.getWalkingQueue().addPath(location.getX() - 1,3463,true);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
List<Player> players = RegionManager.getLocalPlayers(location);
|
||||
if(getLocation().getX() == 2930){
|
||||
walkdir = false;
|
||||
} else if(getLocation().getX() == 2904){
|
||||
walkdir = true;
|
||||
}
|
||||
for (Player player : players) {
|
||||
if (player == null || !player.isActive() || player.getLocks().isInteractionLocked() || DeathTask.isDead(player) || !canTeleport(player) || !CombatSwingHandler.isProjectileClipped(this, player, false)) {
|
||||
continue;
|
||||
}
|
||||
animate(new Animation(5803));
|
||||
sendTeleport(player);
|
||||
player.getPacketDispatch().sendMessage("" + getLocation() + " matches? " + (getLocation().getX() == 2904));
|
||||
}
|
||||
if (location.getX() != 2930 && walkdir) {
|
||||
this.getWalkingQueue().reset();
|
||||
this.getWalkingQueue().addPath(location.getX() + 1,3463,true);
|
||||
} else if (location.getX() != 2904 && !walkdir) {
|
||||
this.getWalkingQueue().reset();
|
||||
this.getWalkingQueue().addPath(location.getX() - 1,3463,true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,165 +19,165 @@ import core.plugin.Initializable;
|
|||
@Initializable
|
||||
public class WitchsExperimentNPC extends AbstractNPC {
|
||||
|
||||
private ExperimentType type;
|
||||
private boolean commenced;
|
||||
Player p;
|
||||
private ExperimentType type;
|
||||
private boolean commenced;
|
||||
Player p;
|
||||
|
||||
public WitchsExperimentNPC() {
|
||||
super(0, null);
|
||||
}
|
||||
public WitchsExperimentNPC() {
|
||||
super(0, null);
|
||||
}
|
||||
|
||||
WitchsExperimentNPC(int id, Location location, Player player) {
|
||||
super(id, location);
|
||||
this.setWalks(true);
|
||||
this.setRespawn(false);
|
||||
this.type = WitchsExperimentNPC.ExperimentType.forId(id);
|
||||
p = player;
|
||||
}
|
||||
WitchsExperimentNPC(int id, Location location, Player player) {
|
||||
super(id, location);
|
||||
this.setWalks(true);
|
||||
this.setRespawn(false);
|
||||
this.type = WitchsExperimentNPC.ExperimentType.forId(id);
|
||||
p = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTickActions() {
|
||||
super.handleTickActions();
|
||||
if (!p.isActive() || !RegionManager.getLocalPlayers(location).contains(p)) {
|
||||
p.removeAttribute("witchs-experiment:npc_spawned");
|
||||
clear();
|
||||
}
|
||||
if (!getProperties().getCombatPulse().isAttacking()) {
|
||||
getProperties().getCombatPulse().attack(p);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void handleTickActions() {
|
||||
super.handleTickActions();
|
||||
if (!p.isActive() || !RegionManager.getLocalPlayers(location).contains(p)) {
|
||||
p.removeAttribute("witchs-experiment:npc_spawned");
|
||||
clear();
|
||||
}
|
||||
if (!getProperties().getCombatPulse().isAttacking()) {
|
||||
getProperties().getCombatPulse().attack(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDeath(Entity killer) {
|
||||
if (killer == p) {
|
||||
type.transform(this, p);
|
||||
return;
|
||||
}
|
||||
super.startDeath(killer);
|
||||
}
|
||||
@Override
|
||||
public void startDeath(Entity killer) {
|
||||
if (killer == p) {
|
||||
type.transform(this, p);
|
||||
return;
|
||||
}
|
||||
super.startDeath(killer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAttackable(Entity entity, CombatStyle style, boolean message) {
|
||||
return p == entity;
|
||||
}
|
||||
@Override
|
||||
public boolean isAttackable(Entity entity, CombatStyle style, boolean message) {
|
||||
return p == entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSelectTarget(Entity target) {
|
||||
if (target instanceof Player) {
|
||||
Player p = (Player) target;
|
||||
return p == this.p;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canSelectTarget(Entity target) {
|
||||
if (target instanceof Player) {
|
||||
Player p = (Player) target;
|
||||
return p == this.p;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AbstractNPC construct(int id, Location location, Object... objects) {
|
||||
return new WitchsExperimentNPC(id, location, null);
|
||||
}
|
||||
@Override
|
||||
public AbstractNPC construct(int id, Location location, Object... objects) {
|
||||
return new WitchsExperimentNPC(id, location, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 897, 898, 899, 900 };
|
||||
}
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 897, 898, 899, 900 };
|
||||
}
|
||||
|
||||
public void setType(ExperimentType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public void setType(ExperimentType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ExperimentType getType() {
|
||||
return type;
|
||||
}
|
||||
public ExperimentType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setCommenced(boolean commenced) {
|
||||
this.commenced = commenced;
|
||||
}
|
||||
public void setCommenced(boolean commenced) {
|
||||
this.commenced = commenced;
|
||||
}
|
||||
|
||||
public enum ExperimentType {
|
||||
FIRST(897, ""),
|
||||
SECOND(898, "The shapeshifter's body begins to deform!", "The shapeshifter turns into a spider!"),
|
||||
THIRD(899, "The shapeshifter's body begins to twist!", "The shapeshifter turns into a bear!"),
|
||||
FOURTH(900, "The shapeshifter's body pulses!", "The shapeshifter turns into a wolf!"),
|
||||
END(-1, ""),
|
||||
public enum ExperimentType {
|
||||
FIRST(897, ""),
|
||||
SECOND(898, "The shapeshifter's body begins to deform!", "The shapeshifter turns into a spider!"),
|
||||
THIRD(899, "The shapeshifter's body begins to twist!", "The shapeshifter turns into a bear!"),
|
||||
FOURTH(900, "The shapeshifter's body pulses!", "The shapeshifter turns into a wolf!"),
|
||||
END(-1, ""),
|
||||
|
||||
;
|
||||
;
|
||||
|
||||
private int id;
|
||||
private String[] message;
|
||||
private int id;
|
||||
private String[] message;
|
||||
|
||||
ExperimentType(int id, String... message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
ExperimentType(int id, String... message) {
|
||||
this.id = id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the new npc.
|
||||
*/
|
||||
public void transform(final WitchsExperimentNPC npc, final Player player) {
|
||||
final ExperimentType newType = next();
|
||||
npc.lock();
|
||||
npc.getPulseManager().clear();
|
||||
npc.getWalkingQueue().reset();
|
||||
player.setAttribute("/save:witchs_house:experiment_id",this.id);
|
||||
GameWorld.getPulser().submit(new Pulse(1, npc, player) {
|
||||
int counter;
|
||||
/**
|
||||
* Transforms the new npc.
|
||||
*/
|
||||
public void transform(final WitchsExperimentNPC npc, final Player player) {
|
||||
final ExperimentType newType = next();
|
||||
npc.lock();
|
||||
npc.getPulseManager().clear();
|
||||
npc.getWalkingQueue().reset();
|
||||
player.setAttribute("/save:witchs_house:experiment_id",this.id);
|
||||
GameWorld.getPulser().submit(new Pulse(1, npc, player) {
|
||||
int counter;
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
switch (++counter) {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
switch (++counter) {
|
||||
|
||||
case 1:
|
||||
npc.unlock();
|
||||
npc.getAnimator().reset();
|
||||
npc.fullRestore();
|
||||
npc.setType(newType);
|
||||
npc.transform(newType.getId());
|
||||
npc.getImpactHandler().setDisabledTicks(1);
|
||||
if (newType != END) {
|
||||
npc.getProperties().getCombatPulse().attack(player);
|
||||
}
|
||||
if (newType.getMessage() != null && newType != END) {
|
||||
player.sendMessage(newType.getMessage()[0]);
|
||||
player.sendMessage(newType.getMessage()[1]);
|
||||
}
|
||||
if (newType == END) {
|
||||
player.setAttribute("witchs_house:experiment_killed",true);
|
||||
npc.clear();
|
||||
return false;
|
||||
}
|
||||
player.unlock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case 1:
|
||||
npc.unlock();
|
||||
npc.getAnimator().reset();
|
||||
npc.fullRestore();
|
||||
npc.setType(newType);
|
||||
npc.transform(newType.getId());
|
||||
npc.getImpactHandler().setDisabledTicks(1);
|
||||
if (newType != END) {
|
||||
npc.getProperties().getCombatPulse().attack(player);
|
||||
}
|
||||
if (newType.getMessage() != null && newType != END) {
|
||||
player.sendMessage(newType.getMessage()[0]);
|
||||
player.sendMessage(newType.getMessage()[1]);
|
||||
}
|
||||
if (newType == END) {
|
||||
player.setAttribute("witchs_house:experiment_killed",true);
|
||||
npc.clear();
|
||||
return false;
|
||||
}
|
||||
player.unlock();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static ExperimentType forId(int id) {
|
||||
for (ExperimentType type : values()) {
|
||||
if (type.getId() == id) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static ExperimentType forId(int id) {
|
||||
for (ExperimentType type : values()) {
|
||||
if (type.getId() == id) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ExperimentType[] experimentTypes = values();
|
||||
private static ExperimentType[] experimentTypes = values();
|
||||
|
||||
public ExperimentType next()
|
||||
{
|
||||
return experimentTypes[this.ordinal() + 1];
|
||||
}
|
||||
public ExperimentType next()
|
||||
{
|
||||
return experimentTypes[this.ordinal() + 1];
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String[] getMessage() {
|
||||
return message;
|
||||
}
|
||||
public String[] getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -17,131 +17,131 @@ import core.tools.RandomFunction;
|
|||
|
||||
public class PvMBots extends AIPlayer {
|
||||
|
||||
//Used so the bot doesn't spam actions
|
||||
private int tick = 0;
|
||||
//Used so the bot doesn't spam actions
|
||||
private int tick = 0;
|
||||
|
||||
public PvMBots(Location l) {
|
||||
super(l);
|
||||
}
|
||||
public PvMBots(Location l) {
|
||||
super(l);
|
||||
}
|
||||
|
||||
public PvMBots(String copyFromFile, Location l) {
|
||||
super(copyFromFile, l);
|
||||
}
|
||||
public PvMBots(String copyFromFile, Location l) {
|
||||
super(copyFromFile, l);
|
||||
}
|
||||
|
||||
|
||||
public List<Entity> FindTargets(Entity entity, int radius) {
|
||||
List<Entity> targets = new ArrayList<>(20);
|
||||
Object[] localNPCs = RegionManager.getLocalNPCs(entity.getLocation(), radius).toArray();
|
||||
int length = localNPCs.length;
|
||||
if(length > 5){length = 5;}
|
||||
for (int i = 0; i < length; i++) {
|
||||
NPC npc = (NPC) localNPCs[i];
|
||||
{
|
||||
if (checkValidTargets(npc))
|
||||
targets.add(npc);
|
||||
}
|
||||
}
|
||||
if (targets.size() == 0)
|
||||
return null;
|
||||
return targets;
|
||||
}
|
||||
public List<Entity> FindTargets(Entity entity, int radius) {
|
||||
List<Entity> targets = new ArrayList<>(20);
|
||||
Object[] localNPCs = RegionManager.getLocalNPCs(entity.getLocation(), radius).toArray();
|
||||
int length = localNPCs.length;
|
||||
if(length > 5){length = 5;}
|
||||
for (int i = 0; i < length; i++) {
|
||||
NPC npc = (NPC) localNPCs[i];
|
||||
{
|
||||
if (checkValidTargets(npc))
|
||||
targets.add(npc);
|
||||
}
|
||||
}
|
||||
if (targets.size() == 0)
|
||||
return null;
|
||||
return targets;
|
||||
}
|
||||
|
||||
public boolean checkValidTargets(NPC target) {
|
||||
if (!target.isActive()) {
|
||||
return false;
|
||||
}
|
||||
if (!target.getProperties().isMultiZone() && target.inCombat()) {
|
||||
return false;
|
||||
}
|
||||
if (!target.getDefinition().hasAction("attack")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean checkValidTargets(NPC target) {
|
||||
if (!target.isActive()) {
|
||||
return false;
|
||||
}
|
||||
if (!target.getProperties().isMultiZone() && target.inCombat()) {
|
||||
return false;
|
||||
}
|
||||
if (!target.getDefinition().hasAction("attack")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean AttackNpcsInRadius(int radius)
|
||||
{
|
||||
return AttackNpcsInRadius(this, radius);
|
||||
}
|
||||
public boolean AttackNpcsInRadius(int radius)
|
||||
{
|
||||
return AttackNpcsInRadius(this, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attacks NPCs in radius of bot
|
||||
* @param bot
|
||||
* @param radius
|
||||
* @return true if bot will be fighting
|
||||
*/
|
||||
public boolean AttackNpcsInRadius(Player bot, int radius) {
|
||||
if (bot.inCombat())
|
||||
return true;
|
||||
List<Entity> creatures = FindTargets(bot, radius);
|
||||
if (creatures == null) {
|
||||
return false;
|
||||
}
|
||||
bot.attack(creatures.get(RandomFunction.getRandom((creatures.size() - 1))));
|
||||
if (!creatures.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
creatures = FindTargets(bot, radius);
|
||||
if (!creatures.isEmpty())
|
||||
{
|
||||
bot.attack(creatures.get(RandomFunction.getRandom((creatures.size() - 1))));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Attacks NPCs in radius of bot
|
||||
* @param bot
|
||||
* @param radius
|
||||
* @return true if bot will be fighting
|
||||
*/
|
||||
public boolean AttackNpcsInRadius(Player bot, int radius) {
|
||||
if (bot.inCombat())
|
||||
return true;
|
||||
List<Entity> creatures = FindTargets(bot, radius);
|
||||
if (creatures == null) {
|
||||
return false;
|
||||
}
|
||||
bot.attack(creatures.get(RandomFunction.getRandom((creatures.size() - 1))));
|
||||
if (!creatures.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
creatures = FindTargets(bot, radius);
|
||||
if (!creatures.isEmpty())
|
||||
{
|
||||
bot.attack(creatures.get(RandomFunction.getRandom((creatures.size() - 1))));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
this.tick++;
|
||||
this.tick++;
|
||||
|
||||
//Despawn
|
||||
if (this.getSkills().getLifepoints() <= 5){
|
||||
//TODO: Just respawn a new bot (not sure how you'd do that :L)
|
||||
// Maybe make all PvMBots know what to do if they aren't in right area? I.e. pest control bots teleport to PC
|
||||
//this.teleport(new Location(500, 500));
|
||||
//Despawning not being delayed causes 3 errors in the console
|
||||
this.getSkills().setLifepoints(20);
|
||||
}
|
||||
//Despawn
|
||||
if (this.getSkills().getLifepoints() <= 5){
|
||||
//TODO: Just respawn a new bot (not sure how you'd do that :L)
|
||||
// Maybe make all PvMBots know what to do if they aren't in right area? I.e. pest control bots teleport to PC
|
||||
//this.teleport(new Location(500, 500));
|
||||
//Despawning not being delayed causes 3 errors in the console
|
||||
this.getSkills().setLifepoints(20);
|
||||
}
|
||||
|
||||
//Npc Combat
|
||||
/*if (this.tick % 10 == 0) {
|
||||
if (!this.inCombat())
|
||||
AttackNpcsInRadius(this, 5);
|
||||
}*/
|
||||
//Npc Combat
|
||||
/*if (this.tick % 10 == 0) {
|
||||
if (!this.inCombat())
|
||||
AttackNpcsInRadius(this, 5);
|
||||
}*/
|
||||
|
||||
if (this.tick == 100) this.tick = 0;
|
||||
if (this.tick == 100) this.tick = 0;
|
||||
|
||||
//this.eat();
|
||||
//this.getPrayer().toggle()
|
||||
}
|
||||
//this.eat();
|
||||
//this.getPrayer().toggle()
|
||||
}
|
||||
|
||||
public void CheckPrayer(PrayerType type[]) {
|
||||
for (int i = 0; i < type.length; i++)
|
||||
this.getPrayer().toggle(type[i]);
|
||||
}
|
||||
public void CheckPrayer(PrayerType type[]) {
|
||||
for (int i = 0; i < type.length; i++)
|
||||
this.getPrayer().toggle(type[i]);
|
||||
}
|
||||
|
||||
public void eat(int foodId) {
|
||||
Item foodItem = new Item(foodId);
|
||||
public void eat(int foodId) {
|
||||
Item foodItem = new Item(foodId);
|
||||
|
||||
if ((this.getSkills().getStaticLevel(Skills.HITPOINTS) >= this.getSkills().getLifepoints() * 3) && this.getInventory().containsItem(foodItem)) {
|
||||
this.lock(3);
|
||||
//this.animate(new Animation(829));
|
||||
Item food = this.getInventory().getItem(foodItem);
|
||||
if ((this.getSkills().getStaticLevel(Skills.HITPOINTS) >= this.getSkills().getLifepoints() * 3) && this.getInventory().containsItem(foodItem)) {
|
||||
this.lock(3);
|
||||
//this.animate(new Animation(829));
|
||||
Item food = this.getInventory().getItem(foodItem);
|
||||
|
||||
Consumable consumable = Consumables.getConsumableById(food.getId()).getConsumable();
|
||||
Consumable consumable = Consumables.getConsumableById(food.getId()).getConsumable();
|
||||
|
||||
if (consumable == null) {
|
||||
return;
|
||||
}
|
||||
if (consumable == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
consumable.consume(food, this);
|
||||
this.getProperties().getCombatPulse().delayNextAttack(3);
|
||||
}
|
||||
if (this.checkVictimIsPlayer() == false)
|
||||
if (!(this.getInventory().contains(foodId, 1)))
|
||||
this.getInventory().add(new Item(foodId, 5)); //Add Food to Inventory
|
||||
}
|
||||
consumable.consume(food, this);
|
||||
this.getProperties().getCombatPulse().delayNextAttack(3);
|
||||
}
|
||||
if (this.checkVictimIsPlayer() == false)
|
||||
if (!(this.getInventory().contains(foodId, 1)))
|
||||
this.getInventory().add(new Item(foodId, 5)); //Add Food to Inventory
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,145 +202,145 @@ public abstract class MovementPulse extends Pulse {
|
|||
mover.scripts.removeNormalScripts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
if (!mover.getLocation().getRegion().isActive())
|
||||
return false;
|
||||
@Override
|
||||
public boolean update() {
|
||||
if (!mover.getLocation().getRegion().isActive())
|
||||
return false;
|
||||
|
||||
if (!isRunning()) return true;
|
||||
if (!isRunning()) return true;
|
||||
|
||||
if (!validate()) {
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
if (!validate()) {
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
|
||||
clearInferiorScripts();
|
||||
clearInferiorScripts();
|
||||
|
||||
mover.face(null);
|
||||
if (canInteractWithoutMoving()) {
|
||||
if (interactImmediately()) {
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
updatePath();
|
||||
mover.face(null);
|
||||
if (canInteractWithoutMoving()) {
|
||||
if (interactImmediately()) {
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
updatePath();
|
||||
|
||||
if (tryInteract()) {
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
if (tryInteract()) {
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean tryInteract() {
|
||||
Location ml = mover.getLocation();
|
||||
if (ml == null) {
|
||||
return false;
|
||||
}
|
||||
// Allow being within 1 square of moving entities to interact with them.
|
||||
int radius = destination instanceof Entity && ((Entity) destination).getWalkingQueue().hasPath() ? 1 : 0;
|
||||
if (interactLocation == null)
|
||||
return false;
|
||||
boolean atInteractLocation = Math.max(Math.abs(ml.getX() - interactLocation.getX()), Math.abs(ml.getY() - interactLocation.getY())) <= radius;
|
||||
// Check if already in a valid interaction position for entity destinations
|
||||
boolean canInteractFromCurrentPosition = false;
|
||||
if (!atInteractLocation && destination instanceof Entity) {
|
||||
Entity target = (Entity) destination;
|
||||
Location dl = target.getLocation();
|
||||
if (dl == null) {
|
||||
return false;
|
||||
}
|
||||
boolean onSameTile = ml.getX() == dl.getX() && ml.getY() == dl.getY() && ml.getZ() == dl.getZ();
|
||||
if (!onSameTile) {
|
||||
canInteractFromCurrentPosition = Pathfinder.canInteract(
|
||||
ml.getX(), ml.getY(), mover.size(),
|
||||
dl.getX(), dl.getY(), target.size(), target.size(),
|
||||
0, // walkFlag - "can interact from any unblocked direction"
|
||||
ml.getZ(),
|
||||
RegionManager::getClippingFlag);
|
||||
}
|
||||
}
|
||||
if (atInteractLocation || canInteractFromCurrentPosition) {
|
||||
try {
|
||||
if (near || pulse()) {
|
||||
if (mover instanceof Player) {
|
||||
if (near) {
|
||||
((Player) mover).getPacketDispatch().sendMessage("I can't reach that.");
|
||||
}
|
||||
PacketRepository.send(ClearMinimapFlag.class, new PlayerContext((Player) mover));
|
||||
}
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean tryInteract() {
|
||||
Location ml = mover.getLocation();
|
||||
if (ml == null) {
|
||||
return false;
|
||||
}
|
||||
// Allow being within 1 square of moving entities to interact with them.
|
||||
int radius = destination instanceof Entity && ((Entity) destination).getWalkingQueue().hasPath() ? 1 : 0;
|
||||
if (interactLocation == null)
|
||||
return false;
|
||||
boolean atInteractLocation = Math.max(Math.abs(ml.getX() - interactLocation.getX()), Math.abs(ml.getY() - interactLocation.getY())) <= radius;
|
||||
// Check if already in a valid interaction position for entity destinations
|
||||
boolean canInteractFromCurrentPosition = false;
|
||||
if (!atInteractLocation && destination instanceof Entity) {
|
||||
Entity target = (Entity) destination;
|
||||
Location dl = target.getLocation();
|
||||
if (dl == null) {
|
||||
return false;
|
||||
}
|
||||
boolean onSameTile = ml.getX() == dl.getX() && ml.getY() == dl.getY() && ml.getZ() == dl.getZ();
|
||||
if (!onSameTile) {
|
||||
canInteractFromCurrentPosition = Pathfinder.canInteract(
|
||||
ml.getX(), ml.getY(), mover.size(),
|
||||
dl.getX(), dl.getY(), target.size(), target.size(),
|
||||
0, // walkFlag - "can interact from any unblocked direction"
|
||||
ml.getZ(),
|
||||
RegionManager::getClippingFlag);
|
||||
}
|
||||
}
|
||||
if (atInteractLocation || canInteractFromCurrentPosition) {
|
||||
try {
|
||||
if (near || pulse()) {
|
||||
if (mover instanceof Player) {
|
||||
if (near) {
|
||||
((Player) mover).getPacketDispatch().sendMessage("I can't reach that.");
|
||||
}
|
||||
PacketRepository.send(ClearMinimapFlag.class, new PlayerContext((Player) mover));
|
||||
}
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the mover can interact with an entity destination from their
|
||||
* current position without needing to move.
|
||||
*
|
||||
* @return true if the mover can interact without moving
|
||||
*/
|
||||
private boolean canInteractWithoutMoving() {
|
||||
if (!(destination instanceof Entity)) {
|
||||
return false;
|
||||
}
|
||||
Entity target = (Entity) destination;
|
||||
Location ml = mover.getLocation();
|
||||
Location dl = target.getLocation();
|
||||
if (ml == null || dl == null) {
|
||||
return false;
|
||||
}
|
||||
if (ml.getX() == dl.getX() && ml.getY() == dl.getY() && ml.getZ() == dl.getZ()) {
|
||||
return false;
|
||||
}
|
||||
if (isInsideEntity(ml)) {
|
||||
return false;
|
||||
}
|
||||
if (target.getWalkingQueue().hasPath()) { // For moving entities, allow interaction from 1 tile away
|
||||
int distance = Math.max(
|
||||
Math.abs(ml.getX() - dl.getX()),
|
||||
Math.abs(ml.getY() - dl.getY()));
|
||||
if (distance <= target.size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Pathfinder.canInteract(
|
||||
ml.getX(), ml.getY(), mover.size(),
|
||||
dl.getX(), dl.getY(), target.size(), target.size(),
|
||||
0, // walkFlag - "can interact from any unblocked direction"
|
||||
ml.getZ(),
|
||||
RegionManager::getClippingFlag);
|
||||
}
|
||||
/**
|
||||
* Checks if the mover can interact with an entity destination from their
|
||||
* current position without needing to move.
|
||||
*
|
||||
* @return true if the mover can interact without moving
|
||||
*/
|
||||
private boolean canInteractWithoutMoving() {
|
||||
if (!(destination instanceof Entity)) {
|
||||
return false;
|
||||
}
|
||||
Entity target = (Entity) destination;
|
||||
Location ml = mover.getLocation();
|
||||
Location dl = target.getLocation();
|
||||
if (ml == null || dl == null) {
|
||||
return false;
|
||||
}
|
||||
if (ml.getX() == dl.getX() && ml.getY() == dl.getY() && ml.getZ() == dl.getZ()) {
|
||||
return false;
|
||||
}
|
||||
if (isInsideEntity(ml)) {
|
||||
return false;
|
||||
}
|
||||
if (target.getWalkingQueue().hasPath()) { // For moving entities, allow interaction from 1 tile away
|
||||
int distance = Math.max(
|
||||
Math.abs(ml.getX() - dl.getX()),
|
||||
Math.abs(ml.getY() - dl.getY()));
|
||||
if (distance <= target.size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Pathfinder.canInteract(
|
||||
ml.getX(), ml.getY(), mover.size(),
|
||||
dl.getX(), dl.getY(), target.size(), target.size(),
|
||||
0, // walkFlag - "can interact from any unblocked direction"
|
||||
ml.getZ(),
|
||||
RegionManager::getClippingFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately performs the interaction without pathfinding.
|
||||
* Called when the player is already in a valid interaction position.
|
||||
*
|
||||
* @return true if interaction was successful and pulse should stop
|
||||
*/
|
||||
private boolean interactImmediately() {
|
||||
if (destination instanceof Entity) {
|
||||
mover.face((Entity) destination);
|
||||
}
|
||||
try {
|
||||
if (pulse()) {
|
||||
if (mover instanceof Player) {
|
||||
PacketRepository.send(ClearMinimapFlag.class, new PlayerContext((Player) mover));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Immediately performs the interaction without pathfinding.
|
||||
* Called when the player is already in a valid interaction position.
|
||||
*
|
||||
* @return true if interaction was successful and pulse should stop
|
||||
*/
|
||||
private boolean interactImmediately() {
|
||||
if (destination instanceof Entity) {
|
||||
mover.face((Entity) destination);
|
||||
}
|
||||
try {
|
||||
if (pulse()) {
|
||||
if (mover instanceof Player) {
|
||||
PacketRepository.send(ClearMinimapFlag.class, new PlayerContext((Player) mover));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean validate() {
|
||||
if (mover == null || destination == null || mover.getLocation().getRegion() == null || hasInactiveNode()) {
|
||||
|
|
@ -466,49 +466,49 @@ public abstract class MovementPulse extends Pulse {
|
|||
return canMove;
|
||||
}
|
||||
|
||||
private Location checkForEntityPathInterrupt(Location loc) {
|
||||
Location ml = mover.getLocation();
|
||||
Location dl = destination.getLocation();
|
||||
// Lead the target if they're walking/running, unless they're already within interaction range
|
||||
if (loc != null && destination instanceof Entity) {
|
||||
WalkingQueue wq = ((Entity) destination).getWalkingQueue();
|
||||
if (wq.hasPath()) {
|
||||
Point[] points = wq.getQueue().toArray(new Point[0]);
|
||||
if (points.length > 0) {
|
||||
Point p = points[0];
|
||||
Point predictiveIntersection = null;
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
Location closestBorder = getClosestBorderToPoint(points[i], loc.getZ());
|
||||
private Location checkForEntityPathInterrupt(Location loc) {
|
||||
Location ml = mover.getLocation();
|
||||
Location dl = destination.getLocation();
|
||||
// Lead the target if they're walking/running, unless they're already within interaction range
|
||||
if (loc != null && destination instanceof Entity) {
|
||||
WalkingQueue wq = ((Entity) destination).getWalkingQueue();
|
||||
if (wq.hasPath()) {
|
||||
Point[] points = wq.getQueue().toArray(new Point[0]);
|
||||
if (points.length > 0) {
|
||||
Point p = points[0];
|
||||
Point predictiveIntersection = null;
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
Location closestBorder = getClosestBorderToPoint(points[i], loc.getZ());
|
||||
|
||||
if (!RegionManager.isTeleportPermitted(closestBorder)) { // A nasty hack to discard invalid intersection points
|
||||
continue;
|
||||
}
|
||||
int moverDist = Math.max(Math.abs(ml.getX() - closestBorder.getX()), Math.abs(ml.getY() - closestBorder.getY()));
|
||||
float movementRatio = moverDist / (float) ((i + 1) / (mover.getWalkingQueue().isRunning() ? 2 : 1));
|
||||
if (predictiveIntersection == null && movementRatio <= 1.0) { //try to predict an intersection point on the path if possible
|
||||
predictiveIntersection = points[i];
|
||||
break;
|
||||
}
|
||||
// Otherwise, we target the farthest point along target's planned movement that's within 1 tick's running,
|
||||
// this ensures the player will run to catch up to the target if able.
|
||||
if (moverDist <= 2) {
|
||||
p = points[i];
|
||||
}
|
||||
}
|
||||
if (predictiveIntersection != null)
|
||||
p = predictiveIntersection;
|
||||
if (!RegionManager.isTeleportPermitted(closestBorder)) { // A nasty hack to discard invalid intersection points
|
||||
continue;
|
||||
}
|
||||
int moverDist = Math.max(Math.abs(ml.getX() - closestBorder.getX()), Math.abs(ml.getY() - closestBorder.getY()));
|
||||
float movementRatio = moverDist / (float) ((i + 1) / (mover.getWalkingQueue().isRunning() ? 2 : 1));
|
||||
if (predictiveIntersection == null && movementRatio <= 1.0) { //try to predict an intersection point on the path if possible
|
||||
predictiveIntersection = points[i];
|
||||
break;
|
||||
}
|
||||
// Otherwise, we target the farthest point along target's planned movement that's within 1 tick's running,
|
||||
// this ensures the player will run to catch up to the target if able.
|
||||
if (moverDist <= 2) {
|
||||
p = points[i];
|
||||
}
|
||||
}
|
||||
if (predictiveIntersection != null)
|
||||
p = predictiveIntersection;
|
||||
|
||||
Location endLoc = getClosestBorderToPoint(p, loc.getZ());
|
||||
Location endLoc = getClosestBorderToPoint(p, loc.getZ());
|
||||
|
||||
if (!RegionManager.isTeleportPermitted(endLoc)) { // Basically a prayer
|
||||
return loc;
|
||||
}
|
||||
return endLoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
if (!RegionManager.isTeleportPermitted(endLoc)) { // Basically a prayer
|
||||
return loc;
|
||||
}
|
||||
return endLoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
private Location getClosestBorderToPoint (Point p, int plane) {
|
||||
Vector pathDiff = Vector.betweenLocs (destination.getLocation(), Location.create(p.getX(), p.getY(), plane));
|
||||
|
|
|
|||
|
|
@ -39,271 +39,271 @@ import content.data.Quests;
|
|||
*/
|
||||
public final class LoginConfiguration {
|
||||
|
||||
/**
|
||||
* The login plugins.
|
||||
*/
|
||||
private static final List<Plugin<Object>> LOGIN_PLUGINS = new ArrayList<>(20);
|
||||
/**
|
||||
* The login plugins.
|
||||
*/
|
||||
private static final List<Plugin<Object>> LOGIN_PLUGINS = new ArrayList<>(20);
|
||||
|
||||
/**
|
||||
* The lobby pane component.
|
||||
*/
|
||||
private static final Component LOBBY_PANE = new Component(549);
|
||||
/**
|
||||
* The lobby pane component.
|
||||
*/
|
||||
private static final Component LOBBY_PANE = new Component(549);
|
||||
|
||||
/**
|
||||
* The lobby interface component.
|
||||
*/
|
||||
private static final Component LOBBY_INTERFACE = new Component(378);
|
||||
/**
|
||||
* The lobby interface component.
|
||||
*/
|
||||
private static final Component LOBBY_INTERFACE = new Component(378);
|
||||
|
||||
/**
|
||||
* The lobby message of the week models & constant to be set for auto selecting the models
|
||||
*/
|
||||
private static final int[] MESSAGE_MODEL = {15, 16, 17, 18, 19, 20, 21, 22, 23, 405, 447, 622, 623, 679, 715, 800};
|
||||
private static int messModel;
|
||||
/**
|
||||
* The lobby message of the week models & constant to be set for auto selecting the models
|
||||
*/
|
||||
private static final int[] MESSAGE_MODEL = {15, 16, 17, 18, 19, 20, 21, 22, 23, 405, 447, 622, 623, 679, 715, 800};
|
||||
private static int messModel;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code LoginConfiguration} {@Code Object}
|
||||
*/
|
||||
public LoginConfiguration() {
|
||||
/*
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
/**
|
||||
* Constructs a new {@Code LoginConfiguration} {@Code Object}
|
||||
*/
|
||||
public LoginConfiguration() {
|
||||
/*
|
||||
* empty.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the lobby login.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
public static void configureLobby(Player player) {
|
||||
player.updateSceneGraph(true);
|
||||
if (!player.isArtificial() && player.getAttribute("tutorial:complete",false) && player.getAttribute("login_type", LoginType.NORMAL_LOGIN) != LoginType.RECONNECT_TYPE) {
|
||||
sendLobbyScreen(player);
|
||||
} else {
|
||||
configureGameWorld(player);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Configures the lobby login.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
public static void configureLobby(Player player) {
|
||||
player.updateSceneGraph(true);
|
||||
if (!player.isArtificial() && player.getAttribute("tutorial:complete",false) && player.getAttribute("login_type", LoginType.NORMAL_LOGIN) != LoginType.RECONNECT_TYPE) {
|
||||
sendLobbyScreen(player);
|
||||
} else {
|
||||
configureGameWorld(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the lobby interface-related packets.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
public static void sendLobbyScreen(Player player) {
|
||||
messModel = autoSelect();
|
||||
for(Player p : Repository.getLobbyPlayers()){
|
||||
if(p.getName().equals(player.getName())){
|
||||
p.clear();
|
||||
Repository.getLobbyPlayers().remove(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Repository.getLobbyPlayers().add(player);
|
||||
setInterfaceText(player, "Welcome to " + ServerConstants.SERVER_NAME, 378, 115);
|
||||
setInterfaceText(player, getLastLogin(player), 378, 116);
|
||||
setInterfaceText(player, "", 378, 37);
|
||||
setInterfaceText(player, "Want to stay up to date with the latest news and updates? Join our discord by using the link on our website!", 378, 38);
|
||||
setInterfaceText(player, "", 378, 39);
|
||||
setInterfaceText(player, "Discord Invite", 378, 14);
|
||||
setInterfaceText(player, "Discord Invite", 378, 129);
|
||||
setInterfaceText(player, "You can gain more credits by reporting bugs and various other methods of contribution.", 378, 93);
|
||||
setInterfaceText(player, player.getDetails().getCredits() + "", 378, 96);
|
||||
setInterfaceText(player, "Credits", 378, 94);
|
||||
setInterfaceText(player, "", 378, 229);
|
||||
setInterfaceText(player, "Want to contribute to " + ServerConstants.SERVER_NAME + "? Visit the GitLab using the link on our website!", 378, 230);
|
||||
setInterfaceText(player, "", 378, 231);
|
||||
setInterfaceText(player, "Github", 378, 240);
|
||||
setInterfaceText(player, GameWorld.getSettings().getMessage_string(), messModel, getMessageChild(messModel));
|
||||
player.getInterfaceManager().openWindowsPane(LOBBY_PANE);
|
||||
player.getInterfaceManager().setOpened(LOBBY_INTERFACE);
|
||||
PacketRepository.send(Interface.class, new InterfaceContext(player, LOBBY_PANE.getId(), 2, 378, true));
|
||||
PacketRepository.send(Interface.class, new InterfaceContext(player, LOBBY_PANE.getId(), 3, messModel, true));//UPDATE `configs` SET `value`=FLOOR(RAND()*(25-10)+10) WHERE key_="messageInterface"
|
||||
player.getDetails().setLastLogin(System.currentTimeMillis());
|
||||
}
|
||||
/**
|
||||
* Sends the lobby interface-related packets.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
public static void sendLobbyScreen(Player player) {
|
||||
messModel = autoSelect();
|
||||
for(Player p : Repository.getLobbyPlayers()){
|
||||
if(p.getName().equals(player.getName())){
|
||||
p.clear();
|
||||
Repository.getLobbyPlayers().remove(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Repository.getLobbyPlayers().add(player);
|
||||
setInterfaceText(player, "Welcome to " + ServerConstants.SERVER_NAME, 378, 115);
|
||||
setInterfaceText(player, getLastLogin(player), 378, 116);
|
||||
setInterfaceText(player, "", 378, 37);
|
||||
setInterfaceText(player, "Want to stay up to date with the latest news and updates? Join our discord by using the link on our website!", 378, 38);
|
||||
setInterfaceText(player, "", 378, 39);
|
||||
setInterfaceText(player, "Discord Invite", 378, 14);
|
||||
setInterfaceText(player, "Discord Invite", 378, 129);
|
||||
setInterfaceText(player, "You can gain more credits by reporting bugs and various other methods of contribution.", 378, 93);
|
||||
setInterfaceText(player, player.getDetails().getCredits() + "", 378, 96);
|
||||
setInterfaceText(player, "Credits", 378, 94);
|
||||
setInterfaceText(player, "", 378, 229);
|
||||
setInterfaceText(player, "Want to contribute to " + ServerConstants.SERVER_NAME + "? Visit the GitLab using the link on our website!", 378, 230);
|
||||
setInterfaceText(player, "", 378, 231);
|
||||
setInterfaceText(player, "Github", 378, 240);
|
||||
setInterfaceText(player, GameWorld.getSettings().getMessage_string(), messModel, getMessageChild(messModel));
|
||||
player.getInterfaceManager().openWindowsPane(LOBBY_PANE);
|
||||
player.getInterfaceManager().setOpened(LOBBY_INTERFACE);
|
||||
PacketRepository.send(Interface.class, new InterfaceContext(player, LOBBY_PANE.getId(), 2, 378, true));
|
||||
PacketRepository.send(Interface.class, new InterfaceContext(player, LOBBY_PANE.getId(), 3, messModel, true));//UPDATE `configs` SET `value`=FLOOR(RAND()*(25-10)+10) WHERE key_="messageInterface"
|
||||
player.getDetails().setLastLogin(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the game world.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
public static void configureGameWorld(final Player player) {
|
||||
sendGameConfiguration(player);
|
||||
Repository.getLobbyPlayers().remove(player);
|
||||
player.setPlaying(true);
|
||||
UpdateSequence.getRenderablePlayers().add(player);
|
||||
RegionManager.move(player, ServerConstants.START_LOCATION, player.getLocation());
|
||||
player.getMusicPlayer().init();
|
||||
player.updateAppearance();
|
||||
player.getPlayerFlags().setUpdateSceneGraph(true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(226, 1, true);
|
||||
/**
|
||||
* Configures the game world.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
public static void configureGameWorld(final Player player) {
|
||||
sendGameConfiguration(player);
|
||||
Repository.getLobbyPlayers().remove(player);
|
||||
player.setPlaying(true);
|
||||
UpdateSequence.getRenderablePlayers().add(player);
|
||||
RegionManager.move(player, ServerConstants.START_LOCATION, player.getLocation());
|
||||
player.getMusicPlayer().init();
|
||||
player.updateAppearance();
|
||||
player.getPlayerFlags().setUpdateSceneGraph(true);
|
||||
player.getPacketDispatch().sendInterfaceConfig(226, 1, true);
|
||||
|
||||
if (player.getGlobalData().getTestStage() == 3 && !player.getEmoteManager().isUnlocked(Emotes.SAFETY_FIRST)) {
|
||||
//TODO: port this to save version later. when you do, please also do this for the Explore emote, which has a similar problem (e.g. player_name.json has this).
|
||||
player.getEmoteManager().unlock(Emotes.SAFETY_FIRST);
|
||||
}
|
||||
if (player.getGlobalData().getTestStage() == 3 && !player.getEmoteManager().isUnlocked(Emotes.SAFETY_FIRST)) {
|
||||
//TODO: port this to save version later. when you do, please also do this for the Explore emote, which has a similar problem (e.g. player_name.json has this).
|
||||
player.getEmoteManager().unlock(Emotes.SAFETY_FIRST);
|
||||
}
|
||||
|
||||
for (Item item : player.getEquipment().toArray()) {
|
||||
//Run equip hooks for all items equipped on login.
|
||||
//We should have already been doing this.
|
||||
//Frankly, I don't even want to imagine the number of bugs us *not* doing this has caused.
|
||||
if (item == null) continue;
|
||||
player.getEquipment().remove(item);
|
||||
if (!InteractionListeners.run(item.getId(), player, item, true) || !player.getEquipment().add(item, true, false)) {
|
||||
player.sendMessage(colorize("%RAs you can no longer wear " + item.getName() + ", it has been unequipped."));
|
||||
addItemOrBank(player, item.getId(), item.getAmount());
|
||||
}
|
||||
}
|
||||
for (Item item : player.getEquipment().toArray()) {
|
||||
//Run equip hooks for all items equipped on login.
|
||||
//We should have already been doing this.
|
||||
//Frankly, I don't even want to imagine the number of bugs us *not* doing this has caused.
|
||||
if (item == null) continue;
|
||||
player.getEquipment().remove(item);
|
||||
if (!InteractionListeners.run(item.getId(), player, item, true) || !player.getEquipment().add(item, true, false)) {
|
||||
player.sendMessage(colorize("%RAs you can no longer wear " + item.getName() + ", it has been unequipped."));
|
||||
addItemOrBank(player, item.getId(), item.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
SpellBookManager.SpellBook currentSpellBook = SpellBookManager.SpellBook.forInterface(player.getSpellBookManager().getSpellBook());
|
||||
if (currentSpellBook == SpellBookManager.SpellBook.ANCIENT && !hasRequirement(player, Quests.DESERT_TREASURE)) {
|
||||
player.sendMessage(colorize("%RAs you can no longer use Ancient Magic, you have been set back to Modern."));
|
||||
player.getSpellBookManager().setSpellBook(SpellBookManager.SpellBook.MODERN);
|
||||
} else if (currentSpellBook == SpellBookManager.SpellBook.LUNAR && !hasRequirement(player, Quests.LUNAR_DIPLOMACY)) {
|
||||
player.sendMessage(colorize("%RAs you can no longer use Lunar Magic, you have been set back to Modern."));
|
||||
player.getSpellBookManager().setSpellBook(SpellBookManager.SpellBook.MODERN);
|
||||
}
|
||||
player.getSpellBookManager().update(player);
|
||||
SpellBookManager.SpellBook currentSpellBook = SpellBookManager.SpellBook.forInterface(player.getSpellBookManager().getSpellBook());
|
||||
if (currentSpellBook == SpellBookManager.SpellBook.ANCIENT && !hasRequirement(player, Quests.DESERT_TREASURE)) {
|
||||
player.sendMessage(colorize("%RAs you can no longer use Ancient Magic, you have been set back to Modern."));
|
||||
player.getSpellBookManager().setSpellBook(SpellBookManager.SpellBook.MODERN);
|
||||
} else if (currentSpellBook == SpellBookManager.SpellBook.LUNAR && !hasRequirement(player, Quests.LUNAR_DIPLOMACY)) {
|
||||
player.sendMessage(colorize("%RAs you can no longer use Lunar Magic, you have been set back to Modern."));
|
||||
player.getSpellBookManager().setSpellBook(SpellBookManager.SpellBook.MODERN);
|
||||
}
|
||||
player.getSpellBookManager().update(player);
|
||||
|
||||
// 1050 is checked client-side for making piety/chivalry disallowed sfx, likely due to the minigame requirement.
|
||||
// Set it here unconditionally until the minigame is implemented.
|
||||
if (hasRequirement(player, Quests.KINGS_RANSOM, false)) {
|
||||
setVarbit(player, 3909, 8, false);
|
||||
}
|
||||
if(ServerConstants.RULES_AND_INFO_ENABLED)
|
||||
RulesAndInfo.openFor(player);
|
||||
/*if (TutorialSession.getExtension(player).getStage() != 73) {
|
||||
TutorialStage.load(player, TutorialSession.getExtension(player).getStage(), true);
|
||||
}*/
|
||||
}
|
||||
// 1050 is checked client-side for making piety/chivalry disallowed sfx, likely due to the minigame requirement.
|
||||
// Set it here unconditionally until the minigame is implemented.
|
||||
if (hasRequirement(player, Quests.KINGS_RANSOM, false)) {
|
||||
setVarbit(player, 3909, 8, false);
|
||||
}
|
||||
if(ServerConstants.RULES_AND_INFO_ENABLED)
|
||||
RulesAndInfo.openFor(player);
|
||||
/*if (TutorialSession.getExtension(player).getStage() != 73) {
|
||||
TutorialStage.load(player, TutorialSession.getExtension(player).getStage(), true);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the game configuration packets.
|
||||
*
|
||||
* @param player The player to send to.
|
||||
*/
|
||||
public static void sendGameConfiguration(final Player player) {
|
||||
player.getInterfaceManager().openWindowsPane(new Component(player.getInterfaceManager().isResizable() ? 746 : 548));
|
||||
player.getInterfaceManager().openChatbox(137);
|
||||
player.getInterfaceManager().openDefaultTabs();
|
||||
welcome(player);
|
||||
config(player);
|
||||
for (Plugin<Object> plugin : LOGIN_PLUGINS) {
|
||||
try {
|
||||
plugin.newInstance(player);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
player.getAppearance().sync();
|
||||
}
|
||||
/**
|
||||
* Sends the game configuration packets.
|
||||
*
|
||||
* @param player The player to send to.
|
||||
*/
|
||||
public static void sendGameConfiguration(final Player player) {
|
||||
player.getInterfaceManager().openWindowsPane(new Component(player.getInterfaceManager().isResizable() ? 746 : 548));
|
||||
player.getInterfaceManager().openChatbox(137);
|
||||
player.getInterfaceManager().openDefaultTabs();
|
||||
welcome(player);
|
||||
config(player);
|
||||
for (Plugin<Object> plugin : LOGIN_PLUGINS) {
|
||||
try {
|
||||
plugin.newInstance(player);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
player.getAppearance().sync();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to welcome the player.
|
||||
*
|
||||
* @param player the player. Fullscreen mode Object id:
|
||||
*/
|
||||
public static final void welcome(final Player player) {
|
||||
if (player.isArtificial()) {
|
||||
return;
|
||||
}
|
||||
player.getPacketDispatch().sendMessage("Welcome to " + ServerConstants.SERVER_NAME + ".");
|
||||
if (player.getDetails().isMuted()) {
|
||||
player.getPacketDispatch().sendMessage("You are muted.");
|
||||
player.getPacketDispatch().sendMessage("To prevent further mutes please read the rules.");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method used to welcome the player.
|
||||
*
|
||||
* @param player the player. Fullscreen mode Object id:
|
||||
*/
|
||||
public static final void welcome(final Player player) {
|
||||
if (player.isArtificial()) {
|
||||
return;
|
||||
}
|
||||
player.getPacketDispatch().sendMessage("Welcome to " + ServerConstants.SERVER_NAME + ".");
|
||||
if (player.getDetails().isMuted()) {
|
||||
player.getPacketDispatch().sendMessage("You are muted.");
|
||||
player.getPacketDispatch().sendMessage("To prevent further mutes please read the rules.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to configure all possible settings for the player.
|
||||
*
|
||||
* @param player the player.
|
||||
*/
|
||||
public static final void config(final Player player) {
|
||||
if(!player.isArtificial())
|
||||
log(LoginConfiguration.class, Log.INFO, "configuring player " + player.getUsername());
|
||||
player.getInventory().refresh();
|
||||
player.getEquipment().refresh();
|
||||
player.getSkills().refresh();
|
||||
player.getSkills().configure();
|
||||
player.getSettings().update();
|
||||
player.getInteraction().setDefault();
|
||||
player.getPacketDispatch().sendRunEnergy();
|
||||
player.getFamiliarManager().login();
|
||||
player.getInterfaceManager().openDefaultTabs();
|
||||
setInterfaceText(player, "Friends List - " + ServerConstants.SERVER_NAME + " " + GameWorld.getSettings().getWorldId(), 550, 3);
|
||||
setInterfaceText(player, "When you have finished playing " + ServerConstants.SERVER_NAME + ", always use the button below to logout safely.", 182, 0);
|
||||
player.getQuestRepository().syncronizeTab(player);
|
||||
player.getInterfaceManager().close();
|
||||
player.getEmoteManager().refresh();
|
||||
player.getInterfaceManager().openInfoBars();
|
||||
if(!player.isArtificial())
|
||||
log(LoginConfiguration.class, Log.INFO, "finished configuring player " + player.getUsername());
|
||||
}
|
||||
/**
|
||||
* Method used to configure all possible settings for the player.
|
||||
*
|
||||
* @param player the player.
|
||||
*/
|
||||
public static final void config(final Player player) {
|
||||
if(!player.isArtificial())
|
||||
log(LoginConfiguration.class, Log.INFO, "configuring player " + player.getUsername());
|
||||
player.getInventory().refresh();
|
||||
player.getEquipment().refresh();
|
||||
player.getSkills().refresh();
|
||||
player.getSkills().configure();
|
||||
player.getSettings().update();
|
||||
player.getInteraction().setDefault();
|
||||
player.getPacketDispatch().sendRunEnergy();
|
||||
player.getFamiliarManager().login();
|
||||
player.getInterfaceManager().openDefaultTabs();
|
||||
setInterfaceText(player, "Friends List - " + ServerConstants.SERVER_NAME + " " + GameWorld.getSettings().getWorldId(), 550, 3);
|
||||
setInterfaceText(player, "When you have finished playing " + ServerConstants.SERVER_NAME + ", always use the button below to logout safely.", 182, 0);
|
||||
player.getQuestRepository().syncronizeTab(player);
|
||||
player.getInterfaceManager().close();
|
||||
player.getEmoteManager().refresh();
|
||||
player.getInterfaceManager().openInfoBars();
|
||||
if(!player.isArtificial())
|
||||
log(LoginConfiguration.class, Log.INFO, "finished configuring player " + player.getUsername());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message child for the inter id.
|
||||
* @notice GameSettings.kt contains the list of what these are
|
||||
* @param interfaceId The interface id.
|
||||
* @return The child id.
|
||||
*/
|
||||
public static int getMessageChild(int interfaceId) {
|
||||
if (interfaceId == 622) {
|
||||
return 8;
|
||||
} else if (interfaceId == 16) {
|
||||
return 6;
|
||||
} else if (interfaceId == 20 || interfaceId == 623) {
|
||||
return 5;
|
||||
} else if (interfaceId == 15 || interfaceId == 18 || interfaceId == 19 || interfaceId == 21 || interfaceId == 22 || interfaceId == 447 || interfaceId == 405) {
|
||||
return 4;
|
||||
} else if (interfaceId == 17 || interfaceId == 23 || interfaceId == 800) {
|
||||
return 3;
|
||||
} else if (interfaceId == 715) {
|
||||
return 2;
|
||||
} else if (interfaceId == 679) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Gets the message child for the inter id.
|
||||
* @notice GameSettings.kt contains the list of what these are
|
||||
* @param interfaceId The interface id.
|
||||
* @return The child id.
|
||||
*/
|
||||
public static int getMessageChild(int interfaceId) {
|
||||
if (interfaceId == 622) {
|
||||
return 8;
|
||||
} else if (interfaceId == 16) {
|
||||
return 6;
|
||||
} else if (interfaceId == 20 || interfaceId == 623) {
|
||||
return 5;
|
||||
} else if (interfaceId == 15 || interfaceId == 18 || interfaceId == 19 || interfaceId == 21 || interfaceId == 22 || interfaceId == 447 || interfaceId == 405) {
|
||||
return 4;
|
||||
} else if (interfaceId == 17 || interfaceId == 23 || interfaceId == 800) {
|
||||
return 3;
|
||||
} else if (interfaceId == 715) {
|
||||
return 2;
|
||||
} else if (interfaceId == 679) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a random interface id for the "message of the week" models
|
||||
*/
|
||||
private final static int autoSelect() {
|
||||
boolean contains = IntStream.of(MESSAGE_MODEL).anyMatch(x -> x == GameWorld.getSettings().getMessage_model());
|
||||
return contains ? GameWorld.getSettings().getMessage_model():MESSAGE_MODEL[new Random().nextInt(MESSAGE_MODEL.length)];
|
||||
}
|
||||
/**
|
||||
* Sets a random interface id for the "message of the week" models
|
||||
*/
|
||||
private final static int autoSelect() {
|
||||
boolean contains = IntStream.of(MESSAGE_MODEL).anyMatch(x -> x == GameWorld.getSettings().getMessage_model());
|
||||
return contains ? GameWorld.getSettings().getMessage_model():MESSAGE_MODEL[new Random().nextInt(MESSAGE_MODEL.length)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last login string for the lobby.
|
||||
*
|
||||
* @param player the player.
|
||||
* @return the last login.
|
||||
*/
|
||||
public static String getLastLogin(Player player) {
|
||||
player.getPacketDispatch().sendLastLoginInfo();
|
||||
String string = "You last logged in @timeAgo from:";
|
||||
long time = player.getDetails().getLastLogin();
|
||||
Date lastLogin = new Date(time);
|
||||
Date current = new Date();
|
||||
long diff = current.getTime() - lastLogin.getTime();
|
||||
int days = (int) TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
|
||||
if (days < 1) {
|
||||
string = string.replace("@timeAgo", "earlier today");
|
||||
} else if (days == 1) {
|
||||
string = string.replace("@timeAgo", "yesterday");
|
||||
} else {
|
||||
string = string.replace("@timeAgo", days + " days ago");
|
||||
}
|
||||
return string;
|
||||
}
|
||||
/**
|
||||
* Gets the last login string for the lobby.
|
||||
*
|
||||
* @param player the player.
|
||||
* @return the last login.
|
||||
*/
|
||||
public static String getLastLogin(Player player) {
|
||||
player.getPacketDispatch().sendLastLoginInfo();
|
||||
String string = "You last logged in @timeAgo from:";
|
||||
long time = player.getDetails().getLastLogin();
|
||||
Date lastLogin = new Date(time);
|
||||
Date current = new Date();
|
||||
long diff = current.getTime() - lastLogin.getTime();
|
||||
int days = (int) TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
|
||||
if (days < 1) {
|
||||
string = string.replace("@timeAgo", "earlier today");
|
||||
} else if (days == 1) {
|
||||
string = string.replace("@timeAgo", "yesterday");
|
||||
} else {
|
||||
string = string.replace("@timeAgo", days + " days ago");
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the loginPlugins.
|
||||
*
|
||||
* @return The loginPlugins.
|
||||
*/
|
||||
public static List<Plugin<Object>> getLoginPlugins() {
|
||||
return LOGIN_PLUGINS;
|
||||
}
|
||||
/**
|
||||
* Gets the loginPlugins.
|
||||
*
|
||||
* @return The loginPlugins.
|
||||
*/
|
||||
public static List<Plugin<Object>> getLoginPlugins() {
|
||||
return LOGIN_PLUGINS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue