mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 10:25:13 -06:00
Work on BaBots Using ItemMachines to "stockup" base on role.
This commit is contained in:
parent
175e141970
commit
3a7bd855b1
3 changed files with 52 additions and 14 deletions
|
|
@ -6,9 +6,17 @@ import content.minigame.barbassault.arena.DEFENDER_ICON
|
|||
import content.minigame.barbassault.arena.HEALER_ICON
|
||||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
|
||||
|
||||
val LureItems = intArrayOf(Items.WORMS_10515, Items.CRACKERS_10513, Items.TOFU_10514)
|
||||
enum class BarbRole { ATTACKER, COLLECTOR,DEFENDER, HEALER }
|
||||
enum class BarbRole(val machineId: Int) {
|
||||
ATTACKER(Scenery.ATTACKER_ITEM_MACHINE_20241),
|
||||
DEFENDER(Scenery.DEFENDER_ITEM_MACHINE_20242),
|
||||
HEALER(Scenery.HEALER_ITEM_MACHINE_20243),
|
||||
COLLECTOR(Scenery.COLLECTOR_CONVERTER_21250)
|
||||
}
|
||||
data class BarbAssaultPoints( val atk: Int = 0, val col: Int = 0, val def: Int = 0, val heal: Int = 0) {
|
||||
val total: Int get() = atk + col + def + heal
|
||||
fun hasEnough(cost: BarbAssaultPoints): Boolean = atk >= cost.atk && col >= cost.col && def >= cost.def && heal >= cost.heal
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package content.minigame.barbassault.bots
|
|||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbassaultState
|
||||
import content.minigame.barbassault.arena.scenery.ItemMachine
|
||||
import content.minigame.barbassault.arena.scenery.ItemMachine.DispenserType
|
||||
import content.minigame.barbassault.getBARoleForPlayer
|
||||
import content.minigame.barbassault.getBASession
|
||||
import content.minigame.barbassault.lobby.BALobby.Companion.MAIN_LOBBY
|
||||
|
|
@ -11,18 +13,22 @@ import content.minigame.barbassault.lobby.BarbassQuickWaveActivity.Companion.add
|
|||
import core.api.forceMove
|
||||
import core.api.getRegionBorders
|
||||
import core.api.log
|
||||
import core.api.queueScript
|
||||
import core.api.stopExecuting
|
||||
import core.game.bots.AIPlayer
|
||||
import core.game.bots.CombatBotAssembler
|
||||
import core.game.bots.PvMBots
|
||||
import core.game.global.action.EquipHandler
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.RegionManager.getLocalNpcs
|
||||
import core.tools.Log
|
||||
import org.rs09.consts.Scenery
|
||||
import org.rs09.consts.Scenery.ATTACKER_ITEM_MACHINE_20241
|
||||
import org.rs09.consts.Scenery.COLLECTOR_CONVERTER_21250
|
||||
import org.rs09.consts.Scenery.DEFENDER_ITEM_MACHINE_20242
|
||||
import org.rs09.consts.Scenery.HEALER_ITEM_MACHINE_20243
|
||||
|
||||
class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
||||
|
||||
|
|
@ -39,6 +45,7 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
private val combatHandler = BACombatState(this)
|
||||
private var tickTimer = 0
|
||||
private var moveTimer = 0
|
||||
var hasVendingItems = false
|
||||
|
||||
enum class State { GET_TO_BA, OUTSIDE_ROOM, ENTER_ROOM, WAITING_IN_ROOM, PLAY_GAME }
|
||||
|
||||
|
|
@ -70,7 +77,7 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
if (session?.state == BarbassaultState.IN_ARENA) {
|
||||
return State.PLAY_GAME
|
||||
}
|
||||
if (QUICK_START.insideBorder(location)) {
|
||||
if (isWaitingArea(location)) {
|
||||
return State.WAITING_IN_ROOM
|
||||
}
|
||||
|
||||
|
|
@ -88,6 +95,21 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
moveTimer = 3
|
||||
}
|
||||
|
||||
fun useRoleVendingMachine() {
|
||||
if (hasVendingItems) return
|
||||
|
||||
val roleMachine = getClosestNodeWithEntry(60, getBARoleForPlayer(this)!!.machineId) ?: return
|
||||
if (roleMachine.id == COLLECTOR_CONVERTER_21250) return
|
||||
queueScript(this,3) {
|
||||
roleMachine.interaction.handle(this, roleMachine.interaction[0])
|
||||
// ItemMachine().handleAddItemMachine(this, roleMachine,10558, STOCK_UP_DEF, 1,DispenserType.FOOD)
|
||||
|
||||
hasVendingItems = true
|
||||
return@queueScript stopExecuting(this)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun outsideRoom() {
|
||||
val quickDoor = getClosestNodeWithEntry(60, Scenery.DOOR_20209) ?: return
|
||||
quickDoor.interaction.handle(this, quickDoor.interaction[0])
|
||||
|
|
@ -133,8 +155,13 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun isWaitingArea(location: Location): Boolean {
|
||||
hasVendingItems = false
|
||||
return QUICK_START.insideBorder(location) || waveLobbies.any { it.insideBorder(location) && it != MAIN_LOBBY }
|
||||
}
|
||||
|
||||
fun debugthis(info : Any) {
|
||||
log(this.javaClass, Log.FINE,state.toString())
|
||||
log(this.javaClass, Log.FINE,state.toString())
|
||||
}
|
||||
|
||||
override fun AttackNpcsInRadius(bot: Player, radius: Int): Boolean {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
package content.minigame.barbassault.bots
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle.STYLE_1
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle.STYLE_2
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle.STYLE_3
|
||||
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle.STYLE_4
|
||||
import content.minigame.barbassault.arena.scenery.ItemMachine
|
||||
import content.minigame.barbassault.arena.scenery.ItemMachine.DispenserType
|
||||
import content.minigame.barbassault.getBARoleForPlayer
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.game.interaction.MovementPulse
|
||||
|
|
@ -16,11 +13,13 @@ import core.game.world.GameWorld
|
|||
import core.game.world.map.Location
|
||||
import core.game.world.map.path.Pathfinder
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
class BACombatState(private val bot: BABot) {
|
||||
|
||||
fun fightNPCs() {
|
||||
bot.customState = "Fight NPCs"
|
||||
bot.hasVendingItems = true
|
||||
bot.AttackNpcsInRadius(bot,25)
|
||||
//use Called AttackStyle
|
||||
val baSession = getBASession(bot) ?: return
|
||||
|
|
@ -31,6 +30,8 @@ class BACombatState(private val bot: BABot) {
|
|||
|
||||
fun handleDefender() {
|
||||
bot.customState = "Lure Runners"
|
||||
bot.useRoleVendingMachine()
|
||||
|
||||
val session = getBASession(bot) ?: return
|
||||
|
||||
randomWalk(session.region.borders.randomWalkableLoc, 3)
|
||||
|
|
@ -39,6 +40,7 @@ class BACombatState(private val bot: BABot) {
|
|||
|
||||
fun handleCollector() {
|
||||
bot.customState = "Collecting Eggs"
|
||||
bot.hasVendingItems = true
|
||||
val session = getBASession(bot) ?: return
|
||||
|
||||
randomWalk(session.region.borders.randomWalkableLoc, 3)
|
||||
|
|
@ -47,8 +49,9 @@ class BACombatState(private val bot: BABot) {
|
|||
|
||||
fun handleHealer() {
|
||||
bot.customState = "Healing"
|
||||
bot.useRoleVendingMachine()
|
||||
val session = getBASession(bot) ?: return
|
||||
|
||||
//if healing vial Empty Go fill.
|
||||
randomWalk(session.region.borders.randomWalkableLoc, 2)
|
||||
//Only use Called poisonFood.
|
||||
}
|
||||
|
|
@ -67,9 +70,9 @@ class BACombatState(private val bot: BABot) {
|
|||
}
|
||||
|
||||
fun randomWalk(center: Location, radius: Int) {
|
||||
if (bot.walkingQueue.isMoving) {
|
||||
return
|
||||
}
|
||||
if (!bot.hasVendingItems) return
|
||||
if (bot.walkingQueue.isMoving) return
|
||||
|
||||
|
||||
val destination = center.transform(
|
||||
RandomFunction.random(-radius, radius),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue