From 3f204cf583dd54ecb5d6debbcb9438c24d02135c Mon Sep 17 00:00:00 2001 From: Ceikry Date: Fri, 19 Mar 2021 16:34:22 -0500 Subject: [PATCH] Remove default bot spawns Moved brimhaven over to listener system --- .../city/BrimhavenDungeonPlugin.java | 175 ------------------ .../city/falador/MakeoverMageInterface.kt | 40 ---- .../{city => region}/IsafdarListeners.kt | 2 +- .../{city => region}/MorytaniaListeners.kt | 2 +- .../brimhaven/BrimhavenDungeonListeners.kt | 77 ++++++++ .../dungeons/brimhaven/BrimhavenUtils.kt | 99 ++++++++++ Server/worldprops/default.json | 2 +- 7 files changed, 179 insertions(+), 218 deletions(-) delete mode 100644 Server/src/main/java/core/game/interaction/city/BrimhavenDungeonPlugin.java delete mode 100644 Server/src/main/kotlin/rs09/game/interaction/city/falador/MakeoverMageInterface.kt rename Server/src/main/kotlin/rs09/game/interaction/{city => region}/IsafdarListeners.kt (95%) rename Server/src/main/kotlin/rs09/game/interaction/{city => region}/MorytaniaListeners.kt (97%) create mode 100644 Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenDungeonListeners.kt create mode 100644 Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt diff --git a/Server/src/main/java/core/game/interaction/city/BrimhavenDungeonPlugin.java b/Server/src/main/java/core/game/interaction/city/BrimhavenDungeonPlugin.java deleted file mode 100644 index 07c9a1f15..000000000 --- a/Server/src/main/java/core/game/interaction/city/BrimhavenDungeonPlugin.java +++ /dev/null @@ -1,175 +0,0 @@ -package core.game.interaction.city; - -import core.cache.def.impl.ObjectDefinition; -import core.game.content.global.action.ClimbActionHandler; -import core.game.node.entity.skill.Skills; -import core.game.node.entity.skill.gather.SkillingTool; -import core.game.node.entity.skill.agility.AgilityHandler; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.diary.DiaryType; -import core.game.node.object.GameObject; -import core.game.node.object.ObjectBuilder; -import core.game.system.task.LocationLogoutTask; -import core.game.system.task.LogoutTask; -import core.game.system.task.Pulse; -import rs09.game.world.GameWorld; -import core.game.world.map.Direction; -import core.game.world.map.Location; -import core.game.world.update.flag.context.Animation; -import core.plugin.Initializable; -import core.plugin.Plugin; - -/** - * Handles the Brimhaven dungeon. - * @author Emperor - */ -@Initializable -public final class BrimhavenDungeonPlugin extends OptionHandler { - - @Override - public Plugin newInstance(Object arg) throws Throwable { - ObjectDefinition.forId(5084).getHandlers().put("option:leave", this); - ObjectDefinition.forId(5088).getHandlers().put("option:walk-across", this); - ObjectDefinition.forId(5090).getHandlers().put("option:walk-across", this); - ObjectDefinition.forId(5094).getHandlers().put("option:walk-up", this); - ObjectDefinition.forId(5096).getHandlers().put("option:walk-down", this); - ObjectDefinition.forId(5097).getHandlers().put("option:walk-up", this); - ObjectDefinition.forId(5098).getHandlers().put("option:walk-down", this); - ObjectDefinition.forId(5103).getHandlers().put("option:chop-down", this); - ObjectDefinition.forId(5104).getHandlers().put("option:chop-down", this); - ObjectDefinition.forId(5105).getHandlers().put("option:chop-down", this); - ObjectDefinition.forId(5106).getHandlers().put("option:chop-down", this); - ObjectDefinition.forId(5107).getHandlers().put("option:chop-down", this); - ObjectDefinition.forId(5110).getHandlers().put("option:jump-from", this); - ObjectDefinition.forId(5111).getHandlers().put("option:jump-from", this); - return this; - } - - @Override - public boolean handle(final Player player, Node node, String option) { - final GameObject object = (GameObject) node; - switch (object.getId()) { - case 5084: - player.getProperties().setTeleportLocation(Location.create(2745, 3152, 0)); - return true; - case 5103: - case 5104: - case 5105: - case 5106: - case 5107: - int level = 10 + ((object.getId() - 5103) * 6); - if (player.getSkills().getLevel(Skills.WOODCUTTING) < level) { - player.getPacketDispatch().sendMessage("You need a woodcutting level of " + level + " to chop down this vine."); - return true; - } - SkillingTool tool = SkillingTool.getHatchet(player); - if (tool == null) { - player.getPacketDispatch().sendMessage("You don't have an axe to cut these vines."); - return true; - } - player.animate(tool.getAnimation()); - player.getPulseManager().run(new Pulse(3, player) { - @Override - public boolean pulse() { - if (ObjectBuilder.replace(object, object.transform(0), 2)) { - Location destination = getVineDestination(player, object); - player.lock(3); - player.getWalkingQueue().reset(); - // Chop the vines to gain deeper access to Brimhaven Dungeon - player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 14); - player.getWalkingQueue().addPath(destination.getX(), destination.getY(), true); - } - return true; - } - }); - return true; - case 5110: - case 5111: - if (player.getSkills().getLevel(Skills.AGILITY) < 12) { - player.getPacketDispatch().sendMessage("You need an agility level of 12 to cross this."); - return true; - } - player.lock(12); - final Direction dir = AgilityHandler.forceWalk(player, -1, player.getLocation(), object.getLocation(), Animation.create(769), 10, 0, null).getDirection(); - GameWorld.getPulser().submit(new Pulse(3, player) { - int stage = dir == Direction.NORTH ? -1 : 0; - Direction direction = dir; - - @Override - public boolean pulse() { - Location l = player.getLocation(); - switch (stage++) { - case 1: - direction = Direction.get(direction.toInteger() + 1 & 3); - break; - case 3: - direction = Direction.get(direction.toInteger() - 1 & 3); - break; - case 5: - if (direction == Direction.NORTH) { - return true; - } - } - if (stage == 6) { - player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 15); - } - AgilityHandler.forceWalk(player, -1, l, l.transform(direction), Animation.create(769), 10, 0, null); - return stage == 6; - } - }); - player.addExtension(LogoutTask.class, new LocationLogoutTask(13, player.getLocation())); - return true; - case 5094: - ClimbActionHandler.climb(player, null, Location.create(2643, 9594, 2)); - return true; - case 5096: - ClimbActionHandler.climb(player, null, Location.create(2649, 9591, 0)); - return true; - case 5097: - // Climb the stairs within Brimhaven Dungeon - player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 16); - ClimbActionHandler.climb(player, null, Location.create(2636, 9510, 2)); - return true; - case 5098: - ClimbActionHandler.climb(player, null, Location.create(2636, 9517, 0)); - return true; - case 5088: - if (player.getSkills().getLevel(Skills.AGILITY) < 30) { - player.getPacketDispatch().sendMessage("You need an agility level of 30 to cross this."); - return true; - } - AgilityHandler.walk(player, -1, player.getLocation(), Location.create(2687, 9506, 0), Animation.create(155), 0, null); - return true; - case 5090: - if (player.getSkills().getLevel(Skills.AGILITY) < 30) { - player.getPacketDispatch().sendMessage("You need an agility level of 30 to cross this."); - return true; - } - AgilityHandler.walk(player, -1, player.getLocation(), Location.create(2682, 9506, 0), Animation.create(155), 0, null); - return true; - } - return false; - } - - /** - * Gets the destination for chopping vines. - * @param player The player. - * @param object The object. - * @return The destination location. - */ - private static Location getVineDestination(Player player, GameObject object) { - if (object.getRotation() % 2 != 0) { - if (player.getLocation().getX() > object.getLocation().getX()) { - return object.getLocation().transform(-1, 0, 0); - } - return object.getLocation().transform(1, 0, 0); - } - if (player.getLocation().getY() > object.getLocation().getY()) { - return object.getLocation().transform(0, -1, 0); - } - return object.getLocation().transform(0, 1, 0); - } - -} diff --git a/Server/src/main/kotlin/rs09/game/interaction/city/falador/MakeoverMageInterface.kt b/Server/src/main/kotlin/rs09/game/interaction/city/falador/MakeoverMageInterface.kt deleted file mode 100644 index 65d1f645d..000000000 --- a/Server/src/main/kotlin/rs09/game/interaction/city/falador/MakeoverMageInterface.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* -package core.game.interaction.city.falador - -import core.game.component.Component -import core.game.component.ComponentDefinition -import core.game.component.ComponentPlugin -import core.game.node.entity.player.Player -import core.game.node.entity.player.info.PlayerDetails -import core.game.node.entity.player.link.appearance.Gender -import core.plugin.InitializablePlugin -import core.plugin.Plugin -import core.game.interaction.inter.FEMALE_HAIR_STYLES -import core.game.interaction.inter.MALE_HAIR_STYLES - -const val MAKEOVER_COMPONENT_ID = 205 - -private const val MALE_CHILD_ID = 90 -private const val FEMALE_CHILD_ID = 92 - -@InitializablePlugin -class MakeoverMageInterface : ComponentPlugin(){ - override fun open(player: Player?, component: Component?) { - player ?: return - super.open(player, component) - player.packetDispatch.sendModelOnInterface(114,MAKEOVER_COMPONENT_ID, MALE_CHILD_ID,100) - player.packetDispatch.sendModelOnInterface(118,MAKEOVER_COMPONENT_ID, FEMALE_CHILD_ID,100) - } - - override fun handle(player: Player?, component: Component?, opcode: Int, button: Int, slot: Int, itemId: Int): Boolean { - player ?: return false - player.appearance.hair.changeLook(MALE_HAIR_STYLES.random()) - player.appearance.sync() - return true - } - - override fun newInstance(arg: Any?): Plugin { - ComponentDefinition.put(MAKEOVER_COMPONENT_ID,this) - return this - } -}*/ diff --git a/Server/src/main/kotlin/rs09/game/interaction/city/IsafdarListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/IsafdarListeners.kt similarity index 95% rename from Server/src/main/kotlin/rs09/game/interaction/city/IsafdarListeners.kt rename to Server/src/main/kotlin/rs09/game/interaction/region/IsafdarListeners.kt index f73db9b01..0f003ed71 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/city/IsafdarListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/IsafdarListeners.kt @@ -1,4 +1,4 @@ -package rs09.game.interaction.city +package rs09.game.interaction.region import core.game.world.map.Location import rs09.game.interaction.InteractionListener diff --git a/Server/src/main/kotlin/rs09/game/interaction/city/MorytaniaListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/MorytaniaListeners.kt similarity index 97% rename from Server/src/main/kotlin/rs09/game/interaction/city/MorytaniaListeners.kt rename to Server/src/main/kotlin/rs09/game/interaction/region/MorytaniaListeners.kt index 68b18bf5a..c5ff76c93 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/city/MorytaniaListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/region/MorytaniaListeners.kt @@ -1,4 +1,4 @@ -package rs09.game.interaction.city +package rs09.game.interaction.region import core.game.node.entity.impl.ForceMovement import core.game.world.map.Direction diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenDungeonListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenDungeonListeners.kt new file mode 100644 index 000000000..118da7675 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenDungeonListeners.kt @@ -0,0 +1,77 @@ +package rs09.game.interaction.region.dungeons.brimhaven + +import core.game.node.entity.skill.Skills +import core.game.node.entity.skill.agility.AgilityHandler +import core.game.world.map.Location +import core.game.world.update.flag.context.Animation +import org.rs09.consts.NPCs +import rs09.game.interaction.InteractionListener + +class BrimhavenDungeonListeners : InteractionListener() { + + val EXIT = 5084 + val SANIBOCH = NPCs.SANIBOCH_1595 + val VINES = intArrayOf(5103,5104,5105,5106,5107) + val STEPPING_STONES = intArrayOf(5110,5111) + val STAIRS = intArrayOf(5094,5096,5097,5098) + val LOGS = intArrayOf(5088,5090) + + override fun defineListeners() { + on(EXIT,OBJECT,"leave"){player, _ -> + player.properties.teleportLocation = Location.create(2745, 3152, 0) + return@on true + } + + on(STAIRS,OBJECT,"walk-up","walk-down"){player, node -> + BrimhavenUtils.handleStairs(node.asObject(),player) + return@on true + } + + on(STEPPING_STONES,OBJECT,"jump-from"){player, node -> + BrimhavenUtils.handleSteppingStones(player,node.asObject()) + return@on true + } + + on(VINES,OBJECT,"chop-down"){player, node -> + BrimhavenUtils.handleVines(player,node.asObject()) + return@on true + } + + on(SANIBOCH,NPC,"pay"){player, node -> + player.dialogueInterpreter.open(SANIBOCH,node.asNpc(),10) + return@on true + } + + on(LOGS,OBJECT,"walk-across"){player, node -> + + if (player.skills.getLevel(Skills.AGILITY) < 30) { + player.packetDispatch.sendMessage("You need an agility level of 30 to cross this.") + return@on true + } + + if(node.id == 5088){ + AgilityHandler.walk( + player, + -1, + player.location, + Location.create(2687, 9506, 0), + Animation.create(155), + 0.0, + null + ) + } else { + AgilityHandler.walk( + player, + -1, + player.location, + Location.create(2682, 9506, 0), + Animation.create(155), + 0.0, + null + ) + } + + return@on true + } + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt new file mode 100644 index 000000000..614b17e3a --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/region/dungeons/brimhaven/BrimhavenUtils.kt @@ -0,0 +1,99 @@ +package rs09.game.interaction.region.dungeons.brimhaven + +import core.game.content.global.action.ClimbActionHandler +import core.game.node.`object`.GameObject +import core.game.node.`object`.ObjectBuilder +import core.game.node.entity.player.Player +import core.game.node.entity.player.link.diary.DiaryType +import core.game.node.entity.skill.Skills +import core.game.node.entity.skill.agility.AgilityHandler +import core.game.node.entity.skill.gather.SkillingTool +import core.game.system.task.Pulse +import core.game.world.map.Direction +import core.game.world.map.Location +import core.game.world.update.flag.context.Animation +import rs09.game.world.GameWorld + +object BrimhavenUtils { + fun getVineDestination(player: Player, node: GameObject): Location { + if (node.rotation % 2 != 0) { + return if (player.location.x > node.location.x) { + node.location.transform(-1, 0, 0) + } else node.location.transform(1, 0, 0) + } + return if (player.location.y > node.location.y) { + node.location.transform(0, -1, 0) + } else node.location.transform(0, 1, 0) + } + + fun handleStairs(node: GameObject, player: Player){ + when(node.id){ + 5094 -> ClimbActionHandler.climb(player, null, Location.create(2643, 9594, 2)) + 5096 -> ClimbActionHandler.climb(player, null, Location.create(2649, 9591, 0)) + 5097 -> { + // Climb the stairs within Brimhaven Dungeon + player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 1, 16) + ClimbActionHandler.climb(player, null, Location.create(2636, 9510, 2)) + } + 5098 -> ClimbActionHandler.climb(player, null, Location.create(2636, 9517, 0)) + } + } + + fun handleSteppingStones(player: Player, node: GameObject){ + if (player.skills.getLevel(Skills.AGILITY) < 12) { + player.packetDispatch.sendMessage("You need an agility level of 12 to cross this.") + return + } + player.lock(12) + val dir = AgilityHandler.forceWalk(player, -1, player.location, node.location, Animation.create(769), 10, 0.0, null).direction + val loc = player.location + player.logoutListeners["steppingstone"] = { p -> p.properties.teleportLocation = loc } + GameWorld.Pulser.submit(object : Pulse(3, player) { + var stage = if (dir == Direction.NORTH) -1 else 0 + var direction = dir + override fun pulse(): Boolean { + val l = player.location + when (stage++) { + 1 -> direction = Direction.get(direction.toInteger() + 1 and 3) + 3 -> direction = Direction.get(direction.toInteger() - 1 and 3) + 5 -> if (direction == Direction.NORTH) { + return true + } + } + if (stage == 6) { + player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 1, 15) + player.logoutListeners.remove("steppingstone") + } + AgilityHandler.forceWalk(player, -1, l, l.transform(direction), Animation.create(769), 10, 0.0, null) + return stage == 6 + } + }) + } + + fun handleVines(player: Player, node: GameObject){ + val level: Int = 10 + (node.id - 5103) * 6 + if (player.skills.getLevel(Skills.WOODCUTTING) < level) { + player.packetDispatch.sendMessage("You need a woodcutting level of $level to chop down this vine.") + return + } + val tool = SkillingTool.getHatchet(player) + if (tool == null) { + player.packetDispatch.sendMessage("You don't have an axe to cut these vines.") + return + } + player.animate(tool.animation) + player.pulseManager.run(object : Pulse(3, player) { + override fun pulse(): Boolean { + if (ObjectBuilder.replace(node.asObject(), node.asObject().transform(0), 2)) { + val destination = getVineDestination(player,node.asObject()) + player.lock(3) + player.walkingQueue.reset() + // Chop the vines to gain deeper access to Brimhaven Dungeon + player.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 1, 14) + player.walkingQueue.addPath(destination.x, destination.y, true) + } + return true + } + }) + } +} \ No newline at end of file diff --git a/Server/worldprops/default.json b/Server/worldprops/default.json index e5d642d8a..8c0da7e38 100644 --- a/Server/worldprops/default.json +++ b/Server/worldprops/default.json @@ -16,7 +16,7 @@ "enable_bots": true, "autostock_ge": true, "allow_token_purchase": true, - "max_adv_bots": "100", + "max_adv_bots": "0", "message_of_the_week_identifier": "0", "message_of_the_week_text": "Welcome to 2009Scape!
Nowin Technicolor!" },