From ad9f817cd6cadb4f73dbdbfcf6dceb5c3b4229dd Mon Sep 17 00:00:00 2001 From: Ceikry Date: Sun, 4 Jul 2021 15:02:39 +0000 Subject: [PATCH] Implemented the signpost for varrock guards --- .../core/game/world/map/zone/MapZone.java | 2 +- Server/src/main/kotlin/api/ContentAPI.kt | 14 ++++++++ .../game/interaction/InteractionListeners.kt | 3 ++ .../object/VarrockGuardSignpost.kt | 33 +++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt diff --git a/Server/src/main/java/core/game/world/map/zone/MapZone.java b/Server/src/main/java/core/game/world/map/zone/MapZone.java index 30efb7340..66d828336 100644 --- a/Server/src/main/java/core/game/world/map/zone/MapZone.java +++ b/Server/src/main/java/core/game/world/map/zone/MapZone.java @@ -245,7 +245,7 @@ public abstract class MapZone implements Zone { /** * Configures this map zone. */ - public abstract void configure(); + public void configure(){}; /** * Cleans items from a players inventory, equipment and bank. diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index baadf76e7..8322b0b57 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -25,6 +25,9 @@ import core.game.system.task.Pulse import core.game.world.map.Location import core.game.world.map.RegionManager import core.game.world.map.path.Pathfinder +import core.game.world.map.zone.MapZone +import core.game.world.map.zone.ZoneBorders +import core.game.world.map.zone.ZoneBuilder import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Graphics import core.tools.RandomFunction @@ -1022,4 +1025,15 @@ object ContentAPI { fun sceneryDefinition(id: Int): SceneryDefinition{ return SceneryDefinition.forId(id) } + + /** + * Register a map zone + * @param zone the zone to register + * @param borders the ZoneBorders that compose the zone + */ + @JvmStatic + fun registerMapZone(zone: MapZone, borders: ZoneBorders){ + ZoneBuilder.configure(zone) + zone.register(borders) + } } \ 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 413ae4eea..ce32d75e9 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt @@ -2,6 +2,7 @@ package rs09.game.interaction import core.game.interaction.DestinationFlag import core.game.interaction.MovementPulse +import core.game.interaction.Option import core.game.node.Node import core.game.node.entity.player.Player import core.game.world.map.Location @@ -171,6 +172,8 @@ 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 diff --git a/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt b/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt new file mode 100644 index 000000000..8d212864c --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/object/VarrockGuardSignpost.kt @@ -0,0 +1,33 @@ +package rs09.game.interaction.`object` + +import api.ContentAPI +import core.game.interaction.Option +import core.game.node.Node +import core.game.node.entity.Entity +import core.game.world.map.zone.MapZone +import core.game.world.map.zone.ZoneBorders +import rs09.game.interaction.InteractionListener + +class VarrockGuardSignpost : InteractionListener() { + override fun defineListeners() { + val zone = object : MapZone("Varrock Guards", true){ + var pickpocketCounter = 0 + override fun interact(e: Entity?, target: Node?, option: Option?): Boolean { + if(option != null && option.name.toLowerCase().contains("pickpocket") && target != null && target.name.toLowerCase().contains("guard")){ + pickpocketCounter++ + } + return false + } + } + + ContentAPI.registerMapZone(zone, ZoneBorders(3225,3445,3198,3471)) + ContentAPI.registerMapZone(zone, ZoneBorders(3222,3375,3199,3387)) + ContentAPI.registerMapZone(zone, ZoneBorders(3180,3420,3165,3435)) + ContentAPI.registerMapZone(zone, ZoneBorders(3280,3422,3266,3435)) + + on(31298, SCENERY, "read"){player, node -> + ContentAPI.sendDialogue(player, "Guards in the Varrock Palace are on full alert due to increasing levels of pickpocketing. So far today, ${zone.pickpocketCounter} guards have had their money pickpocketed in the palace or at the city gates.") + return@on true + } + } +} \ No newline at end of file