mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-22 19:05:11 -06:00
::babot - Spawns a bot who enters QuickStart as ANY role.
This commit is contained in:
parent
6498d1874e
commit
08b96c3ce2
4 changed files with 205 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
147
Server/src/main/content/minigame/barbassault/bots/BarbassBot.kt
Normal file
147
Server/src/main/content/minigame/barbassault/bots/BarbassBot.kt
Normal file
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -86,13 +86,16 @@ open class BarbassLobbyActivity : ActivityPlugin("BarbassLobby",false, false, tr
|
|||
}
|
||||
|
||||
private fun createQuickTeam(players: List<WaitingPlayer>) {
|
||||
// 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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue