From 942fd2876e2e91f080a5dcc38408a6e28ad08184 Mon Sep 17 00:00:00 2001 From: Zerken Date: Mon, 17 Jul 2023 08:59:35 +0000 Subject: [PATCH] Shantay quick-pass now functions authentically --- .../desert/handlers/ShantayPassPlugin.java | 18 ++++++++++++++---- Server/src/main/core/tools/TickUtils.kt | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Server/src/main/content/region/desert/handlers/ShantayPassPlugin.java b/Server/src/main/content/region/desert/handlers/ShantayPassPlugin.java index 27084d03b..73a4d96dd 100644 --- a/Server/src/main/content/region/desert/handlers/ShantayPassPlugin.java +++ b/Server/src/main/content/region/desert/handlers/ShantayPassPlugin.java @@ -1,10 +1,12 @@ package content.region.desert.handlers; +import core.api.Container; import core.cache.def.impl.NPCDefinition; import core.cache.def.impl.SceneryDefinition; import core.game.component.Component; import core.game.component.ComponentDefinition; import core.game.component.ComponentPlugin; +import core.game.dialogue.FacialExpression; import core.game.global.action.DoorActionHandler; import content.global.skill.agility.AgilityHandler; import core.game.interaction.OptionHandler; @@ -16,6 +18,10 @@ import core.game.node.scenery.Scenery; import core.game.world.map.Location; import core.plugin.Initializable; import core.plugin.Plugin; +import org.rs09.consts.Items; + +import static core.api.ContentAPIKt.*; +import static core.tools.TickUtilsKt.ticksToCycles; /** * Represents the plugin to handle the shantay pass. @@ -84,11 +90,15 @@ public class ShantayPassPlugin extends OptionHandler { player.getInterfaceManager().open(new Component(565)); break; case "quick-pass": - if (player.getLocation().getY() < 3117) { - AgilityHandler.walk(player, 0, player.getLocation(), player.getLocation().transform(0, player.getLocation().getY() > 3116 ? -2 : 2, 0), null, 0, null); - return true; + if (player.getLocation().getY() > 3116) { + if (!inInventory(player, Items.SHANTAY_PASS_1854, 1)) { + sendNPCDialogue(player, 838, "You need a Shantay pass to get through this gate. See Shantay, he will sell you one for a very reasonable price.", FacialExpression.NEUTRAL); + return true; + } + if (!removeItem(player, Items.SHANTAY_PASS_1854, Container.INVENTORY)) return true; + sendMessage(player, "You hand your Shantay pass to the guard and pass through the gate."); } - player.getDialogueInterpreter().open(838, 838, true); + forceMove(player, player.getLocation(), player.getLocation().transform(0, player.getLocation().getY() > 3116 ? -2 : 2, 0), 0, ticksToCycles(2), null, 819, null); break; } return true; diff --git a/Server/src/main/core/tools/TickUtils.kt b/Server/src/main/core/tools/TickUtils.kt index 8f9f9045b..f7e26e5ac 100644 --- a/Server/src/main/core/tools/TickUtils.kt +++ b/Server/src/main/core/tools/TickUtils.kt @@ -19,6 +19,10 @@ fun cyclesToTicks (cycles: Int) : Int { return kotlin.math.ceil (cycles / cyclesPerTick.toDouble()).toInt() } +fun ticksToCycles (ticks: Int) : Int { + return ticks * (tick / cycle) +} + fun minutesToTicks(minutes: Int): Int { val minutesMs = minutes * 60 * 1000 return minutesMs / tick