From 08b96c3ce257186c9b2b11336aaadc3352da981e Mon Sep 17 00:00:00 2001 From: Tooze Date: Mon, 23 Feb 2026 23:30:18 -0500 Subject: [PATCH] ::babot - Spawns a bot who enters QuickStart as ANY role. --- .../minigame/barbassault/BarbassDevHelper.kt | 5 + .../barbassault/bots/BACombatState.kt | 46 ++++++ .../minigame/barbassault/bots/BarbassBot.kt | 147 ++++++++++++++++++ .../barbassault/lobby/BarbassLobbyActivity.kt | 11 +- 4 files changed, 205 insertions(+), 4 deletions(-) create mode 100644 Server/src/main/content/minigame/barbassault/bots/BACombatState.kt create mode 100644 Server/src/main/content/minigame/barbassault/bots/BarbassBot.kt diff --git a/Server/src/main/content/minigame/barbassault/BarbassDevHelper.kt b/Server/src/main/content/minigame/barbassault/BarbassDevHelper.kt index a4d4166cb..69f51e6ae 100644 --- a/Server/src/main/content/minigame/barbassault/BarbassDevHelper.kt +++ b/Server/src/main/content/minigame/barbassault/BarbassDevHelper.kt @@ -1,5 +1,7 @@ package content.minigame.barbassault +import content.minigame.barbassault.bots.BarbassBot +import content.minigame.barbassault.lobby.BarbassaultLobby import core.api.animateScenery import core.api.getScenery import core.api.replaceScenery @@ -37,6 +39,9 @@ class BarbassDevHelper : CommandSet(Privilege.ADMIN) { player.equipment.replace(Item(954),2) } + define("babot"){ player,_-> + BarbassBot(BarbassaultLobby.MAIN_LOBBY.randomWalkableLoc) + } define("hch"){ player,args-> val chId = args[1].toIntOrNull() diff --git a/Server/src/main/content/minigame/barbassault/bots/BACombatState.kt b/Server/src/main/content/minigame/barbassault/bots/BACombatState.kt new file mode 100644 index 000000000..c07676919 --- /dev/null +++ b/Server/src/main/content/minigame/barbassault/bots/BACombatState.kt @@ -0,0 +1,46 @@ +package content.minigame.barbassault.bots + +import core.game.interaction.MovementPulse +import core.game.node.Node +import core.game.node.entity.npc.NPC +import core.game.world.map.Location +import core.game.world.map.RegionManager +import core.game.world.map.path.Pathfinder +import core.tools.RandomFunction +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import content.minigame.pestcontrol.PestControlHelper.GATE_ENTRIES +import content.minigame.pestcontrol.PestControlHelper.getMyPestControlSession1 +import core.game.world.GameWorld +import java.util.* + + +class BACombatState(val bot: BarbassBot) { + private val Random = Random() + val randomtype = Random().nextInt(100) + + + fun fightNPCs() { + bot.customState = "Fight NPCs" + bot.AttackNpcsInRadius(8) + } + + fun randomWalkTo(loc: Location, radius: Int) { + var newloc = loc.transform(RandomFunction.random(radius, -radius), + RandomFunction.random(radius, -radius), 0) + if(!bot.walkingQueue.isMoving) { + walkToIterator(newloc) + } + } + + fun walkToIterator(loc: Location){ + var diffX = loc.x - bot.location.x + var diffY = loc.y - bot.location.y + + GameWorld.Pulser.submit(object : MovementPulse(bot, bot.location.transform(diffX, diffY, 0), Pathfinder.SMART) { + override fun pulse(): Boolean { + return true + } + }) + } +} diff --git a/Server/src/main/content/minigame/barbassault/bots/BarbassBot.kt b/Server/src/main/content/minigame/barbassault/bots/BarbassBot.kt new file mode 100644 index 000000000..1d3ad3800 --- /dev/null +++ b/Server/src/main/content/minigame/barbassault/bots/BarbassBot.kt @@ -0,0 +1,147 @@ +package content.minigame.barbassault.bots + +import content.minigame.barbassault.arena.BarbassaultState +import content.minigame.barbassault.lobby.BarbassLobbyActivity.Companion.addToQueue +import content.minigame.barbassault.lobby.BarbassaultLobby +import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.MAIN_LOBBY +import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.QUICK_START +import content.minigame.barbassault.lobby.BarbassaultLobby.Companion.waveLobbies +import content.minigame.barbassault.lobby.baSession +import content.minigame.pestcontrol.bots.PestControlTestBot2.State +import core.api.EquipmentSlot +import core.api.forceMove +import core.api.getRegionBorders +import core.game.bots.CombatBotAssembler +import core.game.bots.PvMBots +import core.game.container.impl.EquipmentContainer +import core.game.global.action.EquipHandler +import core.game.node.item.Item +import core.game.world.map.Location +import org.rs09.consts.Scenery +import java.util.* + +class BarbassBot(l: Location) : PvMBots(legitimizeLocation(l)){ + init { + CombatBotAssembler().gearPCiMeleeBot(this) + val icape: Item = this.equipment.get(1) + EquipHandler.unequip(this,1,icape.id) + isArtificial + } + + var tick = 0 + var combatMoveTimer = 0 + var justStartedGame = true + var movetimer = 0 + val num = Random().nextInt(4) + val combathandler = BACombatState(this) + var time = 0 + enum class State { OUTSIDE_ROOM, ENTER_ROOM,REFRESH, WAITING_IN_ROOM, PLAY_GAME, GET_TO_BA } + + override fun tick() { + super.tick() + tick++ + time++ + movetimer-- + if (movetimer <= 0) { + movetimer = 0 + customState = "$state$movetimer" + when (state) { + State.OUTSIDE_ROOM -> toBALobby() + State.ENTER_ROOM -> enterRoom() + State.REFRESH -> enterRoom() + State.WAITING_IN_ROOM -> idleInRoom() + State.PLAY_GAME -> doRoleTask() + State.GET_TO_BA -> doRoleTask() + } + } + } + var oneact = false + private fun enterRoom() { + this.sendChat("Attempting.....") + if (!oneact) { + val quickDoor = getClosestNodeWithEntry(2, Scenery.DOOR_20209) + // quickDoor.interaction.handle(this, quickDoor.interaction[0]) + if (quickDoor != null){ + quickDoor.interaction.handle(this, quickDoor.interaction[0]) + // this.dialogueInterpreter.handle(234,1) + this.dialogueInterpreter.handle(234,6) + oneact = true + } + + } + } + private fun idleInRoom() { + //chill, say somethings, walk around in .walkablearea + } + private fun doRoleTask() { + val myRole = this.baSession?.team?.getRoleForPlayer(this) + //do task based on myRole + } + + var switch = false + var diagone = false + private fun toBALobby() { + time = 0 + if (!switch){ + this.teleport(MAIN_LOBBY.randomWalkableLoc) + switch = true + return + } + if (switch) { + val quickDoor = getClosestNodeWithEntry(60, Scenery.DOOR_20209) + if (quickDoor == null) { + // switch = false + //this.teleport(MAIN_LOBBY.randomWalkableLoc) + State.OUTSIDE_ROOM + } else { + // switch = false + this.sendChat("Attempting to.....") + quickDoor.interaction.handle(this, quickDoor.interaction[0]) + val quickDoorclose = getClosestNodeWithEntry(2, Scenery.DOOR_20209) + if(quickDoorclose != null) { + if (!diagone){ + forceMove(this, this.location, this.location.transform(0, -1, 0), 25, 60, null, 819){ + addToQueue(this, null) + combathandler.walkToIterator(QUICK_START.randomWalkableLoc) + } + + diagone = true + } + + } + // this.dialogueInterpreter.handle(234,6) + State.ENTER_ROOM + } + } + } + fun isInLobbyOnly(location: Location): Boolean { + return getRegionBorders(10322).insideBorder(location) && waveLobbies.none { it != MAIN_LOBBY && it.insideBorder(location) } + } + + private val state: State + get() { + if (QUICK_START.insideBorder(this.getLocation())) { + return State.WAITING_IN_ROOM + } + if (this.baSession?.state == BarbassaultState.IN_ARENA) { + return State.PLAY_GAME + } + if (isInLobbyOnly(this.getLocation())) { + return State.OUTSIDE_ROOM + } + if (getClosestNodeWithEntry(1, Scenery.DOOR_20209) != null) { + return State.ENTER_ROOM + } + if (time == 1200) { + return State.GET_TO_BA + } + return State.GET_TO_BA + } + + companion object { + fun legitimizeLocation(l: Location): Location { + return l + } + } + +} \ No newline at end of file diff --git a/Server/src/main/content/minigame/barbassault/lobby/BarbassLobbyActivity.kt b/Server/src/main/content/minigame/barbassault/lobby/BarbassLobbyActivity.kt index 74828a6f5..10a442cd0 100644 --- a/Server/src/main/content/minigame/barbassault/lobby/BarbassLobbyActivity.kt +++ b/Server/src/main/content/minigame/barbassault/lobby/BarbassLobbyActivity.kt @@ -86,13 +86,16 @@ open class BarbassLobbyActivity : ActivityPlugin("BarbassLobby",false, false, tr } private fun createQuickTeam(players: List) { + // if(player == null) {removeQuickQue(player);return} players.forEach { removeQuickQue(it.player)} var teamLeader: Player? = null for (wp in players) { - if (giveScroll(wp.player)) { - teamLeader = wp.player - break - } + // if(player.isArtificial) {return} + if (giveScroll(wp.player)) { + teamLeader = wp.player + break + } + } //IF BY CHANCE no one had free inventory space KICK THEM ALL FROM QuickLobby! if (teamLeader == null) {