mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 10:25:13 -06:00
BAbots now "use" their horns
This commit is contained in:
parent
4d541df89c
commit
e1f941f496
3 changed files with 120 additions and 83 deletions
|
|
@ -5,6 +5,7 @@ import content.minigame.barbassault.BA_SESSION_KEY
|
|||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.BAActivity
|
||||
import content.minigame.barbassault.LureItems
|
||||
import content.minigame.barbassault.arena.BAHornSystem.BaCall
|
||||
import content.minigame.barbassault.arena.scenery.EggCannon
|
||||
import content.minigame.barbassault.arena.scenery.GloryHorn
|
||||
import content.minigame.barbassault.getBALevels
|
||||
|
|
@ -516,14 +517,15 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
roleCalls[BarbRole.DEFENDER]?.toCall = roleCalls[BarbRole.HEALER]?.required
|
||||
updateRoleUI()
|
||||
updateGloryHornUI()
|
||||
team.allPlayers().forEach { if(it.isArtificial){ botMakeCall(it) } }
|
||||
}
|
||||
|
||||
fun updateGloryHornUI(){
|
||||
team.allPlayers().forEach { player ->
|
||||
val atkCallText = (roleCalls[BarbRole.COLLECTOR]?.toCall as? AttackerStyle)?.let { "${it.top}${it.bottom}" } ?: GloryHorn.CallOut.defaultText
|
||||
val colCallText = (roleCalls[BarbRole.ATTACKER]?.toCall as? HasUIText)?.ui ?: GloryHorn.CallOut.defaultText
|
||||
val defCallText = (roleCalls[BarbRole.HEALER]?.toCall as? HasUIText)?.ui ?: GloryHorn.CallOut.defaultText
|
||||
val healCallText = (roleCalls[BarbRole.DEFENDER]?.toCall as? HasUIText)?.ui ?: GloryHorn.CallOut.defaultText
|
||||
val colCallText = (roleCalls[BarbRole.ATTACKER]?.toCall as? HasUIText)?.ui ?: GloryHorn.CallOut.defaultText
|
||||
val defCallText = (roleCalls[BarbRole.HEALER]?.toCall as? HasUIText)?.ui ?: GloryHorn.CallOut.defaultText
|
||||
val healCallText = (roleCalls[BarbRole.DEFENDER]?.toCall as? HasUIText)?.ui ?: GloryHorn.CallOut.defaultText
|
||||
|
||||
setInterfaceText(player, atkCallText, Components.BARBASSAULT_HORN_484, GloryHorn.CallOut.attacker)
|
||||
setInterfaceText(player, colCallText, Components.BARBASSAULT_HORN_484, GloryHorn.CallOut.collector)
|
||||
|
|
@ -553,6 +555,30 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
updateRoleUI()
|
||||
}
|
||||
|
||||
fun botMakeCall(bot: Player) {
|
||||
val session = getBASession(bot) ?: return
|
||||
val role = session.team.getRoleForPlayer(bot)
|
||||
|
||||
val calledValue = when (role) {
|
||||
BarbRole.ATTACKER -> session.roleCalls[BarbRole.ATTACKER]?.toCall as? EggColor
|
||||
BarbRole.COLLECTOR -> session.roleCalls[BarbRole.COLLECTOR]?.toCall as? AttackerStyle
|
||||
BarbRole.DEFENDER -> session.roleCalls[BarbRole.DEFENDER]?.toCall as? PoisonFood
|
||||
BarbRole.HEALER -> session.roleCalls[BarbRole.HEALER]?.toCall as? LureFood
|
||||
} ?: return
|
||||
|
||||
session.onHornCall(bot, calledValue)
|
||||
|
||||
val text = when (calledValue) {
|
||||
is EggColor -> calledValue.baCall().text
|
||||
is PoisonFood -> calledValue.baCall().text
|
||||
is LureFood -> calledValue.baCall().text
|
||||
is AttackerStyle -> calledValue.baCall().text
|
||||
else -> return
|
||||
}
|
||||
|
||||
sendChat(bot, text)
|
||||
}
|
||||
|
||||
fun onHornGloryCall(calledValue: Any) {
|
||||
val targetRole = when (calledValue) {
|
||||
is AttackerStyle -> BarbRole.ATTACKER
|
||||
|
|
@ -575,21 +601,26 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
val roleCalls: MutableMap<BarbRole, RoleCall<*>> = mutableMapOf()
|
||||
interface HasUIText { val ui: String }
|
||||
enum class AttackerStyle(val top: String, val bottom: String) : HasUIText {
|
||||
STYLE_1("Controlled/","Bronze/Wind"),
|
||||
STYLE_2("Accurate/","Iron/Water"),
|
||||
STYLE_3("Aggressive/","Steel/Earth"),
|
||||
STYLE_4("Defensive/","Mithril/Fire");
|
||||
STYLE_1("Controlled/","Bronze/Wind"),STYLE_2("Accurate/","Iron/Water"),STYLE_3("Aggressive/","Steel/Earth"),STYLE_4("Defensive/","Mithril/Fire");
|
||||
override val ui: String get() = top
|
||||
fun baCall() = when (this) { STYLE_1 -> BaCall.ATTACKER_STYLE_1; STYLE_2 -> BaCall.ATTACKER_STYLE_2;STYLE_3 -> BaCall.ATTACKER_STYLE_3;STYLE_4 -> BaCall.ATTACKER_STYLE_4
|
||||
}
|
||||
}
|
||||
|
||||
enum class EggColor(override val ui: String): HasUIText { RED("Red Eggs"), GREEN("Green Eggs"),BLUE("Blue Eggs");
|
||||
fun itemId(): Int = when (this) { RED -> Items.RED_EGG_10532; GREEN -> Items.GREEN_EGG_10531; BLUE -> Items.BLUE_EGG_10533 }}
|
||||
fun itemId(): Int = when (this) { RED -> Items.RED_EGG_10532; GREEN -> Items.GREEN_EGG_10531; BLUE -> Items.BLUE_EGG_10533 }
|
||||
fun baCall() = when (this) { RED -> BaCall.COLLECTOR_RED; GREEN -> BaCall.COLLECTOR_GREEN;BLUE -> BaCall.COLLECTOR_BLUE}
|
||||
}
|
||||
|
||||
enum class PoisonFood(override val ui: String): HasUIText { TOFU("Pois. Tofu"), WORMS("Pois. Worms"), MEAT("Pois. Meat");
|
||||
fun itemId(): Int = when (this) { TOFU -> Items.POISONED_TOFU_10539; WORMS -> Items.POISONED_WORMS_10540; MEAT -> Items.POISONED_MEAT_10541 }}
|
||||
fun itemId(): Int = when (this) { TOFU -> Items.POISONED_TOFU_10539; WORMS -> Items.POISONED_WORMS_10540; MEAT -> Items.POISONED_MEAT_10541 }
|
||||
fun baCall() = when (this) { TOFU -> BaCall.HEALER_TOFU; WORMS -> BaCall.HEALER_WORMS; MEAT -> BaCall.HEALER_MEAT}
|
||||
}
|
||||
|
||||
enum class LureFood(override val ui: String) : HasUIText { TOFU("Tofu"), CRACKERS("Crackers"), WORMS("Worms");
|
||||
fun itemId(): Int = when (this) { WORMS -> Items.WORMS_10515; CRACKERS -> Items.CRACKERS_10513; TOFU -> Items.TOFU_10514 }}
|
||||
fun itemId(): Int = when (this) { WORMS -> Items.WORMS_10515; CRACKERS -> Items.CRACKERS_10513; TOFU -> Items.TOFU_10514 }
|
||||
fun baCall() = when (this) { TOFU -> BaCall.DEFENDER_TOFU; CRACKERS -> BaCall.DEFENDER_CRACKERS;WORMS -> BaCall.DEFENDER_WORMS}
|
||||
}
|
||||
|
||||
class AttackerCall( override val required: AttackerStyle ) : RoleCall<AttackerStyle>()
|
||||
class HealerCall( override val required: PoisonFood ) : RoleCall<PoisonFood>()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ 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.AIPlayer
|
||||
import core.game.bots.CombatBotAssembler
|
||||
import core.game.bots.PvMBots
|
||||
import core.game.global.action.EquipHandler
|
||||
|
|
@ -20,12 +21,11 @@ import org.rs09.consts.Scenery
|
|||
class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
||||
|
||||
init {
|
||||
(this as AIPlayer).fullRestore()
|
||||
CombatBotAssembler().gearPCiMeleeBot(this)
|
||||
|
||||
val cape: Item? = equipment.get(1)
|
||||
if (cape != null) {
|
||||
EquipHandler.unequip(this, 1, cape.id)
|
||||
}
|
||||
if (cape != null) { EquipHandler.unequip(this, 1, cape.id)}
|
||||
}
|
||||
|
||||
private val combatHandler = BACombatState(this)
|
||||
|
|
@ -42,9 +42,7 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
|
||||
customState = state.name
|
||||
|
||||
if (moveTimer > 0) {
|
||||
return
|
||||
}
|
||||
if (moveTimer > 0) { return }
|
||||
|
||||
when (state) {
|
||||
State.GET_TO_BA -> getToBA()
|
||||
|
|
@ -57,28 +55,13 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
|
||||
private val state: State
|
||||
get() {
|
||||
|
||||
val session = getBASession(this)
|
||||
|
||||
if (session?.state == BarbassaultState.IN_ARENA) {
|
||||
return State.PLAY_GAME
|
||||
}
|
||||
|
||||
if (QUICK_START.insideBorder(location)) {
|
||||
return State.WAITING_IN_ROOM
|
||||
}
|
||||
if (!isInLobbyOnly(location)) {
|
||||
return State.WAITING_IN_ROOM
|
||||
}
|
||||
|
||||
if (getClosestNodeWithEntry(2, Scenery.DOOR_20209) != null) {
|
||||
return State.ENTER_ROOM
|
||||
}
|
||||
|
||||
if (isInLobbyOnly(location)) {
|
||||
return State.OUTSIDE_ROOM
|
||||
}
|
||||
|
||||
if (session?.state == BarbassaultState.IN_ARENA) { return State.PLAY_GAME }
|
||||
if (QUICK_START.insideBorder(location)) { return State.WAITING_IN_ROOM }
|
||||
if (!isInLobbyOnly(location)) { return State.WAITING_IN_ROOM }
|
||||
if (getClosestNodeWithEntry(2, Scenery.DOOR_20209) != null) { return State.ENTER_ROOM }
|
||||
if (isInLobbyOnly(location)) { return State.OUTSIDE_ROOM }
|
||||
return State.GET_TO_BA
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +84,7 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
|
||||
forceMove(this,location,location.transform(0, -1, 0),25,60,null,819) {
|
||||
addToQueue(this, null)
|
||||
combatHandler.walkToIterator(QUICK_START.randomWalkableLoc)
|
||||
combatHandler.walkTo(QUICK_START.randomWalkableLoc)
|
||||
}
|
||||
|
||||
moveTimer = 4
|
||||
|
|
|
|||
|
|
@ -3,72 +3,95 @@ 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.api.sendChat
|
||||
import core.game.interaction.MovementPulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.map.path.Pathfinder
|
||||
import core.tools.RandomFunction
|
||||
import core.game.world.GameWorld
|
||||
import java.util.*
|
||||
import kotlin.random.Random
|
||||
|
||||
class BACombatState(private val bot: BABot) {
|
||||
|
||||
class BACombatState(val bot: BABot) {
|
||||
private val Random = Random()
|
||||
private val krng = kotlin.random.Random.Default
|
||||
val randomtype = Random().nextInt(100)
|
||||
|
||||
private val rng = Random.Default
|
||||
|
||||
fun fightNPCs() {
|
||||
bot.customState = "Fight NPCs"
|
||||
bot.AttackNpcsInRadius(25)
|
||||
}
|
||||
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() {
|
||||
bot.customState = "Healer Idling"
|
||||
//bot.AttackNpcsInRadius(25)
|
||||
|
||||
}
|
||||
|
||||
fun chatter() {
|
||||
bot.sendChat("LETS GOO!")
|
||||
if (krng.nextInt(12) != 0) return
|
||||
fun handleDefender() {
|
||||
|
||||
bot.customState = "Lure Runners"
|
||||
|
||||
val session = getBASession(bot) ?: return
|
||||
|
||||
randomWalk(session.region.borders.randomWalkableLoc, 3)
|
||||
}
|
||||
|
||||
fun handleCollector() {
|
||||
|
||||
bot.customState = "Collecting Eggs"
|
||||
|
||||
val session = getBASession(bot) ?: return
|
||||
|
||||
randomWalk(session.region.borders.randomWalkableLoc, 3)
|
||||
}
|
||||
|
||||
fun handleHealer() {
|
||||
|
||||
bot.customState = "Healing"
|
||||
|
||||
val session = getBASession(bot) ?: return
|
||||
|
||||
randomWalk(session.region.borders.randomWalkableLoc, 2)
|
||||
}
|
||||
|
||||
fun chatter() {
|
||||
if (rng.nextInt(12) != 0) { return }
|
||||
val role = getBARoleForPlayer(bot)
|
||||
val messages = when (role) {
|
||||
BarbRole.ATTACKER -> listOf("Call pls", "Wrong style?", "Attacking!")
|
||||
BarbRole.HEALER -> listOf("Need poison", "Healing!", "Healer here","Call pls")
|
||||
BarbRole.DEFENDER -> listOf("Dropping food", "Come here runners","Call pls")
|
||||
BarbRole.COLLECTOR -> listOf("Eggs!", "Wrong egg?","Call pls")
|
||||
else -> listOf("Lag...", "Nice", "Oops")
|
||||
BarbRole.ATTACKER -> listOf("Call pls","Wrong style?","Attacking!")
|
||||
BarbRole.HEALER -> listOf("Need poison","Healing!","Healer here","Call pls")
|
||||
BarbRole.DEFENDER -> listOf("Dropping food","Come here runners","Call pls")
|
||||
BarbRole.COLLECTOR -> listOf("Eggs!","Wrong egg?","Call pls")
|
||||
else -> listOf("Lag...","Nice","Oops")
|
||||
}
|
||||
bot.sendChat(messages.random(krng))
|
||||
|
||||
bot.sendChat(messages.random(rng))
|
||||
}
|
||||
|
||||
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 randomWalk(center: Location, radius: Int) {
|
||||
|
||||
if (bot.walkingQueue.isMoving) {
|
||||
return
|
||||
}
|
||||
|
||||
val destination = center.transform(
|
||||
RandomFunction.random(-radius, radius),
|
||||
RandomFunction.random(-radius, radius),
|
||||
0
|
||||
)
|
||||
|
||||
walkTo(destination)
|
||||
}
|
||||
|
||||
fun walkToIterator(loc: Location){
|
||||
var diffX = loc.x - bot.location.x
|
||||
var diffY = loc.y - bot.location.y
|
||||
fun walkTo(destination: Location) {
|
||||
|
||||
GameWorld.Pulser.submit(object : MovementPulse(bot, bot.location.transform(diffX, diffY, 0), Pathfinder.SMART) {
|
||||
override fun pulse(): Boolean {
|
||||
return true
|
||||
val diffX = destination.x - bot.location.x
|
||||
val diffY = destination.y - bot.location.y
|
||||
|
||||
GameWorld.Pulser.submit(
|
||||
object : MovementPulse(
|
||||
bot,
|
||||
bot.location.transform(diffX, diffY, 0),
|
||||
Pathfinder.SMART
|
||||
) {
|
||||
override fun pulse(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue