From e651be47d2a85edd6f834eb0db583afc048abaf4 Mon Sep 17 00:00:00 2001 From: philliam Date: Sat, 26 Jun 2021 01:18:51 -0400 Subject: [PATCH 1/6] Player script fixes, and bankAll scriptAPI function added Fixed the bank window exploit in the coal miner, Draynor willows, lobster catcher, Seers magic, shark catcher, and Varrock essence scripts. Made it so that the coal miner script banks its entire inventory instead of just the coal ore, this way it should no longer get stuck if its inventory is full of mithril ore and uncut gems. Fixed the Draynor willows and Seers magic trees scripts so that the bot actually chops down the trees instead of just standing next to them. Added a bankAll function to the scriptAPI, the coal miner script is dependent on this change --- .../kotlin/rs09/game/ai/general/ScriptAPI.kt | 22 ++ .../ai/general/scriptrepository/CoalMiner.kt | 164 +++++++++++++++ .../scriptrepository/DraynorWillows.kt | 94 +++++++++ .../scriptrepository/LobsterCatcher.kt | 198 ++++++++++++++++++ .../scriptrepository/SeersMagicTrees.kt | 119 +++++++++++ .../general/scriptrepository/SharkCatcher.kt | 1 + .../scriptrepository/VarrockEssenceMiner.kt | 1 + 7 files changed, 599 insertions(+) create mode 100644 Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt create mode 100644 Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt create mode 100644 Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt create mode 100644 Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt diff --git a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt index 567aca3b3..d5306bb55 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt @@ -550,6 +550,28 @@ class ScriptAPI(private val bot: Player) { bot.pulseManager.run(BankingPulse()) } + /** + * Takes every item out of the bots inventory and places it into the bank. + * @param none + * @author cfunnyman joe + */ + fun bankAll(){ + class BankingPulse() : Pulse(20){ + override fun pulse(): Boolean { + for(item in bot.inventory.toArray()){ + var itemAmount = bot.inventory.getAmount(item) + + bot.inventory.remove(item) + bot.bank.add(item) + bot.bank.refresh() + bot.inventory.refresh() + } + return true + } + } + bot.pulseManager.run(BankingPulse()) + } + /** * Function that makes the bot eat the food item in their inventory if their HP is below 2/3. * @author Ceikry diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt new file mode 100644 index 000000000..1d3a533ed --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt @@ -0,0 +1,164 @@ +package rs09.game.ai.general.scriptrepository + + +import core.game.interaction.DestinationFlag +import core.game.interaction.MovementPulse +import core.game.node.Node +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import core.game.world.map.zone.ZoneBorders +import org.rs09.consts.Items +import rs09.game.ai.general.ScriptAPI +import rs09.game.ai.skillingbot.SkillingBotAssembler +import rs09.game.interaction.InteractionListener +import rs09.game.interaction.InteractionListeners +import api.ContentAPI +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import java.util.logging.Handler + +@PlayerCompatible +@ScriptName("Falador Coal Miner") +@ScriptDescription("Start in Falador East Bank with a pick equipped","or in your inventory.") +@ScriptIdentifier("fally_coal") +class CoalMiner : Script() { + var state = State.INIT + var ladderSwitch = false + val bottomLadder = ZoneBorders(3016,9736,3024,9742) + val topLadder = ZoneBorders(3016,3336,3022,3342) + val mine = ZoneBorders(3027,9733,3054,9743) + val bank = ZoneBorders(3009,3355,3018,3358) + var overlay: ScriptAPI.BottingOverlay? = null + var coalAmount = 0 + + override fun tick() { + when(state){ + + State.INIT -> { + overlay = scriptAPI.getOverlay() + ladderSwitch = true + overlay!!.init() + overlay!!.setTitle("Mining") + overlay!!.setTaskLabel("Coal Mined:") + overlay!!.setAmount(0) + + if (mine.insideBorder(bot)){ + ladderSwitch = false + state = State.MINING + } else { + state = State.TO_MINE + } + } + + State.MINING -> { + bot.interfaceManager.close() + if(bot.inventory.freeSlots() == 0){ + state = State.TO_BANK + } + if(!mine.insideBorder(bot)){ + scriptAPI.walkTo(mine.randomLoc) + } else { + val rock = scriptAPI.getNearestNode("rocks",true) + rock?.let { InteractionListeners.run(rock.id, InteractionListener.OBJECT,"mine",bot,rock) } + } + overlay!!.setAmount(ContentAPI.amountInInventory(bot, Items.COAL_453) + coalAmount) + } + + State.TO_BANK -> { + if(bank.insideBorder(bot)){ + val bank = scriptAPI.getNearestNode("bank booth",true) + if(bank != null) { + bot.pulseManager.run(object : BankingPulse(this, bank){ + override fun pulse(): Boolean { + state = State.BANKING + return super.pulse() + } + }) + } + + } else { + if(!ladderSwitch) { + val ladder = scriptAPI.getNearestNode(30941, true) + ladder ?: scriptAPI.walkTo(bottomLadder.randomLoc).also { return } + ladder?.interaction?.handle(bot, ladder.interaction[0]).also { ladderSwitch = true } + } else { + if (!bank.insideBorder(bot)) scriptAPI.walkTo(bank.randomLoc).also { return } + } + } + } + + State.BANKING -> { + coalAmount += bot.inventory.getAmount(Items.COAL_453) + scriptAPI.bankAll() + state = State.TO_MINE + } + + State.TO_MINE -> { + if(ladderSwitch){ + bot.interfaceManager.close() + if(!topLadder.insideBorder(bot.location)){ + scriptAPI.walkTo(topLadder.randomLoc) + } else { + val ladder = scriptAPI.getNearestNode("Ladder",true) + if(ladder != null){ + ladder.interaction.handle(bot,ladder.interaction[0]) + ladderSwitch = false + } else { + scriptAPI.walkTo(topLadder.randomLoc) + } + } + } else { + if(!mine.insideBorder(bot)){ + scriptAPI.walkTo(mine.randomLoc) + } else { + state = State.MINING + } + } + } + + State.TO_GE -> { + scriptAPI.teleportToGE() + state = State.SELLING + } + + State.SELLING -> { + scriptAPI.sellOnGE(Items.COAL_453) + state = State.GO_BACK + } + + State.GO_BACK -> { + scriptAPI.teleport(bank.randomLoc) + state = State.TO_MINE + } + } + } + + open class BankingPulse(val script: Script, val bank: Node) : MovementPulse(script.bot,bank, DestinationFlag.OBJECT){ + override fun pulse(): Boolean { + script.bot.faceLocation(bank.location) + return true + } + } + + override fun newInstance(): Script { + val script = CoalMiner() + script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR,bot.startLocation) + return script + } + + enum class State { + MINING, + TO_MINE, + TO_BANK, + BANKING, + TO_GE, + SELLING, + GO_BACK, + INIT + } + + init { + equipment.add(Item(Items.IRON_PICKAXE_1267)) + skills.put(Skills.MINING,75) + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt new file mode 100644 index 000000000..c7051f8e3 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt @@ -0,0 +1,94 @@ +package rs09.game.ai.general.scriptrepository + +import core.game.component.Component +import core.game.interaction.DestinationFlag +import core.game.interaction.MovementPulse +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import core.game.world.map.zone.ZoneBorders +import org.rs09.consts.Items +import rs09.game.interaction.InteractionListener +import rs09.game.interaction.InteractionListeners +import rs09.tools.stringtools.colorize + +@PlayerCompatible +@ScriptName("Draynor Willows") +@ScriptDescription("Start in Draynor with an axe equipped or in inventory.") +@ScriptIdentifier("draynor_trees") +class DraynorWillows : Script(){ + val willowZone = ZoneBorders(3084, 3225,3091, 3239) + + + val bankZone = ZoneBorders(3092, 3240,3094, 3246) + var state = State.INIT + var logCount = 0 + + override fun tick() { + when(state){ + State.INIT -> { + if(true){ + bot.interfaceManager.openOverlay(Component(195)) + bot.packetDispatch.sendString("Woodcutting",195,7) + bot.packetDispatch.sendString(colorize("%BLogs Chopped:"),195,8) + bot.packetDispatch.sendString(colorize("%B0"),195,9) + bot.packetDispatch.sendInterfaceConfig(195,5,true) + } + state = State.CHOPPING + } + + State.CHOPPING -> { + if (!willowZone.insideBorder(bot)) + scriptAPI.walkTo(willowZone.randomLoc) + else { + val willowtree = scriptAPI.getNearestNode("willow", true) + bot.interfaceManager.close() + willowtree?.let { InteractionListeners.run(willowtree.id, + InteractionListener.OBJECT,"Chop down",bot,willowtree) } + if (bot.inventory.isFull) + state = State.BANKING + } + + bot.packetDispatch.sendString(colorize("%B${logCount + bot.inventory.getAmount(Items.WILLOW_LOGS_1519)}"), 195, 9) + } + + State.BANKING -> { + if(!bankZone.insideBorder(bot)) + scriptAPI.walkTo(bankZone.randomLoc) + else{ + val bank = scriptAPI.getNearestNode("Bank Booth",true) + if(bank != null){ + bot.pulseManager.run(object : MovementPulse(bot,bank, DestinationFlag.OBJECT){ + override fun pulse(): Boolean { + val logs = bot.inventory.getAmount(Item(Items.WILLOW_LOGS_1519)) + logCount += logs + bot.inventory.remove(Item(Items.WILLOW_LOGS_1519,logs)) + bot.bank.add(Item(Items.WILLOW_LOGS_1519,logs)) + state = State.CHOPPING + return true + } + }) + } + } + } + + + + } + } + + init { + inventory.add(Item(Items.ADAMANT_AXE_1357)) + skills[Skills.WOODCUTTING] = 35 + } + + override fun newInstance(): Script { + val script = DraynorWillows() + return script + } + + enum class State { + CHOPPING, + BANKING, + INIT + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt new file mode 100644 index 000000000..d8364100c --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt @@ -0,0 +1,198 @@ +package rs09.game.ai.general.scriptrepository + +import core.game.interaction.DestinationFlag +import core.game.interaction.MovementPulse +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import core.game.system.task.Pulse +import core.game.world.map.Location +import core.game.world.map.path.Pathfinder +import core.game.world.update.flag.context.Animation +import core.game.world.update.flag.context.Graphics +import core.tools.RandomFunction +import org.rs09.consts.Items +import rs09.game.ai.AIPlayer +import rs09.game.ai.general.ScriptAPI +import rs09.game.interaction.InteractionListener +import rs09.game.interaction.InteractionListeners +import rs09.game.world.GameWorld +import kotlin.random.Random + +@PlayerCompatible +@ScriptName("Catherby Lobs") +@ScriptDescription("Start in Catherby bank with a lobster pot in your inventory.") +@ScriptIdentifier("cath_lobs") +class LobsterCatcher : Script() { + private val ANIMATION = Animation(714) + val offers = HashMap() + val limit = 2000 + var myCounter = 0 + /** + * Represents the graphics to use. + */ + private val GRAPHICS = Graphics(308, 100, 50) + internal enum class Sets(val equipment: List) { + SET_1(listOf(Item(2643), Item(9470), Item(10756), Item(10394), Item(88), Item(9793))), + SET_2(listOf(Item(2643), Item(6585), Item(10750), Item(10394), Item(88), Item(9793))), + SET_3(listOf(Item(9472), Item(9470), Item(10750), Item(10394), Item(88), Item(9786))), + SET_4(listOf(Item(2639), Item(6585), Item(10752), Item(10394), Item(88), Item(9786))), + SET_5(listOf(Item(2639), Item(9470), Item(10750), Item(10394), Item(88), Item(9784))), + SET_6(listOf(Item(2639), Item(6585), Item(10750), Item(10394), Item(88), Item(9784))); + + } + + private var bots = 0 + private var lobstopper = false + var overlay: ScriptAPI.BottingOverlay?= null + var fishCounter = 0 + + private var state = State.INIT + private var tick = 0 + override fun tick() { + when(state){ + + State.INIT -> { + overlay = scriptAPI.getOverlay() + overlay!!.init() + overlay!!.setTitle("Fishing") + overlay!!.setTaskLabel("Lobs Caught:") + overlay!!.setAmount(0) + state = State.FIND_SPOT + } + + + State.BANKING -> { + fishCounter += bot.inventory.getAmount(Items.RAW_LOBSTER_377) + scriptAPI.bankItem(Items.RAW_LOBSTER_377) + state = State.IDLE + } + + + State.FISHING -> { + bot.interfaceManager.close() + val spot = scriptAPI.getNearestNode(333, false) + if(spot == null){ + state = State.IDLE + } else { + InteractionListeners.run(spot.id,InteractionListener.NPC,"cage",bot,spot) + } + if(bot.inventory.isFull){ + state = State.FIND_BANK + } + overlay!!.setAmount(fishCounter + bot.inventory.getAmount(Items.RAW_LOBSTER_377)) + } + + State.IDLE -> { + if (Random.nextBoolean()){ + state = State.FIND_SPOT + } + else if(myCounter++ >= RandomFunction.random(1,25)){ + state = State.FIND_SPOT + } + } + + State.FIND_SPOT -> { + val spot = scriptAPI.getNearestNode(333, false) + if (spot != null) { + bot.walkingQueue.reset() + state = State.FISHING + } else { + if (bot.location.x < 2837) { + Pathfinder.find(bot, Location.create(2837, 3435, 0)).walk(bot) + } else { + Pathfinder.find(bot, Location.create(2854, 3427, 0)).walk(bot) + } + } + } + + + State.FIND_BANK -> { + val bank = scriptAPI.getNearestGameObject(bot.location, 2213) + class BankingPulse : MovementPulse(bot, bank, DestinationFlag.OBJECT) { + override fun pulse(): Boolean { + bot.faceLocation(bank!!.location) + state = State.BANKING + return true + } + } + if(bank != null){ + bot.pulseManager.run(BankingPulse()) + } else { + if (bot.location.x > 2837) { + Pathfinder.find(bot, Location.create(2837, 3435, 0)).walk(bot) + } else if (bot.location.x > 2821) { + Pathfinder.find(bot, Location.create(2821, 3435, 0)).walk(bot) + } else if (bot.location.x > 2809){ + Pathfinder.find(bot,Location.create(2809, 3436, 0)).walk(bot) + } + } + } + + + State.TELEPORT_GE -> { + scriptAPI.teleportToGE() + state = State.SELL_GE + } + + + State.SELL_GE -> { + scriptAPI.sellOnGE(Items.RAW_LOBSTER_377) + state = State.TELE_CATH + } + + State.TELE_CATH -> { + if(tick++ == 10) { + bot.lock() + bot.visualize(ANIMATION, GRAPHICS) + bot.impactHandler.disabledTicks = 4 + val location = Location.create(2819, 3437, 0) + GameWorld.Pulser.submit(object : Pulse(4, bot) { + override fun pulse(): Boolean { + bot.unlock() + bot.properties.teleportLocation = location + bot.animator.reset() + state = State.IDLE + return true + } + }) + } + } + + + } + } + + + init { + val setUp = RandomFunction.random(Sets.values().size) + equipment.addAll(Sets.values()[setUp].equipment) + inventory.add(Item(301)) + skills[Skills.FISHING] = 40 + } + + enum class State{ + FISHING, + BANKING, + FIND_BANK, + FIND_SPOT, + TELEPORT_GE, + SELL_GE, + TELE_CATH, + IDLE, + INIT + } + + override fun newInstance(): Script { + if (!lobstopper && bots <= 0) { + val script = LobsterCatcher() + script.bot = AIPlayer(bot.startLocation) + script.state = State.FIND_SPOT + bots = 1 + return script + }else if (tick++ == 6000 && lobstopper) { + tick = 0 + lobstopper = false + } + return newInstance() + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt new file mode 100644 index 000000000..313ad1561 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt @@ -0,0 +1,119 @@ +package rs09.game.ai.general.scriptrepository + +import core.game.interaction.DestinationFlag +import core.game.interaction.MovementPulse +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import core.game.world.map.Location +import core.game.world.map.zone.ZoneBorders +import core.tools.RandomFunction +import org.rs09.consts.Items +import rs09.game.ai.general.ScriptAPI +import rs09.game.ai.skillingbot.SkillingBotAssembler +import rs09.game.interaction.InteractionListener +import rs09.game.interaction.InteractionListeners + +@PlayerCompatible +@ScriptName("Seers Magics") +@ScriptDescription("Start in Seers Bank with an axe equipped or in your inventory.") +@ScriptIdentifier("seers_magics") +class SeersMagicTrees : Script(){ + var state = State.INIT + var stage = 0 + val bankZone = ZoneBorders(2722,3490,2727,3493) + val magicsZone = ZoneBorders(2700, 3396,2704, 3399) + var overlay: ScriptAPI.BottingOverlay? = null + var logCounter = 0 + + override fun tick() { + when(state){ + + State.INIT -> { + overlay = scriptAPI.getOverlay() + overlay!!.init() + overlay!!.setTitle("Woodcutting") + overlay!!.setTaskLabel("Logs cut:") + overlay!!.setAmount(0) + state = State.RETURN_TO_TREES + } + + State.CHOPPING -> { + val tree = scriptAPI.getNearestNode(1306,true) + bot.interfaceManager.close() + tree?.let { InteractionListeners.run(tree.id, InteractionListener.OBJECT,"Chop down",bot,tree) } + if(bot.inventory.isFull){ + state = State.FIND_BANK + } + overlay!!.setAmount(logCounter + bot.inventory.getAmount(Items.MAGIC_LOGS_1513)) + } + + State.FIND_BANK -> { + if(!bankZone.insideBorder(bot)){ + scriptAPI.walkTo(bankZone.randomLoc) + } else { + state = State.BANKING + } + } + + State.BANKING -> { + val bank = scriptAPI.getNearestNode(25808,true) + if(bank != null) + bot.pulseManager.run(object: MovementPulse(bot,bank, DestinationFlag.OBJECT){ + override fun pulse(): Boolean { + bot.faceLocation(bank.location) + logCounter += bot.inventory.getAmount(Items.MAGIC_LOGS_1513) + scriptAPI.bankItem(Items.MAGIC_LOGS_1513) + state = State.RETURN_TO_TREES + return true + } + }) + } + + State.RETURN_TO_TREES -> { + bot.interfaceManager.close() + if(!magicsZone.insideBorder(bot)){ + scriptAPI.walkTo(magicsZone.randomLoc) + } else { + state = State.CHOPPING + } + } + + State.TELE_GE -> { + state = State.SELL_GE + scriptAPI.teleportToGE() + } + + State.SELL_GE -> { + state = State.TELE_SEERS + scriptAPI.sellOnGE(Items.MAGIC_LOGS_1513) + } + + State.TELE_SEERS -> { + state = State.RETURN_TO_TREES + scriptAPI.teleport(Location.create(2756, 3478, 0)) + } + } + } + + init { + inventory.add(Item(Items.RUNE_AXE_1359)) + skills[Skills.WOODCUTTING] = RandomFunction.random(75,99) + } + + enum class State { + CHOPPING, + FIND_BANK, + BANKING, + RETURN_TO_TREES, + TELE_GE, + SELL_GE, + TELE_SEERS, + INIT + } + + override fun newInstance(): Script { + val script = SeersMagicTrees() + script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.AVERAGE,bot.startLocation) + return script + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt index 2d78e48a0..f1a909d53 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt @@ -114,6 +114,7 @@ class SharkCatcher : Script() { } State.FISHING -> { + bot.interfaceManager.close() if (Random.nextBoolean()) { tick = 0 val spot = scriptAPI.getNearestNode(334, false) diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt index d429713c4..5054b98e0 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt @@ -22,6 +22,7 @@ class VarrockEssenceMiner : Script(){ when(state){ State.TO_ESSENCE -> { + bot.interfaceManager.close() if(!auburyZone.insideBorder(bot)) scriptAPI.walkTo(auburyZone.randomLoc) else { From 922657b762fc97ed1210fdd97a15a7709c5a4f75 Mon Sep 17 00:00:00 2001 From: philliam Date: Sat, 26 Jun 2021 01:18:51 -0400 Subject: [PATCH 2/6] Player script fixes, and bankAll scriptAPI function added Fixed the bank window exploit in the coal miner, Draynor willows, lobster catcher, Seers magic, shark catcher, and Varrock essence scripts. Made it so that the coal miner script banks its entire inventory instead of just the coal ore, this way it should no longer get stuck if its inventory is full of mithril ore and uncut gems. Fixed the Draynor willows and Seers magic trees scripts so that the bot actually chops down the trees instead of just standing next to them. Added a bankAll function to the scriptAPI, the coal miner script is dependent on this change --- .../kotlin/rs09/game/ai/general/ScriptAPI.kt | 22 ++++++++++ .../ai/general/scriptrepository/CoalMiner.kt | 44 +++++++++++++++++++ .../scriptrepository/DraynorWillows.kt | 6 +++ .../scriptrepository/LobsterCatcher.kt | 11 +++++ .../scriptrepository/SeersMagicTrees.kt | 9 ++++ .../general/scriptrepository/SharkCatcher.kt | 1 + .../scriptrepository/VarrockEssenceMiner.kt | 1 + 7 files changed, 94 insertions(+) diff --git a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt index 567aca3b3..d5306bb55 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt @@ -550,6 +550,28 @@ class ScriptAPI(private val bot: Player) { bot.pulseManager.run(BankingPulse()) } + /** + * Takes every item out of the bots inventory and places it into the bank. + * @param none + * @author cfunnyman joe + */ + fun bankAll(){ + class BankingPulse() : Pulse(20){ + override fun pulse(): Boolean { + for(item in bot.inventory.toArray()){ + var itemAmount = bot.inventory.getAmount(item) + + bot.inventory.remove(item) + bot.bank.add(item) + bot.bank.refresh() + bot.inventory.refresh() + } + return true + } + } + bot.pulseManager.run(BankingPulse()) + } + /** * Function that makes the bot eat the food item in their inventory if their HP is below 2/3. * @author Ceikry diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt index 9fc4b307b..f57aecfd0 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/CoalMiner.kt @@ -1,5 +1,9 @@ package rs09.game.ai.general.scriptrepository +<<<<<<< refs/remotes/2009scape/master +======= + +>>>>>>> Player script fixes, and bankAll scriptAPI function added import core.game.interaction.DestinationFlag import core.game.interaction.MovementPulse import core.game.node.Node @@ -11,21 +15,38 @@ import rs09.game.ai.general.ScriptAPI import rs09.game.ai.skillingbot.SkillingBotAssembler import rs09.game.interaction.InteractionListener import rs09.game.interaction.InteractionListeners +<<<<<<< refs/remotes/2009scape/master +======= +import api.ContentAPI +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import java.util.logging.Handler +>>>>>>> Player script fixes, and bankAll scriptAPI function added @PlayerCompatible @ScriptName("Falador Coal Miner") @ScriptDescription("Start in Falador East Bank with a pick equipped","or in your inventory.") @ScriptIdentifier("fally_coal") +<<<<<<< refs/remotes/2009scape/master class CoalMiner() : Script() { var state = State.INIT var ladderSwitch = false +======= +class CoalMiner : Script() { + var state = State.INIT + var ladderSwitch = false +>>>>>>> Player script fixes, and bankAll scriptAPI function added val bottomLadder = ZoneBorders(3016,9736,3024,9742) val topLadder = ZoneBorders(3016,3336,3022,3342) val mine = ZoneBorders(3027,9733,3054,9743) val bank = ZoneBorders(3009,3355,3018,3358) var overlay: ScriptAPI.BottingOverlay? = null +<<<<<<< refs/remotes/2009scape/master var coalAmount = 0 +======= + var coalAmount = 0 +>>>>>>> Player script fixes, and bankAll scriptAPI function added override fun tick() { when(state){ @@ -47,6 +68,10 @@ class CoalMiner() : Script() { } State.MINING -> { +<<<<<<< refs/remotes/2009scape/master +======= + bot.interfaceManager.close() +>>>>>>> Player script fixes, and bankAll scriptAPI function added if(bot.inventory.freeSlots() == 0){ state = State.TO_BANK } @@ -56,7 +81,11 @@ class CoalMiner() : Script() { val rock = scriptAPI.getNearestNode("rocks",true) rock?.let { InteractionListeners.run(rock.id, InteractionListener.OBJECT,"mine",bot,rock) } } +<<<<<<< refs/remotes/2009scape/master overlay!!.setAmount(bot.inventory.getAmount(Items.COAL_453) + coalAmount) +======= + overlay!!.setAmount(ContentAPI.amountInInventory(bot, Items.COAL_453) + coalAmount) +>>>>>>> Player script fixes, and bankAll scriptAPI function added } State.TO_BANK -> { @@ -83,13 +112,22 @@ class CoalMiner() : Script() { } State.BANKING -> { +<<<<<<< refs/remotes/2009scape/master coalAmount += bot.inventory.getAmount(Items.COAL_453) scriptAPI.bankItem(Items.COAL_453) +======= + coalAmount += bot.inventory.getAmount(Items.COAL_453) + scriptAPI.bankAll() +>>>>>>> Player script fixes, and bankAll scriptAPI function added state = State.TO_MINE } State.TO_MINE -> { if(ladderSwitch){ +<<<<<<< refs/remotes/2009scape/master +======= + bot.interfaceManager.close() +>>>>>>> Player script fixes, and bankAll scriptAPI function added if(!topLadder.insideBorder(bot.location)){ scriptAPI.walkTo(topLadder.randomLoc) } else { @@ -124,7 +162,10 @@ class CoalMiner() : Script() { scriptAPI.teleport(bank.randomLoc) state = State.TO_MINE } +<<<<<<< refs/remotes/2009scape/master +======= +>>>>>>> Player script fixes, and bankAll scriptAPI function added } } @@ -156,5 +197,8 @@ class CoalMiner() : Script() { equipment.add(Item(Items.IRON_PICKAXE_1267)) skills.put(Skills.MINING,75) } +<<<<<<< refs/remotes/2009scape/master +======= +>>>>>>> Player script fixes, and bankAll scriptAPI function added } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt index b9195bb2e..ad2fbf53e 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/DraynorWillows.kt @@ -41,8 +41,14 @@ class DraynorWillows : Script(){ scriptAPI.walkTo(willowZone.randomLoc) else { val willowtree = scriptAPI.getNearestNode("willow", true) +<<<<<<< refs/remotes/2009scape/master willowtree?.let { InteractionListeners.run(willowtree.id, InteractionListener.OBJECT,"chop",bot,willowtree) } +======= + bot.interfaceManager.close() + willowtree?.let { InteractionListeners.run(willowtree.id, + InteractionListener.OBJECT,"Chop down",bot,willowtree) } +>>>>>>> Player script fixes, and bankAll scriptAPI function added if (bot.inventory.isFull) state = State.BANKING } diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt index 6863f20dd..9532b8b0f 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/LobsterCatcher.kt @@ -69,6 +69,10 @@ class LobsterCatcher : Script() { State.FISHING -> { +<<<<<<< refs/remotes/2009scape/master +======= + bot.interfaceManager.close() +>>>>>>> Player script fixes, and bankAll scriptAPI function added val spot = scriptAPI.getNearestNode(333, false) if(spot == null){ state = State.IDLE @@ -163,10 +167,17 @@ class LobsterCatcher : Script() { init { +<<<<<<< refs/remotes/2009scape/master val setUp = RandomFunction.random(Sets.values().size) equipment.addAll(Sets.values()[setUp].equipment) inventory.add(Item(301)) skills[Skills.FISHING] = 40 +======= + val setUp = RandomFunction.random(Sets.values().size) + equipment.addAll(Sets.values()[setUp].equipment) + inventory.add(Item(301)) + skills[Skills.FISHING] = 40 +>>>>>>> Player script fixes, and bankAll scriptAPI function added } enum class State{ diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt index 48b7b45c3..c2abc1365 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SeersMagicTrees.kt @@ -39,7 +39,12 @@ class SeersMagicTrees : Script(){ State.CHOPPING -> { val tree = scriptAPI.getNearestNode(1306,true) +<<<<<<< refs/remotes/2009scape/master tree?.let { InteractionListeners.run(tree.id, InteractionListener.OBJECT,"chop",bot,tree) } +======= + bot.interfaceManager.close() + tree?.let { InteractionListeners.run(tree.id, InteractionListener.OBJECT,"Chop down",bot,tree) } +>>>>>>> Player script fixes, and bankAll scriptAPI function added if(bot.inventory.isFull){ state = State.FIND_BANK } @@ -69,6 +74,10 @@ class SeersMagicTrees : Script(){ } State.RETURN_TO_TREES -> { +<<<<<<< refs/remotes/2009scape/master +======= + bot.interfaceManager.close() +>>>>>>> Player script fixes, and bankAll scriptAPI function added if(!magicsZone.insideBorder(bot)){ scriptAPI.walkTo(magicsZone.randomLoc) } else { diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt index 2d78e48a0..f1a909d53 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/SharkCatcher.kt @@ -114,6 +114,7 @@ class SharkCatcher : Script() { } State.FISHING -> { + bot.interfaceManager.close() if (Random.nextBoolean()) { tick = 0 val spot = scriptAPI.getNearestNode(334, false) diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt index d429713c4..5054b98e0 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/VarrockEssenceMiner.kt @@ -22,6 +22,7 @@ class VarrockEssenceMiner : Script(){ when(state){ State.TO_ESSENCE -> { + bot.interfaceManager.close() if(!auburyZone.insideBorder(bot)) scriptAPI.walkTo(auburyZone.randomLoc) else { From bfa0439516eb7f2938c2658384f3085cb1d13b4a Mon Sep 17 00:00:00 2001 From: philliam Date: Sun, 27 Jun 2021 10:31:38 -0400 Subject: [PATCH 3/6] Removed unnecessary refreshes in bankAll function --- Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt index d5306bb55..18226073b 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt @@ -563,8 +563,6 @@ class ScriptAPI(private val bot: Player) { bot.inventory.remove(item) bot.bank.add(item) - bot.bank.refresh() - bot.inventory.refresh() } return true } From f473ac3119e1b42737ddf4140de590b22ea4c2e0 Mon Sep 17 00:00:00 2001 From: philliam Date: Sun, 18 Jul 2021 18:42:04 -0400 Subject: [PATCH 4/6] Added bone burying to the Chicken Killer botscript Made takeNearestGroundItem() return a boolean in scriptAPI --- .../kotlin/rs09/game/ai/general/ScriptAPI.kt | 7 ++- .../general/scriptrepository/ChickenKiller.kt | 51 ++++++++++++++++--- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt index 8e1f8dc90..914843913 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/ScriptAPI.kt @@ -213,10 +213,13 @@ class ScriptAPI(private val bot: Player) { * @param id the id to look for * @author Ceikry */ - fun takeNearestGroundItem(id: Int){ + fun takeNearestGroundItem(id: Int) : Boolean{ val item = getNearestGroundItem(id) - if(item != null) + if(item != null){ item.interaction?.handle(bot, item.interaction[2]) + return true + } + else return false } /** diff --git a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/ChickenKiller.kt b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/ChickenKiller.kt index 4bb569afc..d462bf565 100644 --- a/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/ChickenKiller.kt +++ b/Server/src/main/kotlin/rs09/game/ai/general/scriptrepository/ChickenKiller.kt @@ -1,6 +1,8 @@ package rs09.game.ai.general.scriptrepository +import core.game.node.item.Item import core.game.world.map.Location +import core.game.world.map.zone.ZoneBorders import org.rs09.consts.Items import rs09.game.ai.general.ScriptAPI @@ -11,14 +13,16 @@ import rs09.game.ai.general.ScriptAPI class ChickenKiller : Script(){ var state = State.INIT var chickenCounter = 0 - var overlay: ScriptAPI.BottingOverlay?= null + var overlay: ScriptAPI.BottingOverlay? = null var startLocation = Location(0,0,0) var timer = 3 var lootFeathers = false + var featherNearby = false + var currentFeathers = 0 + val chickenPen = ZoneBorders(3231,3300,3235,3287) override fun tick() { when(state){ - State.INIT -> { overlay = scriptAPI.getOverlay() overlay!!.init() @@ -26,7 +30,7 @@ class ChickenKiller : Script(){ overlay!!.setTaskLabel("Chickens KO'd:") overlay!!.setAmount(0) state = State.CONFIG - bot.dialogueInterpreter.sendOptions("Loot Feathers?","Yes","No") + bot.dialogueInterpreter.sendOptions("Loot Feathers and bury bones?","Yes","No") bot.dialogueInterpreter.addAction{player,button -> lootFeathers = button == 2 state = State.KILLING @@ -51,15 +55,43 @@ class ChickenKiller : Script(){ State.IDLE -> { if(timer-- <= 0){ - state = State.LOOTING + featherNearby = scriptAPI.takeNearestGroundItem(Items.FEATHER_314) + currentFeathers = 0 + if (featherNearby) { + state = State.LOOTFEATHER + }else{ + state = State.LOOTBONES + } } } - State.LOOTING -> { - scriptAPI.takeNearestGroundItem(Items.FEATHER_314) - state = State.KILLING + State.LOOTFEATHER -> { + timer = 1 + if(timer-- >= 0) { + currentFeathers = bot.inventory.getAmount(Items.FEATHER_314) + scriptAPI.takeNearestGroundItem(Items.FEATHER_314) + featherNearby = false + } + state = State.LOOTBONES } + State.LOOTBONES -> { + timer = 1 + if(timer-- >= 0){ + scriptAPI.takeNearestGroundItem(Items.BONES_526) + } + state = State.BURYBONES + } + + State.BURYBONES -> { + timer = 1 + var hasBone = bot.hasItem(Item(Items.BONES_526)) + var bone = bot.inventory.getItem(Item(Items.BONES_526)) + if (hasBone) { + bone.interaction.handleItemOption(bot,bone.interaction.get(0),bot.inventory) + } + state = State.KILLING + } } } @@ -73,6 +105,9 @@ class ChickenKiller : Script(){ KILLING, LOOTING, RETURN, - CONFIG + CONFIG, + LOOTFEATHER, + LOOTBONES, + BURYBONES } } \ No newline at end of file From 69888a00d78f33cb1b19e4eec7365457d0ae27f2 Mon Sep 17 00:00:00 2001 From: philliam Date: Mon, 19 Jul 2021 12:45:06 -0400 Subject: [PATCH 5/6] Rewrote the entire AbyssPlugin into kotlin Fixed all of the Abyss obstacle checks to be more authentic. Obstacle checks are now calculated based on the players skill level corresponding to that specific obstacle. ie: 99 thieving will have a 1% fail chance when distracting eyes and 50 agility will have a 50% failure chance when squeezing through the agility passage. Replaced some AbyssPlugin code with ContentAPI code. Added color coding to obstacle related messages, red text if you fail, green text if you pass. Removed the AbyssPlugin.java reference from the RunecraftingPlugin --- .../runecrafting/RunecraftingPlugin.java | 2 - .../skill/runecrafting/abyss/AbyssPlugin.java | 440 ----------------- .../skill/runecrafting/abyss/AbyssPlugin.kt | 462 ++++++++++++++++++ 3 files changed, 462 insertions(+), 442 deletions(-) delete mode 100644 Server/src/main/java/core/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.java create mode 100644 Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt diff --git a/Server/src/main/java/core/game/node/entity/skill/runecrafting/RunecraftingPlugin.java b/Server/src/main/java/core/game/node/entity/skill/runecrafting/RunecraftingPlugin.java index 0418e904f..051d032fb 100644 --- a/Server/src/main/java/core/game/node/entity/skill/runecrafting/RunecraftingPlugin.java +++ b/Server/src/main/java/core/game/node/entity/skill/runecrafting/RunecraftingPlugin.java @@ -10,7 +10,6 @@ import core.game.node.Node; import core.game.node.entity.npc.NPC; import core.game.node.entity.player.Player; import core.game.node.entity.player.info.Rights; -import core.game.node.entity.skill.runecrafting.abyss.AbyssPlugin; import core.game.node.item.Item; import core.game.node.object.Scenery; import core.game.system.task.Pulse; @@ -35,7 +34,6 @@ public class RunecraftingPlugin extends OptionHandler { @Override public Plugin newInstance(Object arg) throws Throwable { addNodes(); - PluginManager.definePlugin(new AbyssPlugin()); PluginManager.definePlugin(new TiaraPlugin()); PluginManager.definePlugin(new RunePouchPlugin()); PluginManager.definePlugin(new EnchantTiaraPlugin()); diff --git a/Server/src/main/java/core/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.java b/Server/src/main/java/core/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.java deleted file mode 100644 index d90ee90f2..000000000 --- a/Server/src/main/java/core/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.java +++ /dev/null @@ -1,440 +0,0 @@ -package core.game.node.entity.skill.runecrafting.abyss; - -import core.cache.def.impl.NPCDefinition; -import core.cache.def.impl.SceneryDefinition; -import core.game.node.entity.skill.gather.SkillingTool; -import core.game.node.entity.skill.runecrafting.Altar; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.impl.Animator.Priority; -import core.game.node.entity.npc.NPC; -import core.game.node.entity.player.Player; -import core.game.node.object.Scenery; -import core.game.system.task.Pulse; -import rs09.game.world.GameWorld; -import core.game.world.map.Location; -import core.game.world.update.flag.context.Animation; -import core.game.world.update.flag.context.Graphics; -import core.plugin.Plugin; -import rs09.plugin.PluginManager; -import core.tools.RandomFunction; - -/** - * A plugin used to handle the abyss. - * @author Vexia - */ -public final class AbyssPlugin extends OptionHandler { - - @Override - public Plugin newInstance(Object arg) throws Throwable { - for (AbbysalObstacle obstacle : AbbysalObstacle.values()) { - for (int i : obstacle.getObjects()) { - SceneryDefinition.forId(i).getHandlers().put("option:" + obstacle.getOption(), this); - } - } - PluginManager.definePlugin(new AbyssalNPC()); - PluginManager.definePlugin(new DarkMageDialogue()); - SceneryDefinition.setOptionHandler("exit-through", this); - PluginManager.definePlugin(new ZamorakMageDialogue()); - NPCDefinition.forId(2259).getHandlers().put("option:teleport", this); - NPCDefinition.forId(2262).getHandlers().put("option:repair-pouches", this); - return null; - } - - @Override - public boolean handle(Player player, Node node, String option) { - switch (option) { - case "teleport": - teleport(player, (NPC) node); - break; - case "repair-pouches": - player.getDialogueInterpreter().open(node.getId(), node, true); - break; - case "exit-through": - Altar altar = Altar.forObject((Scenery) node); - if (altar != null) { - altar.enterRift(player); - } - break; - case "mine": - case "chop": - case "squeeze-through": - case "distract": - case "go-through": - case "burn-down": - final AbbysalObstacle obstacle = AbbysalObstacle.forObject(((Scenery) node)); - obstacle.handle(player, ((Scenery) node)); - break; - } - return true; - } - - /** - * Represents the teleporting to the abyss. - * @param player the player. - */ - public static void teleport(final Player player, final NPC npc) { - player.lock(3); - npc.visualize(new Animation(1979), new Graphics(4)); - npc.sendChat("Veniens! Sallakar! Rinnesset!"); - player.getSkills().decrementPrayerPoints(100); - player.getSkullManager().checkSkull(player); - GameWorld.getPulser().submit(new Pulse(2, player) { - @Override - public boolean pulse() { - player.getProperties().setTeleportLocation(Location.create(3021, 4847, 0)); - npc.getUpdateMasks().reset(); - return true; - } - }); - } - - /** - * Represents an obstacle in an abbsyal. - * @author 'Vexia - * @date 02/11/2013 - */ - public enum AbbysalObstacle { - BOIL("burn-down", new Location[] { Location.create(3024, 4833, 0), Location.create(3053, 4830, 0) }, 7165) { - @Override - public void handle(final Player player, final Scenery object) { - if (!player.getInventory().contains(590, 1)) { - player.getPacketDispatch().sendMessage("You don't have a tinderbox to burn it."); - return; - } - player.animate(new Animation(733)); - player.lock(3); - GameWorld.getPulser().submit(new Pulse(1, player) { - int count = 0; - - @Override - public boolean pulse() { - switch (count) { - case 1: - player.getPacketDispatch().sendMessage("You attempt to burn your way through.."); - break; - case 4: - if (RandomFunction.random(3) != 1) { - player.getPacketDispatch().sendMessage("...and manage to burn it down and get past."); - player.getProperties().setTeleportLocation(getLocations()[getIndex(object)]); - return true; - } else { - player.getPacketDispatch().sendMessage("You fail to set it on fire."); - return true; - } - } - count++; - return false; - } - - @Override - public void stop() { - super.stop(); - player.animate(new Animation(-1, Priority.HIGH)); - } - }); - } - }, - MINE("mine", new Location[] { Location.create(3030, 4821, 0), Location.create(3048, 4822, 0) }, 7158, 7153) { - @Override - public void handle(final Player player, final Scenery object) { - final SkillingTool tool = setTool(true, player); - if (tool == null) { - player.getPacketDispatch().sendMessage("You need a pickaxe in order to do that."); - return; - } - player.animate(tool.getAnimation()); - player.lock(3); - GameWorld.getPulser().submit(new Pulse(1, player) { - int count = 0; - - @Override - public boolean pulse() { - switch (count) { - case 1: - player.getPacketDispatch().sendMessage("You attempt to mine your way through.."); - break; - case 4: - if (RandomFunction.random(3) != 1) { - player.getPacketDispatch().sendMessage("...and manage to break through the rock."); - player.getProperties().setTeleportLocation(getLocations()[getIndex(object)]); - return true; - } else { - player.getPacketDispatch().sendMessage("...but fail to break-up the rock."); - return true; - } - } - count++; - return false; - } - - @Override - public void stop() { - super.stop(); - player.animate(new Animation(-1, Priority.HIGH)); - } - }); - } - }, - CHOP("chop", new Location[] { Location.create(3050, 4824, 0), Location.create(3028, 4824, 0) }, 7161, 7144) { - @Override - public void handle(final Player player, final Scenery object) { - final SkillingTool tool = setTool(false, player); - if (tool == null) { - player.getPacketDispatch().sendMessage("You need an axe in order to do that."); - return; - } - player.animate(tool.getAnimation()); - player.lock(3); - GameWorld.getPulser().submit(new Pulse(1, player) { - int count = 0; - - @Override - public boolean pulse() { - switch (count) { - case 1: - player.getPacketDispatch().sendMessage("You attempt to chop your way through..."); - break; - case 4: - if (RandomFunction.random(3) != 1) { - player.getPacketDispatch().sendMessage("...and manage to chop down the tendrils."); - player.getProperties().setTeleportLocation(getLocations()[getIndex(object)]); - return true; - } else { - player.getPacketDispatch().sendMessage("You fail to cut through the tendrils."); - return true; - } - } - count++; - return false; - } - - @Override - public void stop() { - super.stop(); - player.animate(new Animation(-1, Priority.HIGH)); - } - }); - } - }, - SQUEEZE("squeeze-through", new Location[] { Location.create(3048, 4842, 0), Location.create(3031, 4842, 0) }, 7164, 7147) { - @Override - public void handle(final Player player, final Scenery object) { - player.animate(new Animation(1331)); - player.lock(3); - player.lock(3); - GameWorld.getPulser().submit(new Pulse(1, player) { - int count = 0; - - @Override - public boolean pulse() { - switch (count) { - case 1: - player.getPacketDispatch().sendMessage("You attempt to squeeze through the narrow gap..."); - break; - case 2: - player.getPacketDispatch().sendMessage("...and you manage to crawl through."); - player.getProperties().setTeleportLocation(getLocations()[getIndex(object)]); - return true; - } - count++; - return false; - } - - @Override - public void stop() { - super.stop(); - player.animate(new Animation(-1, Priority.HIGH)); - } - }); - } - }, - DISTRACT("distract", new Location[] { Location.create(3029, 4841, 0), Location.create(3051, 4838, 0) }, 7168, 7150) { - @Override - public void handle(final Player player, final Scenery object) { - int[] emotes = { 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 2113, 2109, 2111, 2106, 2107, 2108, 0x558, 2105, 2110, 2112, 0x84F, 0x850, 1131, 1130, 1129, 1128, 1745, 3544, 3543, 2836 }; - int index = RandomFunction.random(emotes.length); - player.animate(new Animation(emotes[index])); - player.lock(3); - GameWorld.getPulser().submit(new Pulse(1, player) { - int count = 0; - - @Override - public boolean pulse() { - switch (count) { - case 1: - player.getPacketDispatch().sendMessage("You use your thieving skills to misdirect the eyes..."); - break; - case 4: - if (RandomFunction.random(3) != 1) { - player.getPacketDispatch().sendMessage("...and sneak past while they're not looking."); - player.getProperties().setTeleportLocation(getLocations()[getIndex(object)]); - } else { - player.getPacketDispatch().sendMessage("You fail to distract the eyes."); - return true; - } - return true; - } - count++; - return false; - } - - @Override - public void stop() { - super.stop(); - player.animate(new Animation(-1, Priority.HIGH)); - } - }); - } - }, - PASSAGE("go-through", new Location[] { Location.create(3040, 4844, 0) }, 7154) { - @Override - public void handle(final Player player, final Scenery object) { - player.getProperties().setTeleportLocation(getLocations()[0]); - } - }; - /** - * Constructs a new {@code RunecraftingOptionPlugin} {@code Object}. - * @param locations the locations. - * @param objects the objects. - */ - AbbysalObstacle(final String option, Location[] locations, int... objects) { - this.option = option; - this.objects = objects; - this.locations = locations; - this.option = option; - } - - /** - * Represents the option. - */ - private String option; - - /** - * Represents the corssing location. - */ - private final Location[] locations; - - /** - * Represents the object id. - */ - private final int[] objects; - - /** - * Gets the locations. - * @return The locations. - */ - public Location[] getLocations() { - return locations; - } - - /** - * Gets the objects. - * @return The objects. - */ - public int[] getObjects() { - return objects; - } - - /** - * Method used to get the abbysal obstacle. - * @param object the object. - * @return the AbbysalObstacle or Null. - */ - public static AbbysalObstacle forObject(final Scenery object) { - for (AbbysalObstacle obstacle : values()) { - for (int i : obstacle.getObjects()) { - if (i == object.getId()) { - return obstacle; - } - } - } - return null; - } - - /** - * Method used to get the index. - * @param object the object. - * @return the index. - */ - public int getIndex(final Scenery object) { - for (int i = 0; i < objects.length; i++) { - if (getObjects()[i] == object.getId()) { - return i; - } - } - return 0; - } - - /** - * Methhod used to handle the obstacle. - * @param player the player. - * @param object the object. - */ - public void handle(final Player player, final Scenery object) { - - } - - /** - * Gets the option. - * @return The option. - */ - public String getOption() { - return option; - } - - /** - * Sets the tool used. - */ - private static SkillingTool setTool(final boolean mining, final Player player) { - SkillingTool tool = null; - if (!mining) { - if (checkTool(player, SkillingTool.DRAGON_AXE)) { - tool = SkillingTool.DRAGON_AXE; - } else if (checkTool(player, SkillingTool.RUNE_AXE)) { - tool = SkillingTool.RUNE_AXE; - } else if (checkTool(player, SkillingTool.ADAMANT_AXE)) { - tool = SkillingTool.ADAMANT_AXE; - } else if (checkTool(player, SkillingTool.MITHRIL_AXE)) { - tool = SkillingTool.MITHRIL_AXE; - } else if (checkTool(player, SkillingTool.BLACK_AXE)) { - tool = SkillingTool.BLACK_AXE; - } else if (checkTool(player, SkillingTool.STEEL_AXE)) { - tool = SkillingTool.STEEL_AXE; - } else if (checkTool(player, SkillingTool.IRON_AXE)) { - tool = SkillingTool.IRON_AXE; - } else if (checkTool(player, SkillingTool.BRONZE_AXE)) { - tool = SkillingTool.BRONZE_AXE; - } - } else { - if (checkTool(player, SkillingTool.RUNE_PICKAXE)) { - tool = SkillingTool.RUNE_PICKAXE; - } else if (checkTool(player, SkillingTool.ADAMANT_PICKAXE)) { - tool = SkillingTool.ADAMANT_PICKAXE; - } else if (checkTool(player, SkillingTool.MITHRIL_PICKAXE)) { - tool = SkillingTool.MITHRIL_PICKAXE; - } else if (checkTool(player, SkillingTool.STEEL_PICKAXE)) { - tool = SkillingTool.STEEL_PICKAXE; - } else if (checkTool(player, SkillingTool.IRON_PICKAXE)) { - tool = SkillingTool.IRON_PICKAXE; - } else if (checkTool(player, SkillingTool.BRONZE_PICKAXE)) { - tool = SkillingTool.BRONZE_PICKAXE; - } - } - return tool; - } - - /** - * Checks if the player has a tool and if he can use it. - * @param tool The tool. - * @return {@code True} if the tool is usable. - */ - private static boolean checkTool(final Player player, SkillingTool tool) { - if (player.getEquipment().contains(tool.getId(), 1)) { - return true; - } - return player.getInventory().contains(tool.getId(), 1); - } - } - -} diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt new file mode 100644 index 000000000..34ac0cf1e --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt @@ -0,0 +1,462 @@ +package core.game.node.entity.skill.runecrafting.abyss + +import api.ContentAPI +import rs09.plugin.PluginManager.definePlugin +import rs09.tools.stringtools.colorize +import rs09.game.system.SystemLogger.logInfo +import core.game.node.`object`.Scenery +import core.game.node.entity.impl.Animator +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.game.node.entity.skill.Skills +import core.game.node.entity.skill.gather.SkillingTool +import core.game.node.entity.skill.runecrafting.Altar +import core.game.system.task.Pulse +import core.game.world.map.Location +import core.game.world.update.flag.context.Animation +import core.game.world.update.flag.context.Graphics +import core.tools.RandomFunction +import org.rs09.consts.NPCs +import rs09.game.interaction.InteractionListener +import rs09.game.world.GameWorld + +/** + * A plugin used to handle the abyss. + * @author cfunny + */ +class AbyssPlugin : InteractionListener() { + + val OBSTACLE = AbbysalObstacle.values().filter { it != AbbysalObstacle.MINE }.map { it.option }.toTypedArray() + val miningObstacle = 7158 + + override fun defineListeners() { + definePlugin(AbyssalNPC()) + definePlugin(DarkMageDialogue()) + definePlugin(ZamorakMageDialogue()) + on(NPCs.MAGE_OF_ZAMORAK_2259, NPC, "teleport"){ player, node -> + teleport(player, node as NPC) + return@on true + } + on(NPCs.DARK_MAGE_2262, NPC, "repair-pouches"){ player, node -> + player.dialogueInterpreter.open(node.id, node, true) + return@on true + } + on(SCENERY, "exit-through"){ player, node -> + val altar = Altar.forObject(node as Scenery) + altar?.enterRift(player) + return@on true + } + on(SCENERY, *OBSTACLE){ player, node -> + val obstacle = AbbysalObstacle.forObject(node as Scenery) + obstacle!!.handle(player, node as Scenery) + return@on true + } + on(miningObstacle, SCENERY, "mine"){ player, node -> + val obstacle = AbbysalObstacle.forObject(node as Scenery) + obstacle!!.handle(player, node as Scenery) + return@on true + } + + + } + + /** + * Represents an obstacle in an abbsyal. + * @author cfunny + * @date 02/11/2013 + */ + enum class AbbysalObstacle( + /** + * Represents the option. + */ + var option: String, + /** + * Represents the corssing location. + */ + val locations: Array, + /** + * Represents the object id. + */ + vararg val objects: Int + ) { + BOIL("burn-down", arrayOf(Location.create(3024, 4833, 0), Location.create(3053, 4830, 0)), 7165) { + override fun handle(player: Player, `object`: Scenery?) { + `object` ?: return + if (!ContentAPI.inInventory(player, 590, 1)) { + ContentAPI.sendMessage(player, "You don't have a tinderbox to burn it.") + return + } + player.animate(Animation(733)) + player.lock() + GameWorld.Pulser.submit(object : Pulse(1, player) { + var count = 0 + override fun pulse(): Boolean { + when (count) { + 1 -> ContentAPI.sendMessage(player, "You attempt to burn your way through..") + 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + player, + Skills.FIREMAKING + ) + ) { + ContentAPI.sendMessage( + player, + colorize("%G...and manage to burn it down and get past.") + ) + player.properties.teleportLocation = locations[getIndex(`object`)] + player.unlock() + true + } else { + ContentAPI.sendMessage(player, colorize("%RYou fail to set it on fire.")) + player.unlock() + true + } + } + count++ + return false + } + + override fun stop() { + super.stop() + player.animate(Animation(-1, Animator.Priority.HIGH)) + } + }) + } + }, + MINE("mine", arrayOf(Location.create(3030, 4821, 0), Location.create(3048, 4822, 0)), 7158, 7153) { + override fun handle(player: Player, `object`: Scenery?) { + `object` ?: return + logInfo("handled abyss mine") + val tool: SkillingTool = ContentAPI.getTool(player, true) ?: return + if (tool == null) { + ContentAPI.sendMessage(player, "You need a pickaxe in order to do that.") + return + } + player.animate(tool.getAnimation()) + player.lock() + GameWorld.Pulser.submit(object : Pulse(1, player) { + var count = 0 + override fun pulse(): Boolean { + when (count) { + 1 -> ContentAPI.sendMessage(player, "You attempt to mine your way through..") + 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + player, + Skills.MINING + ) + ) { + ContentAPI.sendMessage(player, colorize("%G...and manage to break through the rock.")) + player.properties.teleportLocation = locations[getIndex(`object`)] + player.unlock() + true + } else { + ContentAPI.sendMessage(player, colorize("%R...but fail to break-up the rock.")) + player.unlock() + true + } + } + count++ + return false + } + + override fun stop() { + super.stop() + player.animate(Animation(-1, Animator.Priority.HIGH)) + } + }) + } + }, + CHOP("chop", arrayOf(Location.create(3050, 4824, 0), Location.create(3028, 4824, 0)), 7161, 7144) { + override fun handle(player: Player, `object`: Scenery?) { + `object` ?: return + val tool: SkillingTool? = setTool(false, player) + if (tool == null) { + player.packetDispatch.sendMessage("You need an axe in order to do that.") + return + } + player.animate(tool.getAnimation()) + player.lock() + GameWorld.Pulser.submit(object : Pulse(1, player) { + var count = 0 + override fun pulse(): Boolean { + when (count) { + 1 -> ContentAPI.sendMessage(player, "You attempt to chop your way through...") + 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + player, + Skills.WOODCUTTING + ) + ) { + ContentAPI.sendMessage(player, colorize("%G...and manage to chop down the tendrils.")) + player.properties.teleportLocation = locations[getIndex(`object`)] + player.unlock() + true + } else { + ContentAPI.sendMessage(player, colorize("%RYou fail to cut through the tendrils.")) + player.unlock() + true + } + } + count++ + return false + } + + override fun stop() { + super.stop() + player.animate(Animation(-1, Animator.Priority.HIGH)) + } + }) + } + }, + SQUEEZE( + "squeeze-through", + arrayOf(Location.create(3048, 4842, 0), Location.create(3031, 4842, 0)), + 7164, + 7147 + ) { + override fun handle(player: Player, `object`: Scenery?) { + `object` ?: return + player.animate(Animation(1331)) + player.lock() + GameWorld.Pulser.submit(object : Pulse(1, player) { + var count = 0 + override fun pulse(): Boolean { + when (count) { + 1 -> ContentAPI.sendMessage(player, "You attempt to squeeze through the narrow gap...") + 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + player, + Skills.AGILITY + ) + ) { + ContentAPI.sendMessage(player, colorize("%G...and you manage to crawl through.")) + player.properties.teleportLocation = locations[getIndex(`object`)] + player.unlock() + true + } else { + ContentAPI.sendMessage(player, colorize("%RYou fail to squeeze through the narrow gap")) + player.unlock() + true + } + } + count++ + return false + } + + override fun stop() { + super.stop() + player.animate(Animation(-1, Animator.Priority.HIGH)) + } + }) + } + }, + DISTRACT("distract", arrayOf(Location.create(3029, 4841, 0), Location.create(3051, 4838, 0)), 7168, 7150) { + override fun handle(player: Player, `object`: Scenery?) { + `object` ?: return + val emotes = intArrayOf( + 855, + 856, + 857, + 858, + 859, + 860, + 861, + 862, + 863, + 864, + 865, + 866, + 2113, + 2109, + 2111, + 2106, + 2107, + 2108, + 0x558, + 2105, + 2110, + 2112, + 0x84F, + 0x850, + 1131, + 1130, + 1129, + 1128, + 1745, + 3544, + 3543, + 2836 + ) + val index: Int = RandomFunction.random(emotes.size) + player.animate(Animation(emotes[index])) + player.lock() + GameWorld.Pulser.submit(object : Pulse(1, player) { + var count = 0 + override fun pulse(): Boolean { + when (count) { + 1 -> ContentAPI.sendMessage(player, "You use your thieving skills to misdirect the eyes...") + 4 -> return if (RandomFunction.random(100) < ContentAPI.getStatLevel( + player, + Skills.THIEVING + ) + ) { + ContentAPI.sendMessage( + player, + colorize("%G...and sneak past while they're not looking.") + ) + player.properties.teleportLocation = locations[getIndex(`object`)] + player.unlock() + true + } else { + ContentAPI.sendMessage(player, colorize("%RYou fail to distract the eyes.")) + player.unlock() + true + } + } + count++ + return false + } + + override fun stop() { + super.stop() + player.animate(Animation(-1, Animator.Priority.HIGH)) + } + }) + } + }, + PASSAGE("go-through", arrayOf(Location.create(3040, 4844, 0)), 7154) { + override fun handle(player: Player, `object`: Scenery?) { + player.properties.teleportLocation = locations[0] + } + }; + /** + * Gets the option. + * @return The option. + */ + /** + * Gets the locations. + * @return The locations. + */ + /** + * Gets the objects. + * @return The objects. + */ + + /** + * Method used to get the index. + * @param object the object. + * @return the index. + */ + fun getIndex(`object`: Scenery): Int { + for (i in objects.indices) { + if (objects[i] == `object`.getId()) { + return i + } + } + return 0 + } + + /** + * Method used to handle the obstacle. + * @param player the player. + * @param object the object. + */ + open fun handle(player: Player, `object`: Scenery?) {} + + companion object { + /** + * Method used to get the abbysal obstacle. + * @param object the object. + * @return the `AbbysalObstacle` or `Null`. + */ + fun forObject(`object`: Scenery): AbbysalObstacle? { + for (obstacle in values()) { + for (i in obstacle.objects) { + if (i == `object`.getId()) { + return obstacle + } + } + } + return null + } + + /** + * Sets the tool used. + */ + private fun setTool(mining: Boolean, player: Player): SkillingTool? { + var tool: SkillingTool? = null + if (!mining) { + if (checkTool(player, SkillingTool.DRAGON_AXE)) { + tool = SkillingTool.DRAGON_AXE + } else if (checkTool(player, SkillingTool.RUNE_AXE)) { + tool = SkillingTool.RUNE_AXE + } else if (checkTool(player, SkillingTool.ADAMANT_AXE)) { + tool = SkillingTool.ADAMANT_AXE + } else if (checkTool(player, SkillingTool.MITHRIL_AXE)) { + tool = SkillingTool.MITHRIL_AXE + } else if (checkTool(player, SkillingTool.BLACK_AXE)) { + tool = SkillingTool.BLACK_AXE + } else if (checkTool(player, SkillingTool.STEEL_AXE)) { + tool = SkillingTool.STEEL_AXE + } else if (checkTool(player, SkillingTool.IRON_AXE)) { + tool = SkillingTool.IRON_AXE + } else if (checkTool(player, SkillingTool.BRONZE_AXE)) { + tool = SkillingTool.BRONZE_AXE + } + } else { + if (checkTool(player, SkillingTool.RUNE_PICKAXE)) { + tool = SkillingTool.RUNE_PICKAXE + } else if (checkTool(player, SkillingTool.ADAMANT_PICKAXE)) { + tool = SkillingTool.ADAMANT_PICKAXE + } else if (checkTool(player, SkillingTool.MITHRIL_PICKAXE)) { + tool = SkillingTool.MITHRIL_PICKAXE + } else if (checkTool(player, SkillingTool.STEEL_PICKAXE)) { + tool = SkillingTool.STEEL_PICKAXE + } else if (checkTool(player, SkillingTool.IRON_PICKAXE)) { + tool = SkillingTool.IRON_PICKAXE + } else if (checkTool(player, SkillingTool.BRONZE_PICKAXE)) { + tool = SkillingTool.BRONZE_PICKAXE + } + } + return tool + } + + /** + * Checks if the player has a tool and if he can use it. + * @param tool The tool. + * @return `True` if the tool is usable. + */ + private fun checkTool(player: Player, tool: SkillingTool): Boolean { + return if (player.equipment.contains(tool.getId(), 1)) { + true + } else player.inventory.contains(tool.getId(), 1) + } + } + + /** + * Constructs a new `RunecraftingOptionPlugin` `Object`. + * @param locations the locations. + * @param objects the objects. + */ + init { + option = option + } + } + + companion object { + /** + * Represents the teleporting to the abyss. + * @param player the player. + */ + fun teleport(player: Player, npc: NPC) { + player.lock(3) + npc.visualize(Animation(1979), Graphics(4)) + npc.sendChat("Veniens! Sallakar! Rinnesset!") + player.skills.decrementPrayerPoints(100.0) + player.skullManager.checkSkull(player) + GameWorld.Pulser.submit(object : Pulse(2, player) { + override fun pulse(): Boolean { + player.properties.teleportLocation = Location.create(3021, 4847, 0) + npc.updateMasks.reset() + return true + } + }) + } + } +} \ No newline at end of file From c9da5af1c30419d79aa57f6169218df545efd8fb Mon Sep 17 00:00:00 2001 From: philliam Date: Mon, 19 Jul 2021 13:05:22 -0400 Subject: [PATCH 6/6] whoopsie doopsie --- .../node/entity/skill/runecrafting/abyss/AbyssPlugin.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt index 34ac0cf1e..d3342ea4a 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/runecrafting/abyss/AbyssPlugin.kt @@ -26,8 +26,9 @@ import rs09.game.world.GameWorld */ class AbyssPlugin : InteractionListener() { - val OBSTACLE = AbbysalObstacle.values().filter { it != AbbysalObstacle.MINE }.map { it.option }.toTypedArray() + val OBSTACLE = AbbysalObstacle.values().filter { it != AbbysalObstacle.MINE && it != AbbysalObstacle.SQUEEZE }.map { it.option }.toTypedArray() val miningObstacle = 7158 + val agilityObstacle = 7164 override fun defineListeners() { definePlugin(AbyssalNPC()) @@ -56,6 +57,11 @@ class AbyssPlugin : InteractionListener() { obstacle!!.handle(player, node as Scenery) return@on true } + on(agilityObstacle, SCENERY, "squeeze-through"){ player, node -> + val obstacle = AbbysalObstacle.forObject(node as Scenery) + obstacle!!.handle(player, node as Scenery) + return@on true + } }