From 2586c4b66aee52244ba91a51dec611866dd34821 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Sat, 24 Sep 2022 16:14:09 +0000 Subject: [PATCH] Added new content api method for stating a quest requirement Made Miscellania accessible with completion of Fremennik Trials via the fairy ring Locked Morytania locations behind Priest in Peril (both fairy ring and charter ship methods) --- .../global/travel/ship/ShipCharter.java | 17 ++++++++-- Server/src/main/kotlin/api/ContentAPI.kt | 15 +++++++++ .../interaction/inter/FairyRingInterface.kt | 32 +++++++++++++++---- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Server/src/main/java/core/game/content/global/travel/ship/ShipCharter.java b/Server/src/main/java/core/game/content/global/travel/ship/ShipCharter.java index 91218f74c..c37ef52ad 100644 --- a/Server/src/main/java/core/game/content/global/travel/ship/ShipCharter.java +++ b/Server/src/main/java/core/game/content/global/travel/ship/ShipCharter.java @@ -5,7 +5,6 @@ import core.game.node.entity.player.Player; import core.game.node.entity.player.link.diary.DiaryType; import core.game.node.item.Item; import core.game.system.task.Pulse; -import org.rs09.consts.Items; import rs09.game.world.GameWorld; import core.game.world.map.Location; import rs09.game.world.repository.Repository; @@ -17,6 +16,8 @@ import core.tools.StringUtils; import java.util.ArrayList; import java.util.List; +import static api.ContentAPIKt.requireQuest; + /** * Represents a class used to charter ships. * @author 'Vexia @@ -67,6 +68,9 @@ public final class ShipCharter { if (destination == null) { return; } + if (!destination.checkTravel(player)) { + return; + } final int cost = getCost(player, destination); player.getInterfaceManager().close(); player.getDialogueInterpreter().open(4651, Repository.findNPC(4651), destination, cost); @@ -134,7 +138,12 @@ public final class ShipCharter { */ public enum Destination { CATHERBY(Location.create(2792, 3417, 1), 25, new int[] { 480, 0, 480, 625, 1600, 3250, 1000, 1600, 3200, 3400 }, Location.create(2797, 3414, 0), 3, 14), - PORT_PHASMATYS(Location.create(3705, 3503, 1), 24, new int[] { 3650, 3250, 1850, 0, 0, 0, 2050, 1850, 3200, 1100 }, Location.create(3702, 3502, 0), 2, 13), + PORT_PHASMATYS(Location.create(3705, 3503, 1), 24, new int[] { 3650, 3250, 1850, 0, 0, 0, 2050, 1850, 3200, 1100 }, Location.create(3702, 3502, 0), 2, 13) { + @Override + public boolean checkTravel(Player player) { + return requireQuest(player, "Priest in Peril", "to go there"); + } + }, CRANDOR(new Location(2792, 3417, 1), 32, new int[] { 0, 480, 480, 925, 400, 3650, 1600, 400, 3200, 3800 }, null, 10, 21), BRIMHAVEN(Location.create(2763, 3238, 1), 28, new int[] { 0, 480, 480, 925, 400, 3650, 1600, 400, 3200, 3800 }, Location.create(2760, 3238, 0), 6, 17){ @Override @@ -322,6 +331,10 @@ public final class ShipCharter { return null; } + public boolean checkTravel(Player player) { + return true; + } + /** * Method used to sail the ship. * @param player the player. diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index 9174fbade..3c039cef8 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -2130,4 +2130,19 @@ fun getCredits(player: Player) : Int { return player.details.accountInfo.credits } +/** + * Asserts that a quest is required, and sends the player "You must have completed the $questName quest $message" + * @param player the player we are checking + * @param questName the name of the quest we are checking for + * @param message the text appended to "You must have completed the $questName quest ..." if the quest is not complete. + * @return whether or not the quest has been completed + */ +fun requireQuest(player: Player, questName: String, message: String) : Boolean { + if (!isQuestComplete(player, questName)) { + sendMessage(player, "You must have completed the $questName quest $message") + return false + } + return true +} + private class ContentAPI \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt index dd26cf9a5..e08b48cd6 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/inter/FairyRingInterface.kt @@ -6,7 +6,6 @@ import core.game.component.Component import core.game.content.dialogue.FacialExpression import core.game.node.entity.player.Player import core.game.node.entity.player.link.TeleportManager -import core.game.node.entity.player.link.diary.DiaryType import core.game.system.task.Pulse import core.game.world.map.Location import core.game.world.map.RegionManager @@ -114,8 +113,9 @@ class FairyRingInterface : InterfaceListener{ } catch (e: Exception) { null } var tile = ring?.tile - if(ring == FairyRing.CIP){ + if(ring?.checkAccess(player) != true){ sendDialogue(player, "The ring seems to reject you.") + tile = null } if (ring == null || tile == null) { val center = Location(2412, 4434, 0) @@ -156,7 +156,11 @@ enum class FairyRing(val tile: Location?, val tip: String = "", val childId: Int AJS(Location.create(2500, 3896, 0), "Islands: Penguins near Miscellania", 21), AKQ(Location.create(2319, 3619, 0), "Kandarin: Piscatoris Hunter area", 23), AKS(Location.create(2571, 2956, 0), "Feldip Hills: Jungle Hunter area", 25), - ALQ(Location.create(3597, 3495, 0), "Morytania: Haunted Woods east of Canifis", 27), + ALQ(Location.create(3597, 3495, 0), "Morytania: Haunted Woods east of Canifis", 27) { + override fun checkAccess(player: Player) : Boolean { + return requireQuest(player, "Priest in Peril", "to use this ring.") + } + }, ALS(Location.create(2644, 3495, 0), "Kandarin: McGrubor's Wood", 29), BIP(Location.create(3410, 3324, 0), "Islands: River Salve", 30), BIQ(Location.create(3251, 3095, 0), "Kharidian Desert: Near Kalphite hive", 31), @@ -164,16 +168,28 @@ enum class FairyRing(val tile: Location?, val tip: String = "", val childId: Int BJR(null, "Other Realms: Realm of the Fisher King", 36), BKP(Location.create(2385, 3035, 0), "Feldip Hills: South of Castle Wars", 38), BKQ(Location.create(3041, 4532, 0), "Other realms: Enchanted Valley", 39), - BKR(Location.create(3469, 3431, 0), "Morytania: Mort Myre, south of Canifis", 40), + BKR(Location.create(3469, 3431, 0), "Morytania: Mort Myre, south of Canifis", 40) { + override fun checkAccess(player: Player) : Boolean { + return requireQuest(player, "Priest in Peril", "to use this ring.") + } + }, BLP(Location.create(2437, 5126, 0), "Dungeons: TzHaar area", 42), BLQ(null, "Yu'biusk", 43),//Location.create(2229, 4244, 1) BLR(Location.create(2740, 3351, 0), "Kandarin: Legends' Guild", 44), - CIP(null, "Islands: Miscellania", 46), //Location.create(2513, 3884, 0) + CIP(Location.create(2513, 3884, 0), "Islands: Miscellania", 46) { + override fun checkAccess(player: Player): Boolean { + return requireQuest(player, "Fremennik Trials", "to use this ring.") + } + }, CIQ(Location.create(2528, 3127, 0), "Kandarin: North-west of Yanille", 47), CJR(Location.create(2705, 3576, 0), "Kandarin: Sinclair Mansion", 52), CKP(Location.create(2075, 4848, 0), "Other realms: Cosmic Entity's plane", 54), CKR(Location.create(2801, 3003, 0), "Karamja: South of Tai Bwo Wannai Village", 56), - CKS(Location.create(3447, 3470, 0), "Morytania: Canifis", 57), + CKS(Location.create(3447, 3470, 0), "Morytania: Canifis", 57) { + override fun checkAccess(player: Player) : Boolean { + return requireQuest(player, "Priest in Peril", "to use this ring.") + } + }, CLP(Location.create(3082, 3206, 0), "Islands: South of Draynor Village", 58), CLS(Location.create(2682, 3081, 0), "Islands: Jungle spiders near Yanille", 61), DIR(Location.create(3038, 5348, 0), "Other realms: Goraks' Plane", 64), @@ -187,6 +203,10 @@ enum class FairyRing(val tile: Location?, val tip: String = "", val childId: Int DLR(Location.create(2213, 3099, 0), "Islands: Poison Waste south of Isafdar", 76), AIS(null), AIP(null), AKP(null), FAIRY_HOME(Location.create(2412, 4434, 0)); + open fun checkAccess(player: Player) : Boolean { + return true + } + companion object { /** * Draws the travel log.