Repository reorganisation

Unified kotlin and java into just src/main
Unified the rs09 and core packages
Took all content out of the core package, and placed it into the new content package
Reorganised all source code relating to content to be easier to find and explore
This commit is contained in:
Ceikry
2023-01-26 13:59:28 +00:00
committed by Ryan
parent e4b799c44a
commit a100affda2
3156 changed files with 24205 additions and 30585 deletions
@@ -0,0 +1,629 @@
package content.global.bots
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.node.scenery.Scenery
import core.game.node.entity.combat.CombatStyle
import core.game.node.entity.skill.Skills
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.GameWorld
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.map.zone.ZoneBorders
import core.game.world.update.flag.*
import core.tools.RandomFunction
import org.json.simple.JSONArray
import org.json.simple.JSONObject
import core.ServerConstants
import core.game.bots.AIRepository
import core.game.bots.CombatBotAssembler
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import java.io.File
import java.io.FileReader
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.random.Random
/**
* A bot script for Adventurers who explore the world!
* @param counter used in the bots random idling function.
* @param random is used to generate random number.
* @param city determines the home city of the bot.
* @param freshspawn determines if the bot has just been spawned.
* @param random_city is the list of cities that can be randomly chosen as the home city.
* @param tree_list is the list of trees that a bot can start cutting randomly.
* @author Sir Kermit
* @author Ceikry
*/
//Adventure Bots v4.0.0 -Expansion Edition-
class Adventurer(val style: CombatStyle): Script() {
var city: Location = lumbridge
var ticks = 0
var freshspawn = true
var sold = false
private val geloc: Location = if (Random.nextBoolean()){
Location.create(3165, 3487, 0)
}else{
Location.create(3164, 3492, 0)
}
var counter: Int = 0
var random: Int = (5..30).random()
val type = when(style){
CombatStyle.MELEE -> CombatBotAssembler.Type.MELEE
CombatStyle.MAGIC -> CombatBotAssembler.Type.MAGE
CombatStyle.RANGE -> CombatBotAssembler.Type.RANGE
}
init {
skills[Skills.AGILITY] = 99
inventory.add(Item(1359))//Rune Axe
skills[Skills.WOODCUTTING] = 95
inventory.add(Item(590))//Tinderbox
skills[Skills.FISHING] = 90
inventory.add(Item(1271))//Addy Pickaxe
skills[Skills.MINING] = 90
skills[Skills.SLAYER] = 90
}
override fun toString(): String {
return "${bot.name} is an Adventurer bot at ${bot.location}! State: $state - City: $city"
}
private var state = State.START
fun getRandomCity(): Location{
return cities.random()
}
fun getRandomPoi(): Location{
return pois.random()
}
//TODO: Optimise and adjust how bots handle picking up ground items further.
fun immerse() {
if (counter++ == 180) {state = State.TELEPORTING
}
val items = AIRepository.groundItems[bot]
if (Random.nextBoolean()) {
if (items.isNullOrEmpty()) {
scriptAPI.attackNpcsInRadius(bot, 8)
state = State.LOOT_DELAY
}
if (bot.inventory.isFull) {
if(bankMap[city] == null){
scriptAPI.teleport(getRandomCity().also { city = it })
} else {
if(bankMap[city]?.insideBorder(bot) == true){
state = State.FIND_BANK
} else {
scriptAPI.walkTo(bankMap[city]?.randomLoc ?: Location(0, 0, 0))
}
}
}
} else {
if (bot.inventory.isFull){
if(bankMap[city] == null){
scriptAPI.teleport(getRandomCity().also { city = it })
} else {
if(bankMap[city]?.insideBorder(bot) == true){
state = State.FIND_BANK
} else {
scriptAPI.walkTo(bankMap[city]?.randomLoc ?: Location(0, 0, 0))
}
}
} else {
val resources = listOf(
"Rocks","Tree","Oak","Willow",
"Maple tree","Yew","Magic tree",
"Teak","Mahogany")
val resource = scriptAPI.getNearestNodeFromList(resources,true)
if(resource != null){
if(resource.name.contains("ocks")) InteractionListeners.run(resource.id,
IntType.SCENERY,"mine",bot,resource)
else InteractionListeners.run(resource.id, IntType.SCENERY,"chop down",bot,resource)
}
}
}
return
}
fun refresh() {
scriptAPI.teleport(lumbridge)
freshspawn = true
state = State.START
}
var poi = false
var poiloc = karamja
//Adventure Bots Actual Code STARTS HERE!!!
override fun tick() {
ticks++
if (ticks++ >= 800) {
ticks = 0
refresh()
return
}
// zoneborder checker
if(ticks % 30 == 0){
for((zone, resolution) in common_stuck_locations){
if(zone.insideBorder(bot)){
resolution(this)
return
}
}
}
when(state){
State.LOOT_DELAY -> {
bot.pulseManager.run(object : Pulse() {
var counter1 = 0
override fun pulse(): Boolean {
when (counter1++) {
7 -> return true.also { state = State.LOOT }
}
return false
}
})
}
State.LOOT -> {
val items = AIRepository.groundItems[bot]
if (items?.isNotEmpty() == true && !bot.inventory.isFull) {
items.toTypedArray().forEach {
scriptAPI.takeNearestGroundItem(it.id)
}
return
} else {
state = State.EXPLORE
}
}
State.START -> {
if (freshspawn) {
freshspawn = false
scriptAPI.randomWalkTo(lumbridge, 20)
} else {
city = getRandomCity()
state = State.TELEPORTING
}
}
State.TELEPORTING -> {
ticks = 0
counter = 0
if (bot.location != city) {
poi = false
scriptAPI.teleport(city)
} else {
poi = false
state = State.EXPLORE
}
}
State.EXPLORE -> {
if (counter++ == 350) {
state = State.TELEPORTING
}
val chance = if (city == ge || city == ge2) 5000 else 2500
if (RandomFunction.random(chance) <= 10) {
val nearbyPlayers = RegionManager.getLocalPlayers(bot)
if (nearbyPlayers.isNotEmpty()) {
ticks = 0
dialogue()
}
}
if (RandomFunction.random(1000) <= 150 && !poi) {
val roamDistance = if (city != ge && city != ge2) 225 else 7
if ((city == ge || city == ge2) && RandomFunction.random(100) < 90) {
if (!bot.bank.isEmpty) {
state = State.FIND_GE
}
return
}
scriptAPI.randomWalkTo(city, roamDistance)
return
}
if (RandomFunction.random(1000) <= 50 && poi){
val roamDistancePoi = when(poiloc){
teakfarm, crawlinghands -> 5
treegnome -> 50
isafdar -> 40
eaglespeek -> 40
keldagrimout -> 30
teak1 -> 30
miningguild -> 5
magics, coal -> 7
gemrocks, chaosnpc, chaosnpc2 -> 1
else -> 60
}
scriptAPI.randomWalkTo(poiloc,roamDistancePoi)
return
}
if (RandomFunction.random(1000) <= 75) {
if (city != ge && city != ge2) {
immerse()
return
} else {
return
}
}
if (RandomFunction.random(20000) <= 60 && !poi) {
poiloc = getRandomPoi()
city = teak1
poi = true
scriptAPI.teleport(poiloc)
return
}
if ((city == ge || city == ge2) && RandomFunction.random(1000) >= 999) {
ticks = 0
city = getRandomCity()
state = State.TELEPORTING
}
if (city == ge || city == ge2) {
return
}
if (city == teak1 && counter++ >= 240){
city = getRandomCity()
state = State.TELEPORTING
}
if (counter++ >= 240 && RandomFunction.random(100) >= 10) {
city = getRandomCity()
if (RandomFunction.random(100) % 2 == 0) {
counter = 0
ticks = 0
state = State.TELEPORTING
} else {
if (citygroupA.contains(city)) {
city = citygroupA.random()
} else {
city = citygroupB.random()
}
counter = 0
ticks = 0
state = State.FIND_CITY
}
counter = 0
return
}
return
}
State.GE -> {
var ge = false
if (counter++ == 180) {
state = State.TELEPORTING
}
if (!sold) {
if (counter++ >= 15) {
sold = true
ge = true
counter = 0
ticks = 0
scriptAPI.sellAllOnGeAdv()
return
}
} else if (ge && sold) {
ge = false
city = getRandomCity()
state = State.TELEPORTING
}
return
}
State.FIND_GE -> {
if (counter++ == 180) {
state = State.TELEPORTING
}
sold = false
val ge: Scenery? = scriptAPI.getNearestNode("Desk", true) as Scenery?
if (ge == null || bot.bank.isEmpty) state = State.EXPLORE
class GEPulse : MovementPulse(bot, ge, DestinationFlag.OBJECT) {
override fun pulse(): Boolean {
bot.faceLocation(ge?.location)
state = State.GE
return true
}
}
if (ge != null && !bot.bank.isEmpty) {
counter = 0
scriptAPI.randomWalkTo(geloc, 3)
GameWorld.Pulser.submit(GEPulse())
}
return
}
State.FIND_BANK -> {
if (counter++ == 300) {
state = State.TELEPORTING
}
val bank: Scenery? = scriptAPI.getNearestNode("Bank booth", true) as Scenery?
if (badedge.insideBorder(bot) || bot.location == badedge2 || bot.location == badedge3 || bot.location == badedge4) {
bot.randomWalk(5, 5)
}
if (bank == null) state = State.EXPLORE
class BankingPulse : MovementPulse(bot, bank, DestinationFlag.OBJECT) {
override fun pulse(): Boolean {
bot.faceLocation(bank?.location)
state = State.IDLE_BANKS
return true
}
}
if (bank != null) {
bot.pulseManager.run(BankingPulse())
}
return
}
State.IDLE_BANKS -> {
if (counter++ == 300) {
state = State.TELEPORTING
}
if (RandomFunction.random(1000) < 100) {
for (item in bot.inventory.toArray()) {
item ?: continue
when (item.id) {
1359, 590, 1271, 995 -> continue
}
bot.bank.add(item)
bot.inventory.remove(item)
}
counter = 0
state = State.EXPLORE
}
return
}
State.FIND_CITY -> {
if (counter++ >= 600 || (city == ge || city == ge2)) {
counter = 0
scriptAPI.teleport(getRandomCity().also { city = it })
state = State.EXPLORE
}
if (bot.location.equals(city)) {
state = State.EXPLORE
} else {
scriptAPI.randomWalkTo(city, 5)
}
return
}
State.IDLE_CITY -> {
if (counter++ == 300) {
state = State.TELEPORTING
}
var random = (120..300).random()
if (counter++ == random && RandomFunction.random(1000) % 33 == 0) {
counter = 0
state = State.EXPLORE
}
return
}
}
}
fun dialogue() {
val localPlayer = RegionManager.getLocalPlayers(bot).random()
val until = 1225 - dateCode
val lineStd = dialogue.getLines("standard").rand()
var lineAlt = ""
when {
//Celebrates Halloween!
dateCode == 1031 -> lineAlt = dialogue.getLines("halloween").rand()
//Celebrates lead up to Christmas!
until in 2..23 -> lineAlt = dialogue.getLines("approaching_christmas").rand()
//Celebrates Christmas Day!
dateCode == 1225 -> lineAlt = dialogue.getLines("christmas_day").rand()
//Celebrates Christmas Eve
dateCode == 1224 -> lineAlt = dialogue.getLines("christmas_eve").rand()
//New years eve
dateCode == 1231 -> lineAlt = dialogue.getLines("new_years_eve").rand()
//New years
dateCode == 101 -> lineAlt = dialogue.getLines("new_years").rand()
//Valentines
dateCode == 214 -> lineAlt = dialogue.getLines("valentines").rand()
//Easter
dateCode == 404 -> lineAlt = dialogue.getLines("easter").rand()
}
val chat = if (lineAlt.isNotEmpty() && Random.nextBoolean()) { lineAlt } else { lineStd }
.replace("@name", localPlayer.username)
.replace("@timer", until.toString())
scriptAPI.sendChat(chat)
}
enum class State{
START,
EXPLORE,
FIND_BANK,
IDLE_BANKS,
FIND_CITY,
IDLE_CITY,
GE,
TELEPORTING,
LOOT,
LOOT_DELAY,
FIND_GE
}
override fun newInstance(): Script {
val script = Adventurer(style)
script.state = State.START
val tier = CombatBotAssembler.Tier.MED
if (type == CombatBotAssembler.Type.RANGE)
script.bot = CombatBotAssembler().RangeAdventurer(tier, bot.startLocation)
else
script.bot = CombatBotAssembler().MeleeAdventurer(tier, bot.startLocation)
return script
}
companion object {
val badedge = ZoneBorders(3094, 3494, 3096, 3497)
val badedge2 = Location.create(3094, 3492, 0)
val badedge3 = Location.create(3094, 3490, 0)
val badedge4 = Location.create(3094, 3494, 0)
val yanille: Location = Location.create(2615, 3104, 0)
val ardougne: Location = Location.create(2662, 3304, 0)
val seers: Location = Location.create(2726, 3485, 0)
val edgeville: Location = Location.create(3088, 3486, 0)
val ge: Location = Location.create(3168, 3487, 0)
val ge2: Location = Location.create(3161, 3493, 0)
val catherby: Location = Location.create(2809, 3435, 0)
val falador: Location = Location.create(2965, 3380, 0)
val varrock: Location = Location.create(3213, 3428, 0)
val draynor: Location = Location.create(3080, 3250, 0)
val rimmington: Location = Location.create(2977, 3239, 0)
val lumbridge: Location = Location.create(3222, 3219, 0)
val karamja = Location.create(2849, 3033, 0)
val alkharid = Location.create(3297, 3219, 0)
val feldiphills = Location.create(2535, 2919, 0)
val isafdar = Location.create(2241, 3217, 0)
val eaglespeek = Location.create(2333, 3579, 0)
val canafis = Location.create(3492, 3485, 0)
val treegnome = Location.create(2437, 3441, 0)
val teak1 = Location.create(2334, 3048, 0)
val teakfarm = Location.create(2825, 3085, 0)
val keldagrimout = Location.create(2724,3692,0)
val miningguild = Location.create(3046,9740,0)
val magics = Location.create(2285,3146,0)
val coal = Location.create(2581,3481,0)
val crawlinghands = Location.create(3422,3548,0)
val gemrocks = Location.create(2825,2997,0)
val chaosnpc = Location.create(2612,9484,0)
val chaosnpc2 = Location.create(2580,9501,0)
val taverly = Location.create(2909, 3436, 0)
var citygroupA = listOf(falador, varrock, draynor, rimmington, lumbridge, edgeville)
var citygroupB = listOf(yanille, ardougne, seers, catherby)
var bankMap = mapOf<Location, ZoneBorders>(
falador to ZoneBorders(2950, 3374, 2943, 3368),
varrock to ZoneBorders(3182, 3435, 3189, 3446),
draynor to ZoneBorders(3092, 3240, 3095, 3246),
edgeville to ZoneBorders(3093, 3498, 3092, 3489),
yanille to ZoneBorders(2610, 3089, 2613, 3095),
ardougne to ZoneBorders(2649, 3281, 2655, 3286),
seers to ZoneBorders(2729, 3493, 2722, 3490),
catherby to ZoneBorders(2807, 3438, 2811, 3441)
)
val cities = listOf(yanille, ardougne, seers, catherby, falador, varrock,
draynor, rimmington, lumbridge, ge, ge2, edgeville)
val pois = listOf(
karamja, karamja, alkharid,
alkharid, feldiphills, feldiphills,
isafdar, eaglespeek, eaglespeek,
canafis, treegnome, treegnome,
teak1, teakfarm, keldagrimout,
miningguild, coal, crawlinghands,
magics, gemrocks, chaosnpc, chaosnpc,
chaosnpc2, taverly)
private val whiteWolfMountainTop = Location(2850, 3496, 0)
private val catherbyToTopOfWhiteWolf = arrayOf(Location(2856, 3442, 0), Location(2848, 3455, 0), Location(2848, 3471, 0), Location(2848, 3487, 0))
private val tavleryToTopOfWhiteWolf = arrayOf(Location(2872, 3425, 0), Location(2863, 3440, 0), Location(2863, 3459, 0), Location(2854, 3475, 0), Location(2859, 3488, 0))
val common_stuck_locations = mapOf(
// South of Tavlery dungeon
ZoneBorders(2878, 3386, 2884, 3395) to { it: Adventurer ->
it.scriptAPI.walkArray(tavleryToTopOfWhiteWolf + whiteWolfMountainTop + catherbyToTopOfWhiteWolf.reversedArray())
},
// West of Tavlery dungeon
ZoneBorders(2874, 3390, 2880, 3401) to { it: Adventurer ->
it.scriptAPI.walkArray(tavleryToTopOfWhiteWolf + whiteWolfMountainTop + catherbyToTopOfWhiteWolf.reversedArray())
},
// South of White Wolf Mountain in Tavlery
ZoneBorders(2865,3408,2874,3423) to { it: Adventurer ->
it.scriptAPI.walkArray(tavleryToTopOfWhiteWolf + whiteWolfMountainTop + catherbyToTopOfWhiteWolf.reversedArray())
},
// On beginning of White Wolf Mountain in Tavlery
ZoneBorders(2855, 3454, 2852, 3450) to { it: Adventurer ->
it.scriptAPI.walkArray(tavleryToTopOfWhiteWolf + whiteWolfMountainTop + catherbyToTopOfWhiteWolf.reversedArray())
},
// South of White Wolf Mountain in Catherby
ZoneBorders(2861,3425,2867, 3432) to { it: Adventurer ->
it.scriptAPI.walkArray(catherbyToTopOfWhiteWolf + whiteWolfMountainTop + tavleryToTopOfWhiteWolf.reversedArray())
},
// On beginning of White Wolf Mountain in Catherby
ZoneBorders(2863, 3441, 2859, 3438) to { it: Adventurer ->
it.scriptAPI.walkArray(catherbyToTopOfWhiteWolf + whiteWolfMountainTop + tavleryToTopOfWhiteWolf.reversedArray())
},
// At the Crumbling Wall in Falador
ZoneBorders(2937,3356,2936,3353) to { it: Adventurer ->
// Interact with the Crumbling Wall
val wall = it.scriptAPI.getNearestNode("Crumbling wall", true);
if (wall == null) {
it.refresh()
it.ticks = 0
return@to
}
it.scriptAPI.interact(it.bot, wall, "Climb-over")
},
// Northwest corner of Draynor Bank
ZoneBorders(3092, 3246, 3091, 3247) to { it: Adventurer ->
// Walk into Draynor Bank
it.scriptAPI.walkTo(Location(3093, 3243, 0))
},
// West of GE, stuck in the corner south of the outlaw place
ZoneBorders(3140, 3468, 3140, 3468) to { it: Adventurer ->
// Walk to Barbarian village
it.scriptAPI.walkArray(arrayOf(Location.create(3135, 3516, 0), Location.create(3103, 3489, 0), Location.create(3082, 3423, 0)))
},
)
val dialogue: JSONObject
val dateCode: Int
init {
val reader = FileReader(ServerConstants.BOT_DATA_PATH + File.separator + "bot_dialogue.json")
val parser = org.json.simple.parser.JSONParser()
val data = parser.parse(reader) as JSONObject
dialogue = data
val formatter = DateTimeFormatter.ofPattern("MMdd")
val current = LocalDateTime.now()
val formatted: String = current.format(formatter)
dateCode = formatted.toInt()
}
private fun JSONObject.getLines(category: String): JSONArray {
return this[category] as JSONArray
}
private fun JSONArray.rand(): String {
return this.random() as String
}
}
}
@@ -0,0 +1,113 @@
package content.global.bots
import core.game.bots.*
import core.game.node.item.Item
import core.game.world.map.Location
import core.game.world.map.zone.ZoneBorders
import org.rs09.consts.Items
@PlayerCompatible
@ScriptName("Chicken Killer")
@ScriptDescription("Kills chickens and loots feathers. Start in any chicken area.")
@ScriptIdentifier("chicken_killer")
class ChickenKiller : Script(){
var state = State.INIT
var chickenCounter = 0
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()
overlay!!.setTitle("Chickens")
overlay!!.setTaskLabel("Chickens KO'd:")
overlay!!.setAmount(0)
state = State.CONFIG
bot.dialogueInterpreter.sendOptions("Loot Feathers and bury bones?","Yes","No")
bot.dialogueInterpreter.addAction{player,button ->
lootFeathers = button == 2
state = State.KILLING
}
startLocation = bot.location
}
State.KILLING -> {
val chicken = scriptAPI.getNearestNode("Chicken")
if(chicken == null){
scriptAPI.randomWalkTo(startLocation,3)
} else {
scriptAPI.attackNpcInRadius(bot,"Chicken",10)
if(lootFeathers) {
state = State.IDLE
timer = 4
}
chickenCounter++
overlay!!.setAmount(chickenCounter)
}
}
State.IDLE -> {
if(timer-- <= 0){
featherNearby = scriptAPI.takeNearestGroundItem(Items.FEATHER_314)
currentFeathers = 0
if (featherNearby) {
state = State.LOOTFEATHER
}else{
state = State.LOOTBONES
}
}
}
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
}
}
}
override fun newInstance(): Script {
return this
}
enum class State {
IDLE,
INIT,
KILLING,
LOOTING,
RETURN,
CONFIG,
LOOTFEATHER,
LOOTBONES,
BURYBONES
}
}
@@ -0,0 +1,160 @@
package content.global.bots
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 core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import core.api.*
import core.game.bots.*
@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, IntType.SCENERY,"mine",bot,rock) }
}
overlay!!.setAmount(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)
}
}
@@ -0,0 +1,155 @@
package content.global.bots
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.map.zone.ZoneBorders
import org.rs09.consts.Items
import core.game.bots.CombatBotAssembler
import core.game.bots.Script
class CowKiller : Script() {
var state = State.KILLING
var spawnZone = ZoneBorders(3254,3255,3264,3281)
var cowZone = ZoneBorders(3242, 3254,3265, 3296)
val bankZone = ZoneBorders(3208, 3217,3210, 3220)
init {
cowZone.addException(ZoneBorders(3242,3254,3252,3277))
cowZone.addException(ZoneBorders(3242,3277,3242,3296))
cowZone.addException(ZoneBorders(3253, 3267,3253, 3267))
}
override fun tick() {
when(state){
State.KILLING -> {
scriptAPI.attackNpcInRadius(bot,"Cow",10)
state = State.LOOTING
}
State.LOOTING -> {
bot.pulseManager.run(object: Pulse(4){
override fun pulse(): Boolean {
state = State.KILLING
scriptAPI.takeNearestGroundItem(Items.COWHIDE_1739)
state = if(bot.inventory.getAmount(Items.COWHIDE_1739) > 22){
State.TO_BANK
} else {
State.KILLING
}
return true
}
})
}
State.TO_BANK -> {
if(cowZone.insideBorder(bot))
scriptAPI.walkTo(Location.create(3253, 3267, 0))
else{
val closedGate = scriptAPI.getNearestNode(15516,true)
if(closedGate != null && closedGate.location.withinDistance(bot.location,2)){
closedGate.interaction.handle(bot,closedGate.interaction[0])
} else {
when (bot.location) {
Location.create(3212, 3227, 0) -> {
val stairs = scriptAPI.getNearestGameObject(bot.location, 36776)
stairs?.interaction?.handle(bot, stairs.interaction[0])
}
Location.create(3206, 3229, 1) -> {
val stairs = scriptAPI.getNearestNode(36777, true)
stairs?.interaction?.handle(bot, stairs.interaction[1])
}
Location.create(3206, 3229, 2) -> {
scriptAPI.walkTo(bankZone.randomLoc)
state = State.BANKING
}
else -> scriptAPI.walkTo(Location.create(3212, 3227, 0))
}
}
}
}
State.BANKING -> {
if(bankZone.insideBorder(bot)) {
val bank = scriptAPI.getNearestNode(36786, true)
bot.pulseManager.run(object : MovementPulse(bot, bank, DestinationFlag.OBJECT) {
override fun pulse(): Boolean {
scriptAPI.bankItem(Items.COWHIDE_1739)
if (bot.bank.getAmount(Items.COWHIDE_1739) > 75) {
scriptAPI.teleportToGE()
state = State.TELE_GE
} else {
state = State.BACK_TO_COWS
}
return true
}
})
}
}
State.BACK_TO_COWS -> {
if (bankZone.insideBorder(bot))
scriptAPI.walkTo(Location.create(3206, 3229, 2))
else {
when (bot.location) {
Location.create(3206, 3229, 2) -> {
val stairs = scriptAPI.getNearestNode(36778, true)
stairs?.interaction?.handle(bot, stairs.interaction[0])
}
Location.create(3206, 3229, 1) -> {
val stairs = scriptAPI.getNearestNode(36777, true)
stairs?.interaction?.handle(bot, stairs.interaction[2])
}
Location.create(3252, 3267, 0) -> {
val closedGate = scriptAPI.getNearestNode(15516, true)
if (closedGate != null && closedGate.location.withinDistance(bot.location, 2)) {
closedGate.interaction.handle(bot, closedGate.interaction[0])
} else {
scriptAPI.walkTo(cowZone.randomLoc)
state = State.KILLING
}
}
else -> scriptAPI.walkTo(Location.create(3252, 3267, 0))
}
}
}
State.TELE_GE -> {
if(bot.location == Location.create(3165, 3482, 0))
state = State.SELL_GE
else
scriptAPI.walkTo(Location.create(3165, 3482, 0))
}
State.SELL_GE -> {
state = State.TELE_LUM
scriptAPI.sellOnGE(Items.COWHIDE_1739)
}
State.TELE_LUM -> {
state = State.BACK_TO_COWS
scriptAPI.teleport(Location.create(3222, 3218, 0))
}
}
}
enum class State {
KILLING,
LOOTING,
BANKING,
TO_BANK,
BACK_TO_COWS,
SELL_GE,
TELE_GE,
TELE_LUM
}
override fun newInstance(): Script {
val script = CowKiller()
script.bot = CombatBotAssembler().produce(CombatBotAssembler.Type.values().random(), CombatBotAssembler.Tier.LOW,spawnZone.randomLoc)
script.state = State.KILLING
return script
}
}
@@ -0,0 +1,377 @@
package content.global.bots
import core.game.container.Container
import core.game.interaction.Option._P_TRADE
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.request.trade.TradeModule
import core.game.node.entity.skill.Skills
import core.game.node.item.Item
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.update.flag.context.ChatMessage
import core.game.world.update.flag.player.ChatFlag
import core.integrations.discord.Discord
import org.json.simple.JSONArray
import org.json.simple.JSONObject
import org.json.simple.parser.JSONParser
import org.rs09.consts.Items
import core.ServerConstants
import core.game.bots.AIRepository
import content.global.bots.Adventurer.Companion.lumbridge
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import core.game.world.ImmerseWorld
import java.io.File
import java.io.FileReader
import java.util.Random
import kotlin.math.min
/**
* A bot that doubles money
* 30% chance to double money, 70% chance to scam
* @author dginovker
*/
class DoublingMoney : Script() {
/**
* If we're in ScamMode, we will never trade away any more coins
*/
private var scamMode = false
/**
* Whether the bot has run its setup (gotten appearance made/etc.)
*/
private var setup = false
/**
* Player who most recently traded with this bot
*/
var victim: Player? = null
/**
* Player who the bot took money from
*/
private var playerOwed: Player? = null
/**
* Whether we sent a trade request to the player we owe yet
*/
private var sentTradeRequest = false
/**
* Amount the bot owes the player (2x the amount the player gave the bot)
*/
private var debtOwed: Int = 0
/**
* How many ticks the bot has run for
*/
var ticks = 0
/**
* Duration for how long the bot will take a nap
*/
private var sleepTime = 0
/**
* Debug information about what state the bot is in
*/
private var stateString = "init"
/**
* How long the bot will stay around for
*/
private val maxTicks = (400..750).random()
enum class Effort {
LOW,
HIGH,
VERY_HIGH
}
/**
* Characteristics about how hard the bot will work
* Most likely to be LOW, small chance to be HIGH, very small chance to be VERY_HIGH
*/
private val effort = when (Random().nextInt(100)) {
in 0..90 -> Effort.LOW
in 90..98 -> Effort.HIGH
else -> Effort.VERY_HIGH
}
// Priority calculation -> Execute method mapping. Priority calculation with the highest return value is executed
var states = mapOf(
fun(): Int {
if (setup) return -1
return 250
} to {
stateString = "Putting on my outfit.."
var appearance = if (Math.random() < 0.5) "noob" else "intermediate"
if (effort == Effort.VERY_HIGH && Math.random() < 0.5) appearance = "veteran"
val appearancesArray = botAppearances[appearance] as JSONArray
scriptAPI.loadAppearanceAndEquipment(appearancesArray.random() as JSONObject)
setup = true
},
fun(): Int {
val botTradeModule = TradeModule.getExtension(bot)
if (botTradeModule != null) return -1
return 0
} to {
stateString = "Doing nothing"
},
fun(): Int {
return 1
} to {
stateString = "Saying Doubling money"
when (effort) {
Effort.LOW -> {
scriptAPI.sendChat("Doubling money")
sleepTime = 7
}
Effort.HIGH -> {
val message = arrayOf("Doubling Money", "Doubling Money", "Doubling Money!", "Doubling moneyy").random()
val messageEffect = arrayOf(0, 256).random()
val ctx = ChatMessage(bot, message, messageEffect, message.length)
bot.updateMasks.register(ChatFlag(ctx))
sleepTime = 8
}
Effort.VERY_HIGH -> {
val message = arrayOf("Doubling money!", "Doubling money").random()
val messageEffect = arrayOf(771, 2818, 2562, 768, 512, 2304, 2560, 769, 1792).random()
val ctx = ChatMessage(bot, message, messageEffect, message.length)
bot.updateMasks.register(ChatFlag(ctx))
sleepTime = 9
}
}
},
fun(): Int {
if (victim == null) return -1
return 10
} to {
stateString = "Accepting trade request"
// Send trade request back to victim
InteractionListeners.run(-1, IntType.PLAYER, "trade with", bot, victim!!)
victim = null
sleepTime = 3
},
fun(): Int {
if (debtOwed >= 0) return -1
val botTradeModule = TradeModule.getExtension(bot) ?: return -1
val playerTradeModule = TradeModule.getExtension(botTradeModule.target) ?: return -1
if (!playerTradeModule.container!!.containsAtLeastOneItem(Items.COINS_995)) return 15
return -1
} to {
val botTradeModule = TradeModule.getExtension(bot)
stateString = "Waiting for ${botTradeModule!!.target} to post money"
sleepTime = 5
},
fun(): Int {
// If we have debt and are in the trade screen with the player who we owe, but have not put up coins, put up coins
if (debtOwed == 0) return -1
val botTradeModule = TradeModule.getExtension(bot) ?: return -1
if (botTradeModule.target != playerOwed) return -1
if (!botTradeModule.container!!.containsAtLeastOneItem(Items.COINS_995)) return 150
return -1
} to {
stateString = "Paying off ${playerOwed!!.username} $debtOwed coins"
val botTradeModule = TradeModule.getExtension(bot)
val coinSlot = bot.inventory.getSlot(Item(Items.COINS_995))
botTradeModule!!.container!!.offer(coinSlot, debtOwed)
debtOwed = 0
playerOwed = null
},
fun(): Int {
val botTradeModule = TradeModule.getExtension(bot) ?: return -1
val playerTradeModule = TradeModule.getExtension(botTradeModule.target) ?: return -1
if (botTradeModule.container!!.containsAtLeastOneItem(Items.COINS_995)) return 200
if (playerTradeModule.container!!.containsAtLeastOneItem(Items.COINS_995)) return 200
return -1
} to {
stateString = "Accepting any trade screen that has coins put up"
val botTradeModule = TradeModule.getExtension(bot)
val playerTradeModule = TradeModule.getExtension(botTradeModule!!.target)
if (botTradeModule.isAccepted) return@to
sleepTime = (1..if (botTradeModule.getInterface() == TradeModule.MAIN_INTERFACE) 2 else 5).random()
val coinsFromBot = botTradeModule.container!!.getAmount(Items.COINS_995)
if (botTradeModule.getInterface() == TradeModule.ACCEPT_INTERFACE && coinsFromBot > 0 && effort == Effort.VERY_HIGH) {
val message = "Payed ${(if (coinsFromBot < 1000) "${coinsFromBot}gp" else "${coinsFromBot / 1000}k")}"
val ctx = ChatMessage(bot, message, 512, message.length)
bot.updateMasks.register(ChatFlag(ctx))
sleepTime = 7
}
if (botTradeModule.getInterface() == TradeModule.ACCEPT_INTERFACE && Math.random() < 0.2 && effort == Effort.HIGH && coinsFromBot > 0) {
scriptAPI.sendChat("Enjoy")
sleepTime += 4
}
if (botTradeModule.getInterface() == TradeModule.MAIN_INTERFACE && scamMode) {
sleepTime = maxOf(3, sleepTime)
}
if (botTradeModule.getInterface() == TradeModule.ACCEPT_INTERFACE) {
val player = botTradeModule.target
var playerNetPoL = player!!.getAttribute("double-money-net-pol", "0").toInt()
playerNetPoL += coinsFromBot
playerNetPoL -= playerTradeModule!!.container!!.getAmount(Items.COINS_995)
player.setAttribute("double-money-net-pol", playerNetPoL.toString())
// if playerNetPoL > 100k, send a Discord notification
if (playerNetPoL > 100_000) {
Discord.postPlayerAlert(player.username, "Made too much off Doubling Money bots: ${playerNetPoL / 1000}k")
}
}
// If we're in scamMode, we cannot actually setAccepted to true if we're giving away coins! (Gotta fake em out ;)
if (scamMode && botTradeModule.getInterface() == TradeModule.ACCEPT_INTERFACE && coinsFromBot > 0) {
botTradeModule.decline()
} else {
botTradeModule.setAccepted(true, update = true)
}
sentTradeRequest = false
},
fun(): Int {
if (sentTradeRequest) return 50
return -1
} to {
// Wait for the other player to accept
},
fun(): Int {
if (TradeModule.getExtension(bot) == null && debtOwed > 0 && playerOwed != null) return 25
return -1
} to {
// Scam over 200k payout or 70% chance
if (Math.random() < 0.7 || debtOwed > 200_000) {
stateString = "Scamming"
scamMode = true
if (effort != Effort.VERY_HIGH || Math.random() < 0.5) {
// At high scam effort, there's a chance we fake giving them coins back to keep milking
// with scamMode = true, we will never accept giving coins away at the second trade screen again
terminate()
}
}
stateString = "Sending trade request to ${playerOwed!!.name} to give them $debtOwed coins"
playerOwed!!.interaction.handle(bot, _P_TRADE)
InteractionListeners.run(-1, IntType.PLAYER, "trade with", bot, playerOwed!!)
sentTradeRequest = true
},
fun(): Int {
// If we're not near a doubling loc, or another doubling bot is on our loc, walk to random one
var minDist = 1000.0
for (loc in doublingLocs) {
minDist = min(minDist, loc.getDistance(bot.location))
}
if (minDist > 1) return 2
RegionManager.forId(bot.location.regionId).planes[bot.location.z].players.forEach {
if (AIRepository.PulseRepository[it?.username?.lowercase()]?.botScript is DoublingMoney
&& it != bot
&& it.location.getDistance(bot.location) <= 1) {
return 2
}
}
return -1
} to {
stateString = "Walking to doubling location"
val loc = doublingLocs.random()
scriptAPI.walkTo(loc)
sleepTime = 5
},
fun(): Int {
// If we're past the max ticks, log out
if (ticks > maxTicks) return 30
return -1
} to {
stateString = "Logging out"
terminate()
},
fun(): Int {
// If we're past 1,000 ticks, force terminate
if (ticks > 1000) return 1_000_000
return -1
} to {
stateString = "Force terminating"
terminate()
}
)
override fun toString(): String {
return "stateString: $stateString, sleepTime: $sleepTime, ticks: $ticks, maxTicks: $maxTicks, debtOwed: $debtOwed, playerOwed: $playerOwed, victim: $victim, effort: $effort, scamMode: $scamMode"
}
override fun tick() {
if(!bot.isActive){
running = false
return
}
ticks ++
if (sleepTime > 0) {
sleepTime --
return
}
// Execute the priority calculations, then execute the method of the one which returned highest
states.maxByOrNull { it.key() }?.value?.invoke()
}
fun tradeReceived(p: Player) {
victim = p
}
fun itemsReceived(p: Player, container: Container?) {
if (container == null) return
val coins: Item = container.get(Item(Items.COINS_995)) ?: return
playerOwed = p
debtOwed = coins.amount * 2
if (effort == Effort.VERY_HIGH) {
val message = "Received ${(if (coins.amount < 1000) "${coins.amount}gp" else "${coins.amount / 1000}k")}"
val ctx = ChatMessage(bot, message, 256, message.length)
bot.updateMasks.register(ChatFlag(ctx))
}
}
fun terminate() {
scriptAPI.teleport(lumbridge)
debtOwed = 0
bot.isActive = false
sleepTime = 500
AIRepository.PulseRepository.remove(bot.username.lowercase())
ImmerseWorld.spawnDoubleMoneyBot(true)
}
override fun newInstance(): Script? {
// this straight doesn't get called....
return null
}
init {
skills[Skills.AGILITY] = 99
inventory.add(Item(Items.COINS_995, 1_000_000))
}
companion object {
val startingLocs = arrayOf(Location.create(3184, 3488, 0),
Location.create(3167, 3461, 0),
Location.create(3170, 3444, 0),
Location.create(3165, 3487, 0),
Location.create(3167, 3489, 0),
Location.create(3162, 3491, 0))
val doublingLocs = arrayOf(Location.create(3159, 3492, 0),
Location.create(3164, 3484, 0),
Location.create(3169, 3486, 0),
Location.create(3172, 3489, 0),
Location.create(3168, 3483, 0),
Location.create(3166, 3493, 0),
Location.create(3157, 3498, 0),
Location.create(3157, 3485, 0)
)
// load from data/botdata/ge_bot_appearances_and_equipment.json
private val jsonFilePath = "${ServerConstants.BOT_DATA_PATH}/ge_bot_appearances_and_equipment.json"
private val jsonFile = File(jsonFilePath)
private val parser = JSONParser()
val botAppearances = parser.parse(FileReader(jsonFile)) as JSONObject
}
}
@@ -0,0 +1,67 @@
package content.global.bots
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
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 core.game.bots.SkillingBotAssembler
import core.game.bots.Script
class DraynorFisher : Script() {
val fishingZone = ZoneBorders(3085, 3223,3089, 3233)
val bankZone = ZoneBorders(3092, 3240,3094, 3246)
var state = State.FISHING
override fun tick() {
when(state){
State.FISHING -> {
if(!fishingZone.insideBorder(bot))
scriptAPI.walkTo(fishingZone.randomLoc)
else {
val spot = scriptAPI.getNearestNode(316,false)
spot?.interaction?.handle(bot,spot.interaction[0]) ?: scriptAPI.walkTo(fishingZone.randomLoc)
if(bot.inventory.getMaximumAdd(Item(4151)) < 5)
state = State.BANKING
}
}
State.BANKING -> {
if(!bankZone.insideBorder(bot))
scriptAPI.walkTo(bankZone.randomLoc)
else {
val bank = scriptAPI.getNearestNode("Bank booth")
if (bank != null){
bot.pulseManager.run(object : MovementPulse(bot,bank, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
bot.inventory.clear()
state = State.FISHING
bot.inventory.add(Item(Items.SMALL_FISHING_NET_303))
return true
}
})
}
}
}
}
}
override fun newInstance(): Script {
val script = DraynorFisher()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR, Location.create(3094, 3242, 0))
return script
}
init {
inventory.add(Item(Items.SMALL_FISHING_NET_303))
}
enum class State {
FISHING,
BANKING
}
}
@@ -0,0 +1,92 @@
package content.global.bots
import core.game.bots.*
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 core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import core.tools.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, 3245,3092, 3242)
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,
IntType.SCENERY,"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
}
}
@@ -0,0 +1,72 @@
package content.global.bots
import core.game.world.map.zone.ZoneBorders
import core.game.bots.SkillingBotAssembler
import core.game.node.entity.skill.Skills
import core.game.node.item.Item
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
class FarmerThiever : Script() {
val pickpocketZone = ZoneBorders(3074,3245,3086,3255)
val bankZone = ZoneBorders(3092, 3245,3092, 3242)
val food = Items.JUG_OF_WINE_1993
val foodAmount = 10
var state = State.PICKPOCKETING
override fun tick() {
when(state) {
State.PICKPOCKETING -> {
if (!pickpocketZone.insideBorder(bot))
scriptAPI.walkTo(pickpocketZone.randomLoc)
if (bot.inventory.isFull)
state = State.BANKING
else {
val farmer = scriptAPI.getNearestNode(NPCs.MASTER_FARMER_2234, false)
bot.interfaceManager.close()
scriptAPI.eat(food)
if (farmer != null) {
InteractionListeners.run(farmer.id, IntType.NPC, "Pickpocket", bot, farmer)
}
}
}
State.BANKING -> {
val bank = scriptAPI.getNearestNode("Bank Booth",true)
bank ?: return
if (!bankZone.insideBorder(bot))
scriptAPI.walkTo(bankZone.randomLoc)
else {
bot.faceLocation(bank.location)
bot.inventory.clear()
bot.inventory.add(Item(food, foodAmount))
state = State.PICKPOCKETING
}
}
}
}
override fun newInstance(): Script {
val script = FarmerThiever()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR,bot.startLocation)
return script
}
enum class State {
BANKING,
PICKPOCKETING
}
init {
inventory.add(Item(food,foodAmount))
skills[Skills.THIEVING] = 80
skills[Skills.HITPOINTS] = 10
}
}
@@ -0,0 +1,45 @@
package content.global.bots
import core.game.node.entity.skill.Skills
import content.global.skill.fletching.Fletching
import content.global.skill.fletching.FletchingPulse
import core.game.node.item.Item
import org.rs09.consts.Items
import core.game.bots.SkillingBotAssembler
import core.game.bots.Script
class FletchingBankstander : Script(){
var state = State.FLETCHING
override fun tick() {
val bank = scriptAPI.getNearestNode("Bank booth")
bot.faceLocation(bank?.location)
state = when(state){
State.FLETCHING -> {
bot.inventory.add(Item(Items.KNIFE_946))
bot.inventory.add(Item(Items.LOGS_1511,27))
bot.pulseManager.run(FletchingPulse(bot, Item(Items.LOGS_1511),27, Fletching.FletchingItems.ARROW_SHAFT))
State.BANKING
}
State.BANKING -> {
bot.inventory.clear()
State.FLETCHING
}
}
}
init {
skills[Skills.FLETCHING] = 99
}
override fun newInstance(): Script {
val script = FletchingBankstander()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.AVERAGE,bot.startLocation)
return script
}
enum class State {
FLETCHING,
BANKING
}
}
@@ -0,0 +1,256 @@
package content.global.bots
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.zone.ZoneBorders
import core.tools.RandomFunction
import org.rs09.consts.Items
import core.game.bots.AIRepository
import core.game.bots.Script
/**
* A bot that does various random slayer tasks throughout the game and sells the loot on the GE.
* @author Ceikry
*/
class GenericSlayerBot : Script() {
var state = State.GETTING_TASK
var task = Task.CAVE_CRAWLER //default value to ensure non-nullability
var assignment = Assignment("",0) //same as above
var teleportFlag = false //have we teleported?
val FOOD_ID = Items.LOBSTER_379
val varrockBankBorders = ZoneBorders(3184, 3435,3187, 3441)
/**
* Per-tick actions (they don't run if the bot already has a pulse running, such as moving or combat.)
*/
override fun tick() {
scriptAPI.eat(FOOD_ID) //try to eat every tick (does nothing if health isn't low enough)
when(state){
/**
* State that handles getting a new task
*/
State.GETTING_TASK -> {
populateTaskAndAssignment()
state = State.GOING_TO_HUB //switch states
}
/**
* State that handles going to the "hub" for the task. Such as fremmy slayer cave or slayer tower.
*/
State.GOING_TO_HUB -> {
when(task.hub){
TaskHub.FREMENNIK_CAVE -> {
if(!teleportFlag) {
scriptAPI.teleport(Location.create(2781, 3615, 0)) //tele -> fremennik fairy ring
teleportFlag = !teleportFlag //teleportFlag -> true
}
else {
val entrance = scriptAPI.getNearestNode(4499,true) //returns the object if within render distance, null if not.
if(entrance == null || !entrance.location.withinDistance(bot.location,2)) {
scriptAPI.walkTo(Location.create(2796, 3615, 0))
} else {
entrance.interaction.handle(bot,entrance.interaction[0]) //bot -> use interaction [0] of cave object
teleportFlag = !teleportFlag //teleportFlag -> false
state = State.KILLING_ENEMY //switch states
}
}
}
}
}
/**
* State used for combat. Handles moving the bot back into the zone for the monster and looting as well.
*/
State.KILLING_ENEMY -> {
val items = AIRepository.groundItems.get(bot) //retrieve drops that belong to this bot
if(items != null && items.isNotEmpty()){ //if we have loot...
if(bot.inventory.freeSlots() == 0){
if(bot.inventory.contains(FOOD_ID,1)){
scriptAPI.forceEat(FOOD_ID)
return
}
}
scriptAPI.takeNearestGroundItem(items.get(0).id)
if(bot.inventory.getAmount(Item(FOOD_ID)) == 0){
state = State.GOING_TO_BANK
}
return
}
if(assignment.amount > 0) {
if (task.borders.insideBorder(bot)) { //make sure bot is within the borders of the task's zone.
scriptAPI.attackNpcInRadius(bot, task.npc_name, 20) //attack nearest NPC with given task name within radius.
assignment.amount--
} else {
scriptAPI.walkTo(task.borders.randomLoc)
}
} else {
state = State.GOING_TO_BANK //switch states and bank.
}
}
/**
* State used to handle traveling to a bank. Due to the dynamic nature of where these bots might be
* in this state, they simply teleport to Varrock and then walk to the west bank to bank.
*/
State.GOING_TO_BANK -> {
if(!teleportFlag){
scriptAPI.teleport(Location.create(3213, 3426, 0))
teleportFlag = !teleportFlag
} else {
if(!varrockBankBorders.insideBorder(bot)) {
scriptAPI.walkTo(varrockBankBorders.randomLoc)
} else {
val bank = scriptAPI.getNearestNode("Bank Booth",true)
bank ?: return
/**
* Run a pulse that moves the bot to the bank booth and then faces it, and then swaps to the actual banking state
*/
bot.pulseManager.run(object: MovementPulse(bot,bank, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
bot.faceLocation(bank.location)
state = State.BANKING
teleportFlag = !teleportFlag
return true
}
})
}
}
}
/**
* State used to handle banking itself. Runs a pulse with a delay of 10 (to make it look like the bot is idling at the bank booth a bit.)
* the pulse adds every item in the bot's inventory to its bank and then clears the bot's inventory. Re-adds lobsters to the inventory afterwords.
*/
State.BANKING -> {
bot.pulseManager.run(object: Pulse(10){
override fun pulse(): Boolean {
for(item in bot.inventory.toArray()){
item ?: continue
if(item.checkIgnored()) continue
bot.bank.add(item)
}
bot.inventory.clear()
for(item in inventory)
bot.inventory.add(item)
scriptAPI.withdraw(org.rs09.consts.Items.LOBSTER_379,10)
bot.fullRestore()
if(assignment.amount <= 0){
state = State.GOING_TO_GE
} else {
state = State.GOING_TO_HUB
}
return true
}
})
}
/**
* State used to handle travelling to the GE.
*/
State.GOING_TO_GE -> {
if(bot.location != Location.create(3165, 3487, 0)) {
scriptAPI.walkTo(Location.create(3165, 3487, 0))
} else {
state = State.SELLING
}
}
/**
* State used to handle selling items on the GE
*/
State.SELLING -> {
scriptAPI.sellAllOnGe()
state = State.GETTING_TASK
}
}
}
/**
* Called when a bot needs to be regenerated, like when a bot dies.
*/
override fun newInstance(): Script {
TODO("Not yet implemented")
}
/**
* Populate task and assignment vars
*/
fun populateTaskAndAssignment() {
task = Task.values().random() //get a new random task from the enum
assignment = Assignment(task.npc_name, RandomFunction.random(task.minAmt, task.maxAmt + 1)) //produce a new Assignment class with values from our Task.
}
/**
* Item extension function to check for ignored items when banking.
*/
fun Item.checkIgnored(): Boolean {
if(name.toLowerCase().contains("charm")) return true
if(name.toLowerCase().contains("lobster")) return true
if(name.toLowerCase().contains("clue")) return true
if(!definition.isTradeable) return true
return when(id){
Items.BONES_2530 -> true
995 -> true
else -> false
}
}
/**
* The state enums
*/
enum class State {
GETTING_TASK,
GOING_TO_HUB,
KILLING_ENEMY,
LOOTING,
GOING_TO_BANK,
BANKING,
GOING_TO_GE,
SELLING
}
/**
* Assign default skills and initial inventory
*/
init {
skills[Skills.SLAYER] = 99
inventory.add(Item(Items.LOBSTER_379,10))
}
/**
* List of tasks that this bot can receive
*/
enum class Task(val npc_name: String, val minAmt: Int, val maxAmt: Int, val hub: TaskHub, val borders: ZoneBorders) {
CAVE_CRAWLER("Cave crawler",20,100, TaskHub.FREMENNIK_CAVE, ZoneBorders(2778, 9988,2798, 10002))
}
/**
* The task hubs
*/
enum class TaskHub {
FREMENNIK_CAVE,
SLAYER_TOWER,
TAVERLY_DUNGEON
}
class Assignment(val npc_name: String, var amount: Int) //class used to keep track of current assignment and how many are left.
}
@@ -0,0 +1,45 @@
package content.global.bots
import content.global.handlers.iface.GlassInterface
import core.game.node.entity.skill.Skills
import content.global.skill.crafting.GlassProduct
import core.game.node.item.Item
import org.rs09.consts.Items
import core.game.bots.SkillingBotAssembler
import core.game.bots.Script
class GlassBlowingBankstander : Script(){
var state = State.BLOWING
override fun tick() {
val bank = scriptAPI.getNearestNode("Bank booth")
bot.faceLocation(bank?.location)
state = when(state){
State.BLOWING -> {
bot.inventory.add(Item(Items.GLASSBLOWING_PIPE_1785))
bot.inventory.add(Item(Items.MOLTEN_GLASS_1775,27))
GlassInterface.make(bot, GlassProduct.ORB,27)
State.BANKING
}
State.BANKING -> {
bot.inventory.clear()
State.BLOWING
}
}
}
override fun newInstance(): Script {
val script = GlassBlowingBankstander()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.AVERAGE,bot.startLocation)
return script
}
init {
skills[Skills.CRAFTING] = 99
}
enum class State {
BLOWING,
BANKING
}
}
@@ -0,0 +1,163 @@
package content.global.bots
import core.game.bots.*
import core.game.world.map.zone.ZoneBorders
@PlayerCompatible
@ScriptName("Gnome Agility Course Script")
@ScriptDescription("Start the script while standing front of the balancing log")
@ScriptIdentifier("gnome_agility")
class GnomeAgility : Script() {
var state = State.INIT
val startzone = ZoneBorders(2473,3436,2475,3437,0)
val afterlog = ZoneBorders(2474,3429,2474,3429,0)
val beforefirstnet = ZoneBorders(2473,3426,2474,3427,0)
val afterfirstnet = ZoneBorders(2471,3424,2476,3424,1)
val beforebranchup = ZoneBorders(2473,3423,2473,3423,1)
val afterbranchup = ZoneBorders(2473,3420,2473,3420,2)
val beforerope = ZoneBorders(2477,3420,2477,3420,2)
val afterrope = ZoneBorders(2483,3420,2483,3420,2)
val beforebranchdown = ZoneBorders(2485,3419,2486,3420,2)
val afterbranchdown = ZoneBorders(2487,3420,2487,3420,0)
val beforesecondnet = ZoneBorders(2483,3425,2488,3425,0)
val aftersecondnet = ZoneBorders(2483,3427,2488,3427,0)
val beforepipe = ZoneBorders(2484,3430,2487,3430,0)
val afterpipe = ZoneBorders(2484,3437,2487,3437,0)
var overlay: ScriptAPI.BottingOverlay? = null
var totalLaps = 0
override fun tick() {
when (state) {
State.INIT -> {
overlay = scriptAPI.getOverlay()
overlay!!.init()
overlay!!.setTitle("Agility Course")
overlay!!.setTaskLabel("Laps Run")
overlay!!.setAmount(0)
state = State.START
}
State.START -> {
if(!startzone.insideBorder(bot)){
scriptAPI.walkTo(startzone.randomLoc)
}
if(startzone.insideBorder(bot)){
state = State.LOG
}
}
State.LOG -> {
val log = scriptAPI.getNearestNode("log balance",true)
if(startzone.insideBorder(bot)) {
scriptAPI.interact(bot, log, "walk-across")
}
if(afterlog.insideBorder(bot)){
state = State.FIRSTNET
}
}
State.FIRSTNET -> {
val firstnet = scriptAPI.getNearestNode("obstacle net",true)
if(!beforefirstnet.insideBorder(bot)){
scriptAPI.walkTo(beforefirstnet.randomLoc)
}
if(beforefirstnet.insideBorder(bot)) {
scriptAPI.interact(bot, firstnet, "climb-over")
}
if(afterfirstnet.insideBorder(bot)){
state = State.BRANCHUP
}
}
State.BRANCHUP -> {
val branchup = scriptAPI.getNearestNode("tree branch", true)
if(!beforebranchup.insideBorder(bot) && !afterbranchup.insideBorder(bot)){
scriptAPI.walkTo(beforebranchup.randomLoc)
}
else if(beforebranchup.insideBorder(bot)){
scriptAPI.interact(bot,branchup,"climb")
}
else if(afterbranchup.insideBorder(bot)){
state = State.ROPE
}
}
State.ROPE -> {
val rope = scriptAPI.getNearestNode("balancing rope",true)
if(!beforerope.insideBorder(bot) && !afterrope.insideBorder(bot)){
scriptAPI.walkTo(beforerope.randomLoc)
}
else if(beforerope.insideBorder(bot)){
scriptAPI.interact(bot,rope,"walk-on")
}
else if(afterrope.insideBorder(bot)){
state = State.BRANCHDOWN
}
}
State.BRANCHDOWN -> {
val branchdown = scriptAPI.getNearestNode("tree branch",true)
if(!beforebranchdown.insideBorder(bot) && !afterbranchdown.insideBorder(bot)){
scriptAPI.walkTo(beforebranchdown.randomLoc)
}
else if(beforebranchdown.insideBorder(bot)){
scriptAPI.interact(bot,branchdown,"climb-down")
}
else if(afterbranchdown.insideBorder(bot)){
state = State.SECONDNET
}
}
State.SECONDNET -> {
val secondnet = scriptAPI.getNearestNode("obstacle net",true)
if(!beforesecondnet.insideBorder(bot) && !aftersecondnet.insideBorder(bot)){
scriptAPI.walkTo(beforesecondnet.randomLoc)
}
else if(beforesecondnet.insideBorder(bot)){
scriptAPI.interact(bot,secondnet,"climb-over")
}
else if(aftersecondnet.insideBorder(bot)){
state = State.PIPE
}
}
State.PIPE -> {
val pipe = scriptAPI.getNearestNode("obstacle pipe",true)
if(!beforepipe.insideBorder(bot) && !afterpipe.insideBorder(bot)){
scriptAPI.walkTo((beforepipe.randomLoc))
}
if(beforepipe.insideBorder(bot)){
scriptAPI.interact(bot,pipe,"squeeze-through")
}
if(afterpipe.insideBorder(bot)){
totalLaps += 1
overlay!!.setAmount(totalLaps)
state = State.START
}
}
}
}
override fun newInstance(): Script {
val script = GnomeAgility()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR,bot.startLocation)
return script
}
enum class State {
START,
LOG,
FIRSTNET,
BRANCHUP,
ROPE,
BRANCHDOWN,
SECONDNET,
PIPE,
INIT
}
}
@@ -0,0 +1,173 @@
package content.global.bots
import core.api.*
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import content.global.skill.crafting.spinning.SpinningItem
import content.global.skill.crafting.spinning.SpinningPulse
import core.game.bots.*
import core.game.node.item.Item
import core.game.world.map.Location
import core.game.world.map.path.Pathfinder
import core.game.world.map.zone.ZoneBorders
import org.rs09.consts.Items
@PlayerCompatible
@ScriptName("Gnome Stronghold Bowstring")
@ScriptDescription("Start in Gnome Stronghold, South of the Agility Course")
@ScriptIdentifier("gnome_bowstring")
class GnomeBowstring : Script() {
var state = State.PICKING
var stage = 0
var bLadderSwitch = false
var sLadderSwitch = false
val flaxzone = ZoneBorders(2457,3391,2493,3413,0)
val bankbottomLadder = ZoneBorders(2444, 3413, 2445, 3414, 0)
val banktopLadder = ZoneBorders(2445, 3415, 2446, 3414, 1)
val spinnerbottomLadder = ZoneBorders (2475, 3400, 2476, 3399, 0)
val spinnertopLadder = ZoneBorders (2474, 3397, 2476, 3399, 1)
val pick = ZoneBorders(2478, 3394, 339, 9)
val bank = ZoneBorders(2447, 3415, 2444, 3434)
var overlay: ScriptAPI.BottingOverlay? = null
override fun tick() {
when(state){
State.INIT -> {
overlay = scriptAPI.getOverlay()
overlay!!.init()
overlay!!.setTitle("Picking")
overlay!!.setTaskLabel("Flax Picked")
overlay!!.setAmount(0)
}
State.PICKING -> {
bot.interfaceManager.close()
if(!flaxzone.insideBorder(bot)){
scriptAPI.walkTo(flaxzone.randomLoc)
} else if(flaxzone.insideBorder(bot)) {
var flax = scriptAPI.getNearestNode(2646, true)
scriptAPI.interact(bot,flax,"pick")
}
if(bot.inventory.getAmount(Items.FLAX_1779) > 27){
sLadderSwitch = true
state = State.TO_SPINNER
}
}
State.TO_SPINNER -> {
if(sLadderSwitch){
if(!spinnerbottomLadder.insideBorder(bot.location)){
scriptAPI.walkTo(spinnerbottomLadder.randomLoc)
} else {
val ladder = scriptAPI.getNearestNode("Staircase", true)
if(ladder != null){
ladder.interaction.handle(bot, ladder.interaction[0])
sLadderSwitch = false
} else {
scriptAPI.walkTo(spinnerbottomLadder.randomLoc)
}
}
}
if(stage == 0)
Pathfinder.find(bot, Location.create(2475,3399, 1)).walk(bot).also { stage++ }
when(bot.location){
Location.create(2475,3399, 1) -> Pathfinder.find(bot, Location.create(2477, 3399,1)).walk(bot)
Location.create(2477,3399, 1) -> Pathfinder.find(bot, Location.create(2477,3398, 1)).walk(bot)
Location.create(2477,3398, 1) -> Pathfinder.find(bot, Location.create(2476,3398, 1)).walk(bot)
Location.create(2476,3398, 1) -> {
val spinner = scriptAPI.getNearestNode(2644, true)
bot.faceLocation(spinner?.location)
bot.pulseManager.run(object: MovementPulse(bot,spinner, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
bot.faceLocation(spinner?.location)
state = State.SPINNING
return true
}
})
}
}
}
State.SPINNING -> {
bot.pulseManager.run(SpinningPulse(bot, Item(Items.FLAX_1779),bot.inventory.getAmount(Items.FLAX_1779), SpinningItem.FLAX))
sLadderSwitch = true
state = State.FIND_BANK
}
State.FIND_BANK -> {
if(sLadderSwitch){
val ladder = scriptAPI.getNearestNode("staircase", true)
if(ladder != null){
ladder.interaction.handle(bot, ladder.interaction[0])
sLadderSwitch = false
}
}
if(!bankbottomLadder.insideBorder(bot.location) && !spinnertopLadder.insideBorder(bot)){
scriptAPI.walkTo(bankbottomLadder.randomLoc)
}else if(bankbottomLadder.insideBorder(bot)){
bLadderSwitch = true
}
if(bLadderSwitch){
val ladder = scriptAPI.getNearestNode("staircase", true)
if(ladder != null){
ladder.interaction.handle(bot, ladder.interaction[0])
bLadderSwitch = false
}
}
if(banktopLadder.insideBorder(bot)){
state = State.BANKING
}
}
State.BANKING -> {
val bank = scriptAPI.getNearestNode(2213, true)
if(bank != null) {
bot.pulseManager.run(object : MovementPulse(bot, bank, DestinationFlag.OBJECT) {
override fun pulse(): Boolean {
bot.faceLocation(bank.location)
scriptAPI.bankItem(Items.BOW_STRING_1777)
return true
}
})
}
if(freeSlots(bot) > 27){
bLadderSwitch = true
state = State.RETURN_TO_FLAX
}
}
State.RETURN_TO_FLAX -> {
if(!banktopLadder.insideBorder(bot.location) && bLadderSwitch){
scriptAPI.walkTo(banktopLadder.randomLoc)
} else if(bLadderSwitch){
val ladder = scriptAPI.getNearestNode("Staircase", true)
if(ladder != null){
ladder.interaction.handle(bot, ladder.interaction[0])
bLadderSwitch = false
} else {
scriptAPI.walkTo(banktopLadder.randomLoc)
}
}
if(!flaxzone.insideBorder(bot)){
scriptAPI.walkTo(flaxzone.randomLoc)
} else if(flaxzone.insideBorder(bot)){
state = State.PICKING
}
}
}
}
override fun newInstance(): Script {
TODO("Not yet implemented")
}
}
enum class State {
PICKING,
MINING,
SPINNING,
TO_SPINNER,
FIND_BANK,
RETURN_TO_FLAX,
BANKING,
INIT
}
@@ -0,0 +1,284 @@
package content.global.bots
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.node.entity.Entity
import core.game.node.entity.combat.CombatStyle
import core.game.node.entity.combat.InteractionType
import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills
import content.global.skill.prayer.BoneBuryingOptionPlugin
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.map.zone.ZoneBorders
import core.game.world.map.zone.impl.WildernessZone
import core.tools.RandomFunction
import org.rs09.consts.Items
import core.game.bots.AIRepository
import core.game.bots.CombatBotAssembler
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import core.game.node.entity.combat.CombatSwingHandler
import core.game.node.entity.combat.MeleeSwingHandler
import kotlin.random.Random
/**
* A bot script for killing green dragons in the wilderness.. Capable of banking, selling on ge, eating, trash talking, buries bones when fleeing and more.
* @param style The combat style the bot is going to use.
* @param area (optional) What area the bot tries to kill dragons in.
* @author Ceikry
*/
class GreenDragonKiller(val style: CombatStyle, area: ZoneBorders? = null) : Script() {
companion object {
val westDragons = ZoneBorders(2971,3606,2991,3628)
val wildernessLine = ZoneBorders(3078,3523,3096,3523)
val edgevilleLine = ZoneBorders(3078,3520,3096,3520)
val bankZone = ZoneBorders(3092,3489,3094,3493)
val trashTalkLines = arrayOf("Bro, seriously?", "Ffs.", "Jesus christ.", "????", "Friendly!", "Get a life dude", "Do you mind??? lol", "Lol.", "Kek.", "One sec burying all the bones.", "Yikes.", "Yeet", "Ah shit, here we go again.", "Cmonnnn", "Plz", "Do you have nothing better to do?", "Cmon bro pls", "I just need to get my prayer up bro jesus", "Reeeeeee", "I cant believe you've done this", "Really m8", "Zomg", "Aaaaaaaaaaaaaaaaaaaaa", "Rofl.", "Oh god oh fuck oh shit", "....", ":|", "A q p", "Hcim btw", "I hope the revenants kill your mum", "Wrap your ass titties", "Why do this", "Bruh", "Straight sussin no cap fr fr", "This ain't bussin dawg", "Really bro?")
}
var state = State.TO_BANK
var handler: CombatSwingHandler? = null
var lootDelay = 0
var offerMade = false
var trashTalkDelay = 0
var food = if (Random.nextBoolean()){
Items.LOBSTER_379
} else if(Random.nextBoolean()){
Items.SWORDFISH_373
} else {
Items.SHARK_385
}
var myBorders: ZoneBorders? = null
val type = CombatBotAssembler.Type.MELEE
override fun tick() {
if(!bot.isActive){
running = false
return
}
checkFoodStockAndEat()
when(state){
State.KILLING -> {
bot.properties.combatPulse.temporaryHandler = handler
scriptAPI.attackNpcInRadius(bot,"Green dragon",20)
state = State.LOOT_DELAYER
}
State.LOOT_DELAYER -> {
if(lootDelay < 3)
lootDelay++
else
state = State.LOOTING
}
State.RUNNING -> {
val players = RegionManager.getLocalPlayers(bot.location)
if(players.isEmpty()){
state = State.TO_DRAGONS
} else {
if(bot.skullManager.level < 21){
if (scriptAPI.teleportToGE())
state = State.REFRESHING
return
}
sendTrashTalk()
attemptToBuryBone()
scriptAPI.walkTo(WildernessZone.getInstance().borders.random().randomLoc)
}
}
State.LOOTING -> {
lootDelay = 0
val items = AIRepository.groundItems.get(bot)
if(items.isNullOrEmpty()) {state = State.KILLING; return}
if(bot.inventory.isFull) {
if(bot.inventory.containsItem(Item(food))){
scriptAPI.forceEat(food)
} else {
state = State.TO_BANK
}
return
}
items.toTypedArray().forEach {it: Item -> scriptAPI.takeNearestGroundItem(it.id)}
}
State.TO_BANK -> {
if(!wildernessLine.insideBorder(bot) && bot.location.y > 3521)
scriptAPI.walkTo(wildernessLine.randomLoc)
if(wildernessLine.insideBorder(bot)){
val ditch = scriptAPI.getNearestNode("Wilderness Ditch",true)
ditch ?: return
ditch.interaction.handle(bot,ditch.interaction[0])
}
if(!bankZone.insideBorder(bot))
scriptAPI.walkTo(bankZone.randomLoc)
if(bankZone.insideBorder(bot)){
val bank = scriptAPI.getNearestNode("Bank Booth",true)
bank ?: return
bot.pulseManager.run(object: MovementPulse(bot,bank, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
bot.faceLocation(bank.location)
state = State.BANKING
return true
}
})
}
}
State.BANKING -> {
bot.pulseManager.run(object: Pulse(25){
override fun pulse(): Boolean {
for(item in bot.inventory.toArray()){
item ?: continue
if(item.name.toLowerCase().contains("lobster") || item.name.toLowerCase().contains("swordfish") || item.name.toLowerCase().contains("shark")) continue
if(item.id == 995) continue
bot.bank.add(item)
}
bot.inventory.clear()
state = if(bot.bank.getAmount(food) < 10)
State.TO_GE
else
State.TO_DRAGONS
for(item in inventory)
bot.inventory.add(item)
scriptAPI.withdraw(food,10)
bot.fullRestore()
return true
}
})
}
State.BUYING_FOOD -> {
state = State.TO_DRAGONS
bot.bank.add(Item(food,50))
bot.bank.refresh()
scriptAPI.withdraw(food, 10)
}
State.TO_DRAGONS -> {
offerMade = false
if(bot.location.x >= 3143){
if(bot.location != Location.create(3144, 3514, 0))
scriptAPI.walkTo(Location.create(3144, 3514, 0))
else {
val shortcut = scriptAPI.getNearestNode("Underwall Tunnel",true)
shortcut ?: return
InteractionListeners.run(shortcut.id, IntType.SCENERY, "climb-into", bot, shortcut)
}
} else {
if (!edgevilleLine.insideBorder(bot) && bot.location.y < 3520) {
scriptAPI.walkTo(edgevilleLine.randomLoc)
return
}
if (edgevilleLine.insideBorder(bot)) {
val ditch = scriptAPI.getNearestNode("Wilderness Ditch", true)
ditch ?: return
ditch.interaction.handle(bot, ditch.interaction[0]).also { return }
}
if (bot.location.y > 3520 && !myBorders!!.insideBorder(bot))
scriptAPI.walkTo(myBorders!!.randomLoc).also { return }
if (myBorders!!.insideBorder(bot))
state = State.KILLING
}
}
State.TO_GE -> {
if(bot.location.x < 3143) {
if(bot.location == Location.create(3136, 3517, 0)){
val shortcut = scriptAPI.getNearestNode("Underwall Tunnel",true)
shortcut ?: return
InteractionListeners.run(shortcut.id, IntType.SCENERY, "climb-into", bot, shortcut)
} else {
scriptAPI.walkTo(Location.create(3136, 3517, 0))
}
return
}
if(bot.location != Location.create(3165, 3487, 0)) {
scriptAPI.walkTo(Location.create(3165, 3487, 0))
} else {
state = State.SELL_GE
}
}
State.SELL_GE -> {
scriptAPI.sellAllOnGe()
state = State.BUYING_FOOD
}
State.REFRESHING -> {
running = false
return
}
}
}
private fun attemptToBuryBone() {
if (bot.inventory.containsAtLeastOneItem(Items.DRAGON_BONES_536)) {
BoneBuryingOptionPlugin().handle(bot, bot.inventory.get(Item(Items.DRAGON_BONES_536)), "bury")
}
}
private fun checkFoodStockAndEat() {
if (bot.inventory.getAmount(food) < 3 && state == State.KILLING)
state = State.TO_BANK
scriptAPI.eat(food)
}
private fun sendTrashTalk() {
if (trashTalkDelay-- == 0)
scriptAPI.sendChat(trashTalkLines.random())
else
trashTalkDelay = RandomFunction.random(10, 30)
}
override fun newInstance(): Script {
val script = GreenDragonKiller(style)
val tier = CombatBotAssembler.Tier.MED
script.bot = CombatBotAssembler().assembleMeleeDragonBot(tier, bot.startLocation)
return script
}
enum class State {
KILLING,
RUNNING,
LOOTING,
LOOT_DELAYER,
BANKING,
TO_BANK,
TO_DRAGONS,
TO_GE,
SELL_GE,
REFRESHING,
BUYING_FOOD
}
init {
handler = MeleeSwinger(this)
equipment.add(Item(Items.ANTI_DRAGON_SHIELD_1540))
myBorders = westDragons
skills[Skills.AGILITY] = 99
bankZone.addException(ZoneBorders(3094, 3492,3094, 3492))
bankZone.addException(ZoneBorders(3094, 3490,3094, 3490))
}
internal class MeleeSwinger(val script: GreenDragonKiller) : MeleeSwingHandler() {
override fun canSwing(entity: Entity, victim: Entity): InteractionType? {
if(victim is Player || victim.name.contains("revenant", ignoreCase = true)) {
script.state = State.RUNNING
script.bot.pulseManager.clear()
}
return super.canSwing(entity, victim)
}
}
}
@@ -0,0 +1,12 @@
package content.global.bots
import core.game.bots.Script
class Idler : Script(){
override fun tick() {
}
override fun newInstance(): Script {
return this
}
}
@@ -0,0 +1,197 @@
package content.global.bots
import core.game.bots.*
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 core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import core.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<Int, Int>()
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<Item>) {
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, IntType.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()
}
}
@@ -0,0 +1,27 @@
package content.global.bots
import core.game.node.item.Item
import core.game.bots.SkillingBotAssembler
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import java.util.*
class ManThiever : Script() {
override fun tick() {
val man = scriptAPI.getNearestNode("Man")
bot.interfaceManager.close()
man?.let { InteractionListeners.run(man.id,
IntType.NPC,"Pickpocket",bot,man) }
}
override fun newInstance(): Script? {
val script = ManThiever()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR, bot.startLocation)
return script
}
init {
equipment.addAll(Arrays.asList(Item(1103), Item(1139), Item(1265)))
}
}
@@ -0,0 +1,41 @@
package content.global.bots
import core.api.produceGroundItem
import core.game.node.entity.skill.Skills
import core.game.node.item.Item
import org.rs09.consts.Items
import core.game.bots.SkillingBotAssembler
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
class NonBankingMiner : Script() {
override fun tick() {
val rock = scriptAPI.getNearestNode(11957,true)
if(rock != null && !bot.inventory.isFull){
InteractionListeners.run(rock.id, IntType.SCENERY,"mine",bot,rock)
}
//checks if the bot has tin ore in his inventory and drops it if he does
if(bot.inventory.containsAtLeastOneItem(Items.TIN_ORE_438)){
produceGroundItem(null,438,1,bot.location)
bot.inventory.remove(Item(Items.TIN_ORE_438,1))
}
//The following is to prevent lucky bots from breaking by having a full inventory of gems
if(bot.inventory.isFull && (!bot.inventory.containsAtLeastOneItem(Items.TIN_ORE_438))){
bot.inventory.clear()
bot.inventory.add(Item(Items.MITHRIL_PICKAXE_1273))
}
}
override fun newInstance(): Script {
val script = NonBankingMiner()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR,bot.startLocation)
return script
}
init {
skills[Skills.ATTACK] = 99
inventory.add(Item(Items.MITHRIL_PICKAXE_1273))
skills[Skills.MINING] = 50
}
}
@@ -0,0 +1,155 @@
package content.global.bots
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.node.entity.skill.Skills
import content.global.skill.crafting.spinning.SpinningItem
import content.global.skill.crafting.spinning.SpinningPulse
import core.game.node.item.Item
import core.game.world.map.Location
import core.game.world.map.path.Pathfinder
import org.rs09.consts.Items
import core.game.bots.SkillingBotAssembler
import core.game.bots.Script
class SeersFlax : Script(){
var state = State.PICKING
var stage = 0
var doorOpen = false
override fun tick() {
when(state){
State.PICKING -> {
val flax = scriptAPI.getNearestNode(2646,true)
flax?.interaction?.handle(bot,flax.interaction[1])
if(bot.inventory.getAmount(Items.FLAX_1779) > 25){
state = State.TO_SPINNER
}
}
State.TO_SPINNER -> {
if(stage == 0)
Pathfinder.find(bot, Location.create(2736, 3442, 0)).walk(bot).also { stage++ }
when(bot.location){
Location.create(2736, 3442, 0) -> Pathfinder.find(bot,Location.create(2722, 3456, 0)).walk(bot)
Location.create(2722, 3456, 0) -> Pathfinder.find(bot,Location.create(2716, 3472, 0)).walk(bot)
Location.create(2716, 3472, 0) -> {
val door = scriptAPI.getNearestNode(25819,true)
if(door != null && door.location?.withinDistance(bot.location,2)!!){
door.interaction?.handle(bot, door.interaction[0])
doorOpen = true
} else {
val ladder = scriptAPI.getNearestNode(25938,true)
ladder?.interaction?.handle(bot,ladder.interaction[0]) }
}
Location.create(2714, 3470, 1) -> {
val spinner = scriptAPI.getNearestNode(25824,true)
bot.faceLocation(spinner?.location)
bot.pulseManager.run(object: MovementPulse(bot,spinner, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
bot.faceLocation(spinner?.location)
state = State.SPINNING.also { stage = 0; doorOpen = false }
return true
}
})
}
}
}
State.SPINNING -> {
bot.pulseManager.run(SpinningPulse(bot, Item(Items.FLAX_1779),bot.inventory.getAmount(Items.FLAX_1779), SpinningItem.FLAX))
state = State.FIND_BANK
}
State.FIND_BANK -> {
when(bot.location){
Location.create(2711, 3471, 1) -> {
val ladder = scriptAPI.getNearestNode(25939,true)
ladder?.interaction?.handle(bot,ladder?.interaction[0])
}
Location.create(2714, 3470, 0) -> Pathfinder.find(bot,Location.create(2715, 3472, 0)).walk(bot)
Location.create(2715, 3472, 0) -> {
val door = scriptAPI.getNearestNode(25819,true)
if(door != null && door.location?.withinDistance(bot.location,2)!!){
door.interaction?.handle(bot, door.interaction[0])
doorOpen = true
} else {
Pathfinder.find(bot,Location.create(2726, 3481, 0)).walk(bot)
}
}
Location.create(2726, 3481, 0) -> Pathfinder.find(bot,Location.create(2724, 3491, 0)).walk(bot)
Location.create(2724, 3491, 0) -> 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)
scriptAPI.bankItem(Items.BOW_STRING_1777)
if(bot.bank.getAmount(Items.BOW_STRING_1777) > 500){
state = State.TELE_GE
return true
}
state = State.RETURN_TO_FLAX
return true
}
})
}
State.RETURN_TO_FLAX -> {
if(bot.location == Location.create(2756, 3478, 0))
Pathfinder.find(bot,Location.create(2726, 3486, 0)).walk(bot)
if(stage == 0)
Pathfinder.find(bot,Location.create(2726, 3486, 0)).walk(bot).also { stage++ }
when(bot.location){
Location.create(2726, 3486, 0) -> Pathfinder.find(bot,Location.create(2729, 3469, 0)).walk(bot)
Location.create(2729, 3469, 0) -> Pathfinder.find(bot,Location.create(2734, 3447, 0)).walk(bot)
Location.create(2734, 3447, 0) -> state = State.PICKING.also { stage = 0 }
}
}
State.TELE_GE -> {
scriptAPI.teleportToGE()
state = State.SELL_GE
}
State.SELL_GE -> {
scriptAPI.sellOnGE(Items.BOW_STRING_1777)
state = State.TELE_CAMELOT
}
State.TELE_CAMELOT -> {
scriptAPI.teleport(Location.create(2756, 3478, 0))
stage = 0
state = State.RETURN_TO_FLAX
}
}
}
enum class State {
PICKING,
SPINNING,
TO_SPINNER,
FIND_BANK,
BANKING,
TELE_GE,
SELL_GE,
RETURN_TO_FLAX,
TELE_CAMELOT
}
init {
skills[Skills.CRAFTING] = 10
}
override fun newInstance(): Script {
val script = SeersFlax()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR,bot.startLocation)
return script
}
}
@@ -0,0 +1,118 @@
package content.global.bots
import core.game.bots.*
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 core.game.interaction.IntType
import core.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, IntType.SCENERY,"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
}
}
@@ -0,0 +1,223 @@
package content.global.bots
import core.game.bots.*
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.tools.RandomFunction
import org.rs09.consts.Items
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
import kotlin.random.Random
/*
Grabs all amounts in GE
val offers = HashMap<Int, Int>()
for (offer in GEOfferDispatch.offerMapping.values) {
val item = offer.itemId
val amount = offer.amount - offer.completedAmount
if (offers[item] == null) { offers[item] = amount }
else { offers[item] = offers[item]!!.plus(amount) }
if (offers[383]!!.plus(amount) >= 1000) {
*/
/*
Grabs just one offer
for (offer in GEOfferDispatch.offerMapping.values) {
if (offer.itemId == 383 && offer.amount >= 1000) {
*/
/**
* A bot script for fishing sharks in the Fishing Guild - Fishes, Banks, Sells.
* @param mycounter used in the bots random idling function.
* @param pause is currently not used.
* @param limit is the number of Raw Sharks in the GE the bots will sleep at.
* @author Sir Kermit
* Training Wheel Manufacturer @Ceikry
* Very slight ge modifications by @Angle
*/
@PlayerCompatible
@ScriptName("Guild Sharks")
@ScriptDescription("Start in the fishing guild with a harpoon","in your inventory.")
@ScriptIdentifier("guild_sharks")
class SharkCatcher : Script() {
//val shark = Items.RAW_SHARK
val pause = (1000..3000)
val limit = 5000
var myCounter = 0
//val fishzone = ZoneBorders(2597, 3410, 2612, 3426)
internal enum class Sets(val equipment: List<Item>) {
SET_1(listOf(Item(10721), Item(8283), Item(10412), Item(10414), Item(88), Item(1007))),
SET_2(listOf(Item(10721), Item(8283), Item(10412), Item(10414), Item(88), Item(1007))),
SET_3(listOf(Item(10721), Item(8283), Item(10412), Item(10414), Item(88), Item(1019))),
SET_4(listOf(Item(10721), Item(8283), Item(10412), Item(10414), Item(88), Item(1019))),
SET_5(listOf(Item(10721), Item(8283), Item(10412), Item(10414), Item(88), Item(3765))),
SET_6(listOf(Item(10721), Item(8283), Item(10412), Item(10414), Item(88), Item(3765)));
}
private var state = State.INIT
private var tick = 0
var fishCounter = 0
var overlay: ScriptAPI.BottingOverlay?= null
override fun tick() {
val fishguild = Location.create(2596, 3410, 0)
if (tick++ >= 500){
scriptAPI.teleport(fishguild)
state = State.FIND_SPOT
return
}
when(state){
State.INIT -> {
overlay = scriptAPI.getOverlay()
overlay!!.init()
overlay!!.setTitle("Fishing")
overlay!!.setTaskLabel("Sharks Caught:")
overlay!!.setAmount(0)
state = State.FIND_SPOT
}
State.BANKING -> {
fishCounter += bot.inventory.getAmount(Items.RAW_SHARK_383)
scriptAPI.bankItem(Items.RAW_SHARK_383)
state = State.FIND_SPOT
}
State.STOP -> {
val botAmount = bot.bank.getAmount(Items.RAW_SHARK_383) + 1
var geAmount = 0//OfferManager.getQuantitySoldForItem(Items.RAW_SHARK_383)
val totalAmount = (geAmount + botAmount) + 1
if((totalAmount > limit) && myCounter++ == 300){
bot.randomWalk(5,5)
myCounter = 0
return
} else if (myCounter++ == 300){
myCounter = 0
State.TELE_FISH
}
return
}
State.IDLE -> {
if (Random.nextBoolean()){
state = State.FIND_SPOT
}
else if(myCounter++ >= RandomFunction.random(1,25)){
myCounter = 0
state = State.FIND_SPOT
}
}
State.FISHING -> {
bot.interfaceManager.close()
if (Random.nextBoolean()) {
tick = 0
val spot = scriptAPI.getNearestNode(334, false)
spot?.let { InteractionListeners.run(spot.id, IntType.NPC,"harpoon",bot,spot) }
if(bot.inventory.isFull){
state = State.FIND_BANK
} else {
state = State.IDLE
}
}
else{
state = State.IDLE
}
overlay!!.setAmount(fishCounter + bot.inventory.getAmount(Items.RAW_SHARK_383))
}
State.FIND_SPOT -> {
val spot = scriptAPI.getNearestNode(334, false)
if (spot != null) {
bot.walkingQueue.reset()
state = State.FISHING
} else {
if(bot.location.x < 2591) {
scriptAPI.walkTo(Location.create(2604, 3421, 0))
} else {
scriptAPI.walkTo(Location.create(2608, 3414, 0))
}
}
}
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 != 2596) {
scriptAPI.walkTo(Location.create(2596, 3415, 0))
} else if (bot.location.x < 2591) {
scriptAPI.walkTo(Location.create(2591, 3415, 0))
} else if (bot.location.x < 2587){
scriptAPI.walkTo(Location.create(2587, 3420, 0))
}
}
}
State.TELEPORT_GE -> {
scriptAPI.teleportToGE()
state = State.SELL_GE
}
State.SELL_GE -> {
val botAmount = bot.bank.getAmount(Items.RAW_SHARK_383) + 1
var geAmount = 0//OfferManager.getQuantitySoldForItem(Items.RAW_SHARK_383)
val totalAmount = (geAmount + botAmount) + 1
if(totalAmount > limit){
scriptAPI.walkTo(Location.create(3164, 3487, 0))
scriptAPI.sellOnGE(Items.RAW_SHARK_383)
state = State.STOP//.also { println("STOPPING") }
} else {
scriptAPI.walkTo(Location.create(3164, 3487, 0))
scriptAPI.sellOnGE(Items.RAW_SHARK_383)
state = State.TELE_FISH
}
}
State.TELE_FISH -> {
scriptAPI.teleport(fishguild)
state = State.FIND_SPOT
}
}
}
init {
val setUp = RandomFunction.random(Sets.values().size)
equipment.addAll(Sets.values()[setUp].equipment)
inventory.add(Item(311))
skills[Skills.FISHING] = 90
}
enum class State{
FISHING,
BANKING,
FIND_BANK,
FIND_SPOT,
TELEPORT_GE,
SELL_GE,
TELE_FISH,
IDLE,
STOP,
INIT
}
override fun newInstance(): Script {
val script = SharkCatcher()
script.bot = AIPlayer(bot.startLocation)
script.state = State.FIND_SPOT
return script
}
}
@@ -0,0 +1,95 @@
package content.global.bots
import core.game.node.entity.skill.Skills
import core.game.node.item.Item
import core.game.world.map.Location
import core.tools.RandomFunction
import org.rs09.consts.Items
import core.game.bots.GeneralBotCreator
import content.global.activity.shootingstar.ShootingStarPlugin
import core.game.bots.Script
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
class ShootingStarBot : Script() {
private var state = State.FULL_IDLE
private var timerCountdown = 0
val star = ShootingStarPlugin.getStar()
override fun tick() {
bot.fullRestore()
if(timerCountdown > 0) {
--timerCountdown
return
}
when(state) {
State.FULL_IDLE -> {}
State.TELEPORT_TO -> {
scriptAPI.teleport(star.crash_locations[star.location]!!.transform(0, -1, 0))
state = State.MINING
timerCountdown = 15
}
State.MINING -> {
InteractionListeners.run(star.starObject.id, IntType.SCENERY, "mine", bot, star.starObject)
}
State.TELEPORT_BACK -> {
scriptAPI.teleport(spawnLoc)
timerCountdown = 15
}
}
}
init {
skills[Skills.ATTACK] = 41
skills[Skills.RANGE] = RandomFunction.random(30,99)
skills[Skills.MINING] = 99
skills[Skills.HITPOINTS] = 99
skills[Skills.DEFENCE] = 99
skills[Skills.SUMMONING] = 99
skills[Skills.PRAYER] = 99
inventory.add(Item(Items.RUNE_PICKAXE_1275))
}
override fun newInstance(): Script {
return ShootingStarBot()
}
fun activate(instant: Boolean) {
state = State.TELEPORT_TO
if(!instant)
timerCountdown = RandomFunction.random(500)
}
fun sleep() {
state = State.TELEPORT_BACK
}
fun isMining() : Boolean {
return state == State.MINING
}
fun isIdle() : Boolean {
return state == State.FULL_IDLE
}
internal enum class State {
FULL_IDLE,
TELEPORT_TO,
MINING,
TELEPORT_BACK
}
companion object {
val spawnLoc = Location.create(2230, 3339, 0)
fun new() : ShootingStarBot {
val script = ShootingStarBot()
GeneralBotCreator(script, spawnLoc)
return script
}
}
}
@@ -0,0 +1,117 @@
package content.global.bots
import core.game.bots.*
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.world.map.Location
import core.game.world.map.zone.ZoneBorders
import org.rs09.consts.Items
import core.game.interaction.IntType
import core.game.interaction.InteractionListeners
@PlayerCompatible
@ScriptDescription("Start in varrock bank with rune mysteries complete and a pickaxe equipped/in inventory")
@ScriptName("Varrock Essence Miner")
@ScriptIdentifier("essence_miner")
class VarrockEssenceMiner : Script(){
var state = State.TO_ESSENCE
val auburyZone = ZoneBorders(3252, 3398, 3254, 3402)
val bankZone = ZoneBorders(3251, 3420,3254, 3422)
override fun tick() {
when(state){
State.TO_ESSENCE -> {
bot.interfaceManager.close()
if(!auburyZone.insideBorder(bot))
scriptAPI.walkTo(auburyZone.randomLoc)
else {
val aubury = scriptAPI.getNearestNode("Aubury")
aubury?.interaction?.handle(bot,aubury.interaction[3])
state = State.MINING
}
/*val bank = scriptAPI.getNearestNode("Bank booth",true)
if(bank != null && bank.location?.withinDistance(bot.location,2) == true){
Pathfinder.find(bot, Location.create(3259, 3405, 0)).walk(bot)
} else {
when(bot.location){
Location.create(3165, 3487, 0) -> scriptAPI.teleport(Location.create(3254, 3421, 0))
Location.create(3259, 3405, 0) -> Pathfinder.find(bot,Location.create(3253, 3400, 0)).walk(bot)
Location.create(3253, 3400, 0) -> {
val aubury = scriptAPI.getNearestNode("Aubury")
aubury?.interaction?.handle(bot,aubury.interaction[3])
}
Location.create(2922, 4820, 0) -> {
state = State.MINING
}
}
}*/
}
State.MINING -> {
val essence = scriptAPI.getNearestNode(2491,true)
essence?.let { InteractionListeners.run(essence.id, IntType.SCENERY,"mine",bot,essence) }
if(bot.inventory.isFull)
state = State.TO_BANK
}
State.TO_BANK -> {
val portal = scriptAPI.getNearestNode("Portal",true)
if(portal != null && portal.location.withinDistance(bot.location,20))
portal.interaction.handle(bot,portal.interaction[0])
else {
if(!bankZone.insideBorder(bot)){
scriptAPI.walkTo(bankZone.randomLoc)
} else {
state = State.BANKING
}
}
}
State.BANKING -> {
val bank = scriptAPI.getNearestNode("bank booth",true)
val item =
if(bot.inventory.getAmount(Items.RUNE_ESSENCE_1436) > 0) Items.RUNE_ESSENCE_1436 else Items.PURE_ESSENCE_7936
if(bank != null){
bot.pulseManager.run(object : MovementPulse(bot,bank, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
bot.faceLocation(bank.location)
scriptAPI.bankItem(item)
state = State.TO_ESSENCE
return true
}
})
}
}
State.TELE_GE -> {
if(bot.location != Location.create(3165, 3482, 0))
scriptAPI.walkTo(Location.create(3165, 3482, 0))
else
state = State.SELL_GE
}
State.SELL_GE -> {
scriptAPI.sellOnGE(Items.PURE_ESSENCE_7936)
state = State.TO_ESSENCE
}
}
}
enum class State{
TO_ESSENCE,
TO_BANK,
MINING,
BANKING,
TELE_GE,
SELL_GE
}
override fun newInstance(): Script {
val script = VarrockEssenceMiner()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.POOR,bot.startLocation)
return script
}
}
@@ -0,0 +1,67 @@
package content.global.bots
import core.game.interaction.DestinationFlag
import core.game.interaction.MovementPulse
import core.game.node.entity.skill.Skills
import content.global.skill.smithing.Bars
import content.global.skill.smithing.SmithingPulse
import core.game.node.item.Item
import core.game.world.map.Location
import core.tools.RandomFunction
import org.rs09.consts.Items
import core.game.bots.SkillingBotAssembler
import core.game.bots.Script
class VarrockSmither : Script() {
var state = State.SMITHING
override fun tick() {
when(state) {
State.SMITHING -> {
for (i in inventory) {
bot.inventory.add(i)
}
val anvil = scriptAPI.getNearestNode("anvil", true)
if (anvil != null) {
bot.pulseManager.run(object : MovementPulse(bot, anvil, DestinationFlag.OBJECT) {
override fun pulse(): Boolean {
bot.faceLocation(anvil.location)
bot.pulseManager.run(SmithingPulse(bot, Item(2353), Bars.STEEL_ARROW_TIPS, 27))
state = State.BANKING
return true
}
})
}
}
State.BANKING -> {
val bank = scriptAPI.getNearestNode("Bank booth")
if(bank != null)
bot.pulseManager.run(object: MovementPulse(bot,bank, DestinationFlag.OBJECT){
override fun pulse(): Boolean {
bot.faceLocation(bank.location)
bot.inventory.clear()
state = State.SMITHING
return true
}
})
}
}
}
override fun newInstance(): Script {
val script = VarrockSmither()
script.bot = SkillingBotAssembler().produce(SkillingBotAssembler.Wealth.RICH, Location.create(3189, 3436, 0))
return script
}
init {
skills[Skills.SMITHING] = RandomFunction.random(33,99)
inventory.add(Item(Items.HAMMER_2347))
inventory.add(Item(Items.STEEL_BAR_2353,27))
}
enum class State {
SMITHING,
BANKING
}
}