From c63654ea126f9f3b85f2de47ea250cd1fbd376b2 Mon Sep 17 00:00:00 2001 From: aidan Date: Thu, 4 Dec 2025 14:47:07 -0600 Subject: [PATCH] minecarts push you, but they are wacky. --- .../hauntedmine}/AbandonedMineListeners.kt | 11 +- .../quest/hauntedmine/AbandonedMineZone.kt | 100 ++++++++++++++++++ .../quest/hauntedmine/HauntedMineListeners.kt | 10 ++ .../quest/hauntedmine/MinecartNPC.kt | 73 +++++++++++++ 4 files changed, 190 insertions(+), 4 deletions(-) rename Server/src/main/content/region/morytania/{handlers => quest/hauntedmine}/AbandonedMineListeners.kt (97%) create mode 100644 Server/src/main/content/region/morytania/quest/hauntedmine/AbandonedMineZone.kt create mode 100644 Server/src/main/content/region/morytania/quest/hauntedmine/MinecartNPC.kt diff --git a/Server/src/main/content/region/morytania/handlers/AbandonedMineListeners.kt b/Server/src/main/content/region/morytania/quest/hauntedmine/AbandonedMineListeners.kt similarity index 97% rename from Server/src/main/content/region/morytania/handlers/AbandonedMineListeners.kt rename to Server/src/main/content/region/morytania/quest/hauntedmine/AbandonedMineListeners.kt index 927ac053e..21eb6a259 100644 --- a/Server/src/main/content/region/morytania/handlers/AbandonedMineListeners.kt +++ b/Server/src/main/content/region/morytania/quest/hauntedmine/AbandonedMineListeners.kt @@ -1,15 +1,14 @@ -package content.region.morytania.handlers +package content.region.morytania.quest.hauntedmine -import content.global.skill.slayer.dungeon.AncientCavern +import content.data.tables.BirdNest import core.api.* import core.game.global.action.DoorActionHandler import core.game.interaction.IntType import core.game.interaction.InteractionListener -import core.game.node.entity.combat.ImpactHandler.HitsplatType import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player +import core.game.node.item.Item import core.game.world.map.Location -import core.tools.RandomFunction import org.rs09.consts.Items import org.rs09.consts.NPCs import org.rs09.consts.Scenery @@ -327,6 +326,10 @@ class AbandonedMineListeners : InteractionListener { // handles spawning the possessed pickaxe private fun takePickaxe(player: Player, npc: NPC) { + + // todo try this later instead of spawning and removing to fix the pick not respawning issue. + // transformNpc(npc, NPCs.POSSESSED_PICKAXE_1536, 400) + val spawn: NPC = NPC.create( NPCs.POSSESSED_PICKAXE_1536, npc.getLocation() diff --git a/Server/src/main/content/region/morytania/quest/hauntedmine/AbandonedMineZone.kt b/Server/src/main/content/region/morytania/quest/hauntedmine/AbandonedMineZone.kt new file mode 100644 index 000000000..bda02d442 --- /dev/null +++ b/Server/src/main/content/region/morytania/quest/hauntedmine/AbandonedMineZone.kt @@ -0,0 +1,100 @@ +package content.region.morytania.quest.hauntedmine + +import core.api.Container +import core.api.addItem +import core.api.addItemOrDrop +import core.api.amountInInventory +import core.api.inInventory +import core.api.removeItem +import core.api.sendMessage +import core.game.node.entity.Entity +import core.game.node.entity.player.Player +import core.game.node.item.Item +import core.game.world.map.zone.MapZone +import core.game.world.map.zone.ZoneBorders +import core.game.world.map.zone.ZoneBuilder +import core.plugin.Initializable +import core.plugin.Plugin +import org.rs09.consts.Items + +@Initializable + +// if you leave the abandoned mine, any instances of Glowing Fungus in your inventory should be removed and replaced with ashes. +class AbandonedMineZone : MapZone("Abandoned Mine", true), Plugin { + + override fun newInstance(arg: Any?): Plugin { + ZoneBuilder.configure(this) + return this + } + + override fun fireEvent(identifier: String?, vararg args: Any?): Any { + return Unit + } + + override fun leave(e: Entity?, logout: Boolean): Boolean { + + //todo come back to this and fix it the leave logic. + // Right now if you go from floor 2 to 1 it gets rid of the fungus. + // I could also just leave as-is. It doesn't impact the quest and still accomplishes the correct goal. + if (e!!.isPlayer){ + // remove any glowing fungus the player is carrying. + val fungi = amountInInventory(e as Player, Items.GLOWING_FUNGUS_4075) + if(removeItem(e, Item(Items.GLOWING_FUNGUS_4075, fungi), Container.INVENTORY)){ + addItemOrDrop(e, Items.ASHES_592, fungi) + sendMessage(e, "The strange fungus you are carrying crumbles to dust.") + } + } + return super.leave(e, logout) + } + + override fun configure() { + // mine floor 1 + register(ZoneBorders(3395, 9609, 3448, 9664)) + + // mine floors 2-6 + register(ZoneBorders(2680, 4415, 2820, 4609)) + } +} + +// If you enter level 5 of the abandoned mine, any tinderboxes with you should become damp tinderboxes. +// Light sources should also be extinguished. This is so that when you try to go to mine level 5 and the +// player says "i need a light source", it'll force you to get a glowing fungus. +class AbandonedMineL5Zone : MapZone("Abandoned Mine Level 5", true), Plugin { + + override fun newInstance(arg: Any?): Plugin { + ZoneBuilder.configure(this) + return this + } + + override fun fireEvent(identifier: String?, vararg args: Any?): Any { + return Unit + } + + override fun enter(e: Entity?): Boolean { + if (e!!.isPlayer){ + val tindies = amountInInventory(e as Player, Items.TINDERBOX_1553) + if(removeItem(e, Item(Items.TINDERBOX_1553, tindies), Container.INVENTORY)){ + addItemOrDrop(e, Items.DAMP_TINDERBOX_4073, tindies) + } + //todo extinguish light sources. + } + + return super.enter(e) + } + + override fun leave(e: Entity?, logout: Boolean): Boolean { + + if (e!!.isPlayer){ + val tindies = amountInInventory(e as Player, Items.DAMP_TINDERBOX_4073) + if(removeItem(e, Item(Items.DAMP_TINDERBOX_4073, tindies), Container.INVENTORY)){ + addItemOrDrop(e, Items.TINDERBOX_1553, tindies) + } + } + + return super.leave(e, logout) + } + + override fun configure() { + register(ZoneBorders(2680, 4415, 2755, 4480)) + } +} diff --git a/Server/src/main/content/region/morytania/quest/hauntedmine/HauntedMineListeners.kt b/Server/src/main/content/region/morytania/quest/hauntedmine/HauntedMineListeners.kt index 9870acf6b..51e4ffbcb 100644 --- a/Server/src/main/content/region/morytania/quest/hauntedmine/HauntedMineListeners.kt +++ b/Server/src/main/content/region/morytania/quest/hauntedmine/HauntedMineListeners.kt @@ -62,6 +62,16 @@ class HauntedMineListeners : InteractionListener { // points settings on(Scenery.POINTS_SETTINGS_4949, IntType.SCENERY, "Check") { player, node -> + // open iface 144 + + return@on true + } + + // you can't drop the fungus + on(Items.GLOWING_FUNGUS_4075, IntType.ITEM, "Drop") { player, node -> + removeItem(player,node) + produceGroundItem(player, Items.ASHES_592) + sendMessage(player,"When you drop the fungus it crumbles mysteriously to dust.") return@on true } diff --git a/Server/src/main/content/region/morytania/quest/hauntedmine/MinecartNPC.kt b/Server/src/main/content/region/morytania/quest/hauntedmine/MinecartNPC.kt new file mode 100644 index 000000000..0c8b25177 --- /dev/null +++ b/Server/src/main/content/region/morytania/quest/hauntedmine/MinecartNPC.kt @@ -0,0 +1,73 @@ +package content.region.morytania.quest.hauntedmine + +import core.api.* +import core.game.node.entity.npc.NPC +import core.game.node.entity.npc.NPCBehavior +import core.game.node.entity.player.Player +import core.game.world.map.Location +import core.tools.RandomFunction.random +import org.rs09.consts.NPCs + +// covers the behavior of the animated minecarts. They move back and forth along set paths, +// and if the player runs into one they push the player back with them while causing continuous 0-2 damage. + +// mine cart 1544 is used on level 6 during the Trayus Dayth fight. + +/* +@Initializable +class MinecartNPC(id: Int = 0, location: Location? = null) : AbstractNPC(id, location) { + + override fun construct(id: Int, location: Location, vararg objects: Any): AbstractNPC { + return MinecartNPC(id, location) + } + + override fun getIds(): IntArray { + return intArrayOf(NPCs.MINE_CART_1544, NPCs.MINE_CART_1545, NPCs.MINE_CART_1546, NPCs.MINE_CART_1547, NPCs.MINE_CART_1548) + } + +} + */ + +class MinecartNPCBehavior : NPCBehavior(NPCs.MINE_CART_1544, NPCs.MINE_CART_1545, NPCs.MINE_CART_1546, NPCs.MINE_CART_1547, NPCs.MINE_CART_1548) { + + override fun onCreation(self: NPC) { + + if (self.id == NPCs.MINE_CART_1545 && self.properties.spawnLocation == location(2727,4509,0)) { + val movementPath = arrayOf(Location.create(2727, 4517, 0), Location.create(2727, 4489, 0)) + self.configureMovementPath(*movementPath) + self.isWalks = true + } + + if (self.id == NPCs.MINE_CART_1546 && self.properties.spawnLocation == location(2697,4498,0)) { + val movementPath = arrayOf(Location.create(2696, 4498, 0), Location.create(2711, 4498, 0)) + self.configureMovementPath(*movementPath) + self.isWalks = true + } + + if (self.id == NPCs.MINE_CART_1547 && self.properties.spawnLocation == location(2715,4517,0)) { + val movementPath = arrayOf(Location.create(2696, 4498, 0), Location.create(2711, 4498, 0)) + self.configureMovementPath(*movementPath) + self.isWalks = true + } + + if (self.id == NPCs.MINE_CART_1548 && self.properties.spawnLocation == location(2739,4528,0)) { + val movementPath = arrayOf(Location.create(2739, 4531, 0), Location.create(2739, 4528, 0)) + self.configureMovementPath(*movementPath) + self.isWalks = true + } + } + + // logic to check for, push, and damage players. + override fun tick(self: NPC): Boolean { + for (p in self.viewport.currentPlane.players) { + // todo come back and refine the pushing, it doesn't work very well. + if (p.location == self.location /*|| p.location == self.location.transform(self.direction,1)*/) { + forceMove(p, p.location,self.location.transform(self.direction,1),0,0) + impact(p,random(0,2)) + } + } + + return true + } + +} \ No newline at end of file