Properly handled Rellekka's sailing map

This commit is contained in:
Ceikry
2021-07-09 23:12:56 +00:00
parent 0164ddae8a
commit 4d52be73fd
11 changed files with 204 additions and 53 deletions
+8
View File
@@ -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}"
}
]
@@ -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;
@@ -49,13 +49,11 @@ public final class RellekkaZone extends MapZone implements Plugin<Object> {
@Override
public Plugin<Object> 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<Object> {
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<Object> {
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
@@ -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;
+31
View File
@@ -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)
}
}
@@ -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)
}
}
@@ -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
@@ -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
@@ -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
}
}
}
@@ -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
@@ -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)
}