From 4d52be73fd1ca9081163daf9ad19e850a765b7df Mon Sep 17 00:00:00 2001 From: Ceikry Date: Fri, 9 Jul 2021 23:12:56 +0000 Subject: [PATCH] Properly handled Rellekka's sailing map --- Server/data/configs/npc_spawns.json | 8 +++ .../zone/rellekka/MariaGunnarsDialogue.java | 6 ++- .../content/zone/rellekka/RellekkaZone.java | 36 -------------- .../content/zone/rellekka/SailorDialogue.java | 12 +++-- Server/src/main/kotlin/api/ContentAPI.kt | 31 ++++++++++++ .../area/jatizso/MordGunnarsDialogue.kt | 49 +++++++++++++++++++ .../game/interaction/InteractionListeners.kt | 3 +- .../region/{ => rellekka}/JatizsoListeners.kt | 3 +- .../{ => rellekka}/RellekkaListeners.kt | 25 +++++++++- .../system/command/oldsys/VisualCommand.kt | 49 ++++++++++++++++--- .../util/region/rellekka/RellekkaUtils.kt | 35 +++++++++++++ 11 files changed, 204 insertions(+), 53 deletions(-) create mode 100644 Server/src/main/kotlin/rs09/game/content/dialogue/area/jatizso/MordGunnarsDialogue.kt rename Server/src/main/kotlin/rs09/game/interaction/region/{ => rellekka}/JatizsoListeners.kt (98%) rename Server/src/main/kotlin/rs09/game/interaction/region/{ => rellekka}/RellekkaListeners.kt (60%) create mode 100644 Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt diff --git a/Server/data/configs/npc_spawns.json b/Server/data/configs/npc_spawns.json index 54fd909da..323111de9 100644 --- a/Server/data/configs/npc_spawns.json +++ b/Server/data/configs/npc_spawns.json @@ -10674,5 +10674,13 @@ { "npc_id": "5492", "loc_data": "{2387,3797,0,0,3}-{2414,3825,0,0,1}-{2414,3795,0,0,6}" + }, + { + "npc_id": "5481", + "loc_data": "{2644,3709,0,1,0}" + }, + { + "npc_id": "5482", + "loc_data": "{2422,3781,0,1,0}" } ] \ No newline at end of file diff --git a/Server/src/main/java/core/game/content/zone/rellekka/MariaGunnarsDialogue.java b/Server/src/main/java/core/game/content/zone/rellekka/MariaGunnarsDialogue.java index c64867e42..6c96cdf01 100644 --- a/Server/src/main/java/core/game/content/zone/rellekka/MariaGunnarsDialogue.java +++ b/Server/src/main/java/core/game/content/zone/rellekka/MariaGunnarsDialogue.java @@ -4,6 +4,8 @@ import core.game.content.dialogue.DialoguePlugin; import core.game.node.entity.npc.NPC; import core.game.node.entity.player.Player; import core.game.world.map.Location; +import rs09.game.util.region.rellekka.RellekkaDestination; +import rs09.game.util.region.rellekka.RellekkaUtils; /** * Handles the maria gunnars dialogue. @@ -62,9 +64,9 @@ public class MariaGunnarsDialogue extends DialoguePlugin { break; case 3: if (npc.getId() == 5508) { - RellekkaZone.sail(player, "Relleka", new Location(2310, 3782, 0)); + RellekkaUtils.sail(player, RellekkaDestination.RELLEKKA_TO_NEITIZNOT); } else { - RellekkaZone.sail(player, "Neitiznot", new Location(2644, 3710, 0)); + RellekkaUtils.sail(player, RellekkaDestination.NEITIZNOT_TO_RELLEKKA); } end(); break; diff --git a/Server/src/main/java/core/game/content/zone/rellekka/RellekkaZone.java b/Server/src/main/java/core/game/content/zone/rellekka/RellekkaZone.java index 299a833da..1f55183c6 100644 --- a/Server/src/main/java/core/game/content/zone/rellekka/RellekkaZone.java +++ b/Server/src/main/java/core/game/content/zone/rellekka/RellekkaZone.java @@ -49,13 +49,11 @@ public final class RellekkaZone extends MapZone implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - NPCDefinition.forId(5507).getHandlers().put("option:ferry-rellekka", this); return this; } @Override public boolean handle(Player player, Node node, String option) { - sail(player, "Relleka", new Location(2644, 3710, 0)); return true; } @@ -107,11 +105,6 @@ public final class RellekkaZone extends MapZone implements Plugin { return true; } break; - case 5508: - if (option.getName().equals("Ferry-Neitiznot")) { - sail(player, "Neitiznot", new Location(2310, 3782, 0)); - } - return true; } } return super.interact(e, target, option); @@ -127,35 +120,6 @@ public final class RellekkaZone extends MapZone implements Plugin { register(new ZoneBorders(2602, 3639, 2739, 3741)); } - /** - * Sails a player using the relleka ships. - * @param player the player. - * @param name the name. - * @param destination the destination. - */ - public static void sail(final Player player, final String name, final Location destination) { - player.lock(); - player.getInterfaceManager().open(new Component(224)); - player.addExtension(LogoutTask.class, new LocationLogoutTask(5, destination)); - GameWorld.getPulser().submit(new Pulse(1, player) { - int count; - - @Override - public boolean pulse() { - switch (++count) { - case 5: - player.unlock(); - player.getInterfaceManager().close(); - player.getProperties().setTeleportLocation(destination); - player.getDialogueInterpreter().sendDialogue("The ship arrives at " + name + "."); - return true; - } - return false; - } - - }); - } - /** * Handles options related to relleka. * @author Vexia diff --git a/Server/src/main/java/core/game/content/zone/rellekka/SailorDialogue.java b/Server/src/main/java/core/game/content/zone/rellekka/SailorDialogue.java index ab9210a08..5e5b12e60 100644 --- a/Server/src/main/java/core/game/content/zone/rellekka/SailorDialogue.java +++ b/Server/src/main/java/core/game/content/zone/rellekka/SailorDialogue.java @@ -5,6 +5,8 @@ import core.game.node.entity.npc.NPC; import core.game.node.entity.player.Player; import core.game.world.map.Location; +import static rs09.tools.DialogueConstKt.END_DIALOGUE; + /** * Handles the sailor dialogue. * @author Vexia @@ -40,7 +42,7 @@ public final class SailorDialogue extends DialoguePlugin { public boolean open(Object... args) { npc = (NPC) args[0]; rellekaNpc = npc.getId() == 1385; - player("Hello. Can I get a ride on your ship?"); + player("Ship's closed due to stingrays?"); return true; } @@ -48,8 +50,10 @@ public final class SailorDialogue extends DialoguePlugin { public boolean handle(int interfaceId, int buttonId) { switch (stage) { case 0: - npc("Hello again, brother " + player.getUsername() + ". If you're ready to jump", "aboard, we're all ready to set sail with the tide!"); - stage++; + npc("Yes."); + stage = END_DIALOGUE; + //npc("Hello again, brother " + player.getUsername() + ". If you're ready to jump", "aboard, we're all ready to set sail with the tide!"); + //stage++; break; case 1: player("Let's go!"); @@ -59,7 +63,7 @@ public final class SailorDialogue extends DialoguePlugin { end(); player.lock(); player.sendMessage("You board the longship..."); - RellekkaZone.sail(player, rellekaNpc ? "Miscellania" : "Rellekka", rellekaNpc ? Location.create(2581, 3845, 0) : Location.create(2629, 3693, 0)); + //RellekkaZone.sail(player, rellekaNpc ? "Miscellania" : "Rellekka", rellekaNpc ? Location.create(2581, 3845, 0) : Location.create(2629, 3693, 0)); break; } return true; diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index 2f4fa55f9..bab015fc6 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -435,6 +435,25 @@ object ContentAPI { player.interfaceManager.open(Component(id)) } + /** + * Opens the given interface as an overlay for the given player + * @param player the player to open the interface for + * @param id the ID of the interface to open + */ + @JvmStatic + fun openOverlay(player: Player, id: Int){ + player.interfaceManager.openOverlay(Component(id)) + } + + /** + * Closes any open overlays for the given player + * @param player the player to close for + */ + @JvmStatic + fun closeOverlay(player: Player){ + player.interfaceManager.closeOverlay() + } + /** * Runs the given Emote for the given Entity * @param entity the entity to run the emote on @@ -1094,4 +1113,16 @@ object ContentAPI { ZoneBuilder.configure(zone) zone.register(borders) } + + /** + * Animates a component of an interface. + * @param player the player to animate the interface for. + * @param iface the ID of the interface to animate. + * @param child the child on the interface to animate. + * @param anim the ID of the animation to use. + */ + @JvmStatic + fun animateInterface(player: Player, iface: Int, child: Int, anim: Int){ + player.packetDispatch.sendAnimationInterface(anim,iface,child) + } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/dialogue/area/jatizso/MordGunnarsDialogue.kt b/Server/src/main/kotlin/rs09/game/content/dialogue/area/jatizso/MordGunnarsDialogue.kt new file mode 100644 index 000000000..5a1eb28a1 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/content/dialogue/area/jatizso/MordGunnarsDialogue.kt @@ -0,0 +1,49 @@ +package rs09.game.content.dialogue.area.jatizso + +import core.game.content.dialogue.DialoguePlugin +import core.game.content.dialogue.FacialExpression +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.plugin.Initializable +import org.rs09.consts.NPCs +import rs09.game.util.region.rellekka.RellekkaDestination +import rs09.game.util.region.rellekka.RellekkaUtils +import rs09.tools.END_DIALOGUE + +@Initializable +class MordGunnarsDialogue(player: Player? = null) : DialoguePlugin(player) { + override fun newInstance(player: Player?): DialoguePlugin { + return MordGunnarsDialogue(player) + } + + override fun open(vararg args: Any?): Boolean { + npc = args[0] as NPC + if(npc.id == NPCs.MORD_GUNNARS_5481){ + npcl(FacialExpression.FRIENDLY, "Would you like to sail to Jatizso?") + } else { + npcl(FacialExpression.FRIENDLY, "Would you like to sail back to Rellekka?") + } + return true + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when(stage){ + 0 -> options("Yes, please.", "No, thanks.").also { stage++ } + 1 -> when(buttonId){ + 1 -> playerl(FacialExpression.FRIENDLY, "Yes, please!").also { stage++ } + 2 -> playerl(FacialExpression.FRIENDLY, "No, thank you.").also { stage = END_DIALOGUE } + } + + 2 -> { + end() + RellekkaUtils.sail(player, if(npc.id == NPCs.MORD_GUNNARS_5481) RellekkaDestination.RELLEKKA_TO_JATIZSO else RellekkaDestination.JATIZSO_TO_RELLEKKA) + } + } + return true + } + + override fun getIds(): IntArray { + return intArrayOf(NPCs.MORD_GUNNARS_5482, NPCs.MORD_GUNNARS_5481) + } + +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt index ce32d75e9..afb8f8587 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt @@ -172,8 +172,6 @@ object InteractionListeners { else -> DestinationFlag.OBJECT } - if(player.zoneMonitor.interact(node, Option(option, 0))) return true - if(player.locks.isInteractionLocked) return false val method = get(id,type,option) ?: get(option,type) ?: return false @@ -185,6 +183,7 @@ object InteractionListeners { if(player.locks.isMovementLocked) return false player.pulseManager.run(object : MovementPulse(player, node, flag, destOverride) { override fun pulse(): Boolean { + if(player.zoneMonitor.interact(node, Option(option, 0))) return true player.faceLocation(node.location) method.invoke(player,node) return true diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/JatizsoListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/JatizsoListeners.kt similarity index 98% rename from Server/src/main/kotlin/rs09/game/interaction/region/JatizsoListeners.kt rename to Server/src/main/kotlin/rs09/game/interaction/region/rellekka/JatizsoListeners.kt index e76441975..ceb9486c7 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/JatizsoListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/JatizsoListeners.kt @@ -1,4 +1,4 @@ -package rs09.game.interaction.region +package rs09.game.interaction.region.rellekka import api.ContentAPI import core.game.node.entity.npc.NPC @@ -8,7 +8,6 @@ import core.game.world.map.Direction import core.game.world.map.Location import core.game.world.map.zone.ZoneBorders import org.rs09.consts.NPCs -import rs09.game.camerautils.PlayerCamera import rs09.game.content.dialogue.area.jatizso.LeftieRightieDialogue import rs09.game.interaction.InteractionListener diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/RellekkaListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/RellekkaListeners.kt similarity index 60% rename from Server/src/main/kotlin/rs09/game/interaction/region/RellekkaListeners.kt rename to Server/src/main/kotlin/rs09/game/interaction/region/rellekka/RellekkaListeners.kt index 1edfc93a6..b330b22c6 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/region/RellekkaListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/rellekka/RellekkaListeners.kt @@ -1,7 +1,10 @@ -package rs09.game.interaction.region +package rs09.game.interaction.region.rellekka import core.game.world.map.Location +import org.rs09.consts.NPCs import rs09.game.interaction.InteractionListener +import rs09.game.util.region.rellekka.RellekkaDestination +import rs09.game.util.region.rellekka.RellekkaUtils /** * File to be used for anything Rellekka related. @@ -43,5 +46,25 @@ class RellekkaListeners : InteractionListener() { } return@on true } + + on(NPCs.MARIA_GUNNARS_5508, NPC, "ferry-neitiznot"){player, _ -> + RellekkaUtils.sail(player, RellekkaDestination.RELLEKKA_TO_NEITIZNOT) + return@on true + } + + on(NPCs.MARIA_GUNNARS_5507, NPC, "ferry-rellekka"){player, node -> + RellekkaUtils.sail(player, RellekkaDestination.NEITIZNOT_TO_RELLEKKA) + return@on true + } + + on(NPCs.MORD_GUNNARS_5481, NPC, "ferry-jatizso"){player, node -> + RellekkaUtils.sail(player, RellekkaDestination.RELLEKKA_TO_JATIZSO) + return@on true + } + + on(NPCs.MORD_GUNNARS_5482, NPC, "ferry-rellekka"){player, node -> + RellekkaUtils.sail(player, RellekkaDestination.JATIZSO_TO_RELLEKKA) + return@on true + } } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt b/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt index 407174dfb..be2a5a0bb 100644 --- a/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt +++ b/Server/src/main/kotlin/rs09/game/system/command/oldsys/VisualCommand.kt @@ -1,5 +1,6 @@ package rs09.game.system.command.oldsys +import api.ContentAPI import core.cache.Cache import core.game.container.access.InterfaceContainer import core.game.content.quest.tutorials.tutorialisland.CharacterDesign @@ -187,6 +188,8 @@ class VisualCommand : CommandPlugin() { return true } player!!.packetDispatch.sendSceneryAnimation(`object`, Animation(toInteger(args[args.size - 1]!!))) + //ContentAPI.sendMessage(player, `object`.definition.modelIds.map { it.toString() }.toString()) + ContentAPI.sendMessage(player, `object`.definition.animationId.toString()) return true } "inter", "component", "interface" -> { @@ -215,16 +218,50 @@ class VisualCommand : CommandPlugin() { } "loop_varposition" -> { val value = (args!![1]!!.toString().toInt()) ?: 0 - val config_index = (args!![2]!!.toString().toInt()) - GameWorld.Pulser.submit(object : Pulse(3, player) { - var pos = 0 + val cfg_index = (args.getOrNull(2)?.toString()?.toInt() ?: -1) + if(cfg_index == -1){ + ContentAPI.submitWorldPulse(object : Pulse(3, player){ + var pos = 0 + var shift = 0 + override fun pulse(): Boolean { + for(i in 0..1999){ + player?.configManager?.forceSet(i, pos shl shift, false) + } + player?.sendMessage("$pos << $shift") + if(pos++ >= 32){ + shift += 4 + pos = 0 + } + return shift >= 32 + } + }) + } else { + ContentAPI.submitWorldPulse(object : Pulse(3, player) { + var pos = 0 + override fun pulse(): Boolean { + player?.configManager?.forceSet(cfg_index, value shl pos, false) + player?.sendMessage("$pos") + return pos++ >= 32 + } + }) + } + } + "loop_anim_on_i" -> { + var anim = toInteger(args!![1]!!) + ContentAPI.submitWorldPulse(object : Pulse(3){ override fun pulse(): Boolean { - player?.configManager?.forceSet(config_index, value shl pos,false) - player?.sendMessage("$pos") - return pos++ >= 32 + player!!.packetDispatch.sendAnimationInterface(anim++, 224, 7) + ContentAPI.sendMessage(player, "${anim - 1}") + return false } }) } + "send_i_anim" -> { + val iface = args?.getOrNull(0) ?: return true + val anim = args.getOrNull(1) ?: return true + + player?.packetDispatch?.sendAnimationInterface(toInteger(anim), toInteger(iface),7) + } "loop_inter" -> { val st = toInteger(args!![1]!!) val en = if (args.size > 2) toInteger(args[2]!!) else 740 diff --git a/Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt b/Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt new file mode 100644 index 000000000..282ca96d7 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/util/region/rellekka/RellekkaUtils.kt @@ -0,0 +1,35 @@ +package rs09.game.util.region.rellekka + +import api.ContentAPI +import core.game.node.entity.player.Player +import core.game.system.task.Pulse +import core.game.world.map.Location +import org.rs09.consts.Components + +object RellekkaUtils { + @JvmStatic + fun sail(player: Player, destination: RellekkaDestination){ + ContentAPI.lock(player, 100) + ContentAPI.openOverlay(player, 115) + ContentAPI.openInterface(player, Components.MISC_SHIPJOURNEY_224) + ContentAPI.animateInterface(player, Components.MISC_SHIPJOURNEY_224, 7, destination.shipAnim) + + val animDuration = ContentAPI.animationDuration(ContentAPI.getAnimation(destination.shipAnim)) + ContentAPI.submitWorldPulse(object : Pulse(animDuration){ + override fun pulse(): Boolean { + ContentAPI.teleport(player, destination.destLoc) + ContentAPI.closeInterface(player) + ContentAPI.closeOverlay(player) + ContentAPI.unlock(player) + return true + } + }) + } +} + +enum class RellekkaDestination(val destName: String, val destLoc: Location, val shipAnim: Int){ + RELLEKKA_TO_JATIZSO("Jatizso", Location.create(2421, 3781, 0), 5766), + JATIZSO_TO_RELLEKKA("Rellekka", Location.create(2644, 3710, 0), 5767), + RELLEKKA_TO_NEITIZNOT("Neitiznot",Location(2310, 3782, 0), 5764), + NEITIZNOT_TO_RELLEKKA("Rellekka", Location(2644, 3710, 0), 5765) +} \ No newline at end of file