mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 18:35:11 -06:00
Bots dont get stuck outside quickstart wave lobby anymore.
This commit is contained in:
parent
2cdd2654eb
commit
4d541df89c
2 changed files with 97 additions and 103 deletions
|
|
@ -4,10 +4,10 @@ import content.minigame.barbassault.BarbRole
|
|||
import content.minigame.barbassault.arena.BarbassaultState
|
||||
import content.minigame.barbassault.getBARoleForPlayer
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.lobby.BarbassQuickWaveActivity.Companion.addToQueue
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.MAIN_LOBBY
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.QUICK_START
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.waveLobbies
|
||||
import content.minigame.barbassault.lobby.BarbassQuickWaveActivity.Companion.addToQueue
|
||||
import core.api.forceMove
|
||||
import core.api.getRegionBorders
|
||||
import core.game.bots.CombatBotAssembler
|
||||
|
|
@ -17,134 +17,122 @@ import core.game.node.item.Item
|
|||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
class BABot(l: Location) : PvMBots(legitimizeLocation(l)){
|
||||
class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
||||
|
||||
init {
|
||||
CombatBotAssembler().gearPCiMeleeBot(this)
|
||||
val icape: Item = this.equipment.get(1)
|
||||
EquipHandler.unequip(this,1,icape.id)
|
||||
|
||||
val cape: Item? = equipment.get(1)
|
||||
if (cape != null) {
|
||||
EquipHandler.unequip(this, 1, cape.id)
|
||||
}
|
||||
}
|
||||
|
||||
var tick = 0
|
||||
var combatMoveTimer = 0
|
||||
var justStartedGame = true
|
||||
var movetimer = 0
|
||||
val combathandler = BACombatState(this)
|
||||
var time = 0
|
||||
enum class State { OUTSIDE_ROOM, ENTER_ROOM,REFRESH, WAITING_IN_ROOM, PLAY_GAME, GET_TO_BA }
|
||||
private val combatHandler = BACombatState(this)
|
||||
private var tickTimer = 0
|
||||
private var moveTimer = 0
|
||||
|
||||
enum class State { GET_TO_BA, OUTSIDE_ROOM, ENTER_ROOM, WAITING_IN_ROOM, PLAY_GAME }
|
||||
|
||||
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
|
||||
}
|
||||
tickTimer++
|
||||
moveTimer--
|
||||
|
||||
}
|
||||
}
|
||||
private fun idleInRoom() {
|
||||
//chill, say somethings, walk around in .walkablearea
|
||||
}
|
||||
private fun doRoleTask() {
|
||||
val myRole = getBARoleForPlayer(this)
|
||||
when (myRole) {
|
||||
BarbRole.ATTACKER -> combathandler.fightNPCs()
|
||||
BarbRole.DEFENDER -> combathandler.handleDefender()
|
||||
BarbRole.COLLECTOR -> combathandler.handleCollector()
|
||||
BarbRole.HEALER -> combathandler.handleHealer()
|
||||
null -> return
|
||||
}
|
||||
combathandler.chatter()
|
||||
}
|
||||
customState = state.name
|
||||
|
||||
var switch = false
|
||||
var diagone = false
|
||||
private fun toBALobby() {
|
||||
time = 0
|
||||
if (!switch){
|
||||
this.teleport(MAIN_LOBBY.randomWalkableLoc)
|
||||
switch = true
|
||||
if (moveTimer > 0) {
|
||||
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
|
||||
}
|
||||
when (state) {
|
||||
State.GET_TO_BA -> getToBA()
|
||||
State.OUTSIDE_ROOM -> outsideRoom()
|
||||
State.ENTER_ROOM -> enterRoom()
|
||||
State.WAITING_IN_ROOM -> waitingInRoom()
|
||||
State.PLAY_GAME -> playGame()
|
||||
}
|
||||
}
|
||||
fun isInLobbyOnly(location: Location): Boolean {
|
||||
return getRegionBorders(10322).insideBorder(location) && waveLobbies.none { it != MAIN_LOBBY && it.insideBorder(location) }
|
||||
}
|
||||
|
||||
private val state: State
|
||||
private val state: State
|
||||
get() {
|
||||
if (QUICK_START.insideBorder(this.getLocation())) {
|
||||
return State.WAITING_IN_ROOM
|
||||
}
|
||||
if (getBASession(this)?.state == BarbassaultState.IN_ARENA) {
|
||||
|
||||
val session = getBASession(this)
|
||||
|
||||
if (session?.state == BarbassaultState.IN_ARENA) {
|
||||
return State.PLAY_GAME
|
||||
}
|
||||
if (isInLobbyOnly(this.getLocation())) {
|
||||
return State.OUTSIDE_ROOM
|
||||
|
||||
if (QUICK_START.insideBorder(location)) {
|
||||
return State.WAITING_IN_ROOM
|
||||
}
|
||||
if (getClosestNodeWithEntry(1, Scenery.DOOR_20209) != null) {
|
||||
if (!isInLobbyOnly(location)) {
|
||||
return State.WAITING_IN_ROOM
|
||||
}
|
||||
|
||||
if (getClosestNodeWithEntry(2, Scenery.DOOR_20209) != null) {
|
||||
return State.ENTER_ROOM
|
||||
}
|
||||
if (time == 1200) {
|
||||
return State.GET_TO_BA
|
||||
|
||||
if (isInLobbyOnly(location)) {
|
||||
return State.OUTSIDE_ROOM
|
||||
}
|
||||
|
||||
return State.GET_TO_BA
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun legitimizeLocation(l: Location): Location {
|
||||
return l
|
||||
private fun getToBA() {
|
||||
teleport(MAIN_LOBBY.randomWalkableLoc)
|
||||
moveTimer = 3
|
||||
}
|
||||
|
||||
private fun outsideRoom() {
|
||||
val quickDoor = getClosestNodeWithEntry(60, Scenery.DOOR_20209)?: return
|
||||
quickDoor.interaction.handle(this, quickDoor.interaction[0])
|
||||
moveTimer = 2
|
||||
}
|
||||
|
||||
|
||||
private fun enterRoom() {
|
||||
val quickDoor = getClosestNodeWithEntry(2, Scenery.DOOR_20209)?: return
|
||||
|
||||
quickDoor.interaction.handle(this, quickDoor.interaction[0])
|
||||
|
||||
forceMove(this,location,location.transform(0, -1, 0),25,60,null,819) {
|
||||
addToQueue(this, null)
|
||||
combatHandler.walkToIterator(QUICK_START.randomWalkableLoc)
|
||||
}
|
||||
|
||||
moveTimer = 4
|
||||
}
|
||||
|
||||
private fun waitingInRoom() {
|
||||
if (tickTimer % 50 == 0) {
|
||||
combatHandler.chatter()
|
||||
}
|
||||
}
|
||||
|
||||
private fun playGame() {
|
||||
when (getBARoleForPlayer(this)) {
|
||||
BarbRole.ATTACKER -> combatHandler.fightNPCs()
|
||||
BarbRole.DEFENDER -> combatHandler.handleDefender()
|
||||
BarbRole.COLLECTOR -> combatHandler.handleCollector()
|
||||
BarbRole.HEALER -> combatHandler.handleHealer()
|
||||
null -> return
|
||||
}
|
||||
}
|
||||
|
||||
fun isInLobbyOnly(location: Location): Boolean {
|
||||
return getRegionBorders(10322).insideBorder(location)
|
||||
&& waveLobbies.none {it != MAIN_LOBBY && it.insideBorder(location)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun legitimizeLocation(l: Location): Location {
|
||||
return l
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package content.minigame.barbassault.bots
|
|||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.getBARoleForPlayer
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.getRegionBorders
|
||||
import core.game.interaction.MovementPulse
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.path.Pathfinder
|
||||
|
|
@ -22,10 +24,14 @@ class BACombatState(val bot: BABot) {
|
|||
}
|
||||
fun handleDefender() {
|
||||
bot.customState = "Lure Runners"
|
||||
val session = getBASession(bot) ?: return
|
||||
walkToIterator(session.region.borders.randomWalkableLoc)
|
||||
//bot.AttackNpcsInRadius(25)
|
||||
}
|
||||
fun handleCollector() {
|
||||
bot.customState = "Collecting Eggs"
|
||||
val session = getBASession(bot) ?: return
|
||||
walkToIterator(session.region.borders.randomWalkableLoc)
|
||||
//bot.AttackNpcsInRadius(25)
|
||||
}
|
||||
fun handleHealer() {
|
||||
|
|
@ -35,7 +41,7 @@ class BACombatState(val bot: BABot) {
|
|||
|
||||
fun chatter() {
|
||||
bot.sendChat("LETS GOO!")
|
||||
if (krng.nextInt(200) != 0) return
|
||||
if (krng.nextInt(12) != 0) return
|
||||
val role = getBARoleForPlayer(bot)
|
||||
val messages = when (role) {
|
||||
BarbRole.ATTACKER -> listOf("Call pls", "Wrong style?", "Attacking!")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue