mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 10:25:13 -06:00
BA AttackBots more responsive to killing creatures.
This commit is contained in:
parent
c5f6f3a5cb
commit
b72df6c1f7
6 changed files with 73 additions and 20 deletions
|
|
@ -61,6 +61,7 @@ open class BAActivity : ActivityPlugin("barbassault",false, true, true,ZoneRestr
|
|||
}
|
||||
if (e is NPC) {
|
||||
// dropPenanceEggCluster(e)
|
||||
session.sessionNpcs.remove(e)
|
||||
session.pennanceClearedMessage(e)
|
||||
}
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import content.minigame.barbassault.setBASession
|
|||
import core.api.*
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.equipment.WeaponInterface
|
||||
import core.game.node.entity.combat.equipment.WeaponInterface.STYLE_ACCURATE
|
||||
import core.game.node.entity.combat.equipment.WeaponInterface.STYLE_AGGRESSIVE
|
||||
import core.game.node.entity.combat.equipment.WeaponInterface.STYLE_CONTROLLED
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
package content.minigame.barbassault.arenas.monsters
|
||||
|
||||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.arena.BarbAssEvent
|
||||
import content.minigame.barbassault.arena.BACombatValidation
|
||||
import content.minigame.barbassault.arena.BarbAssEvent
|
||||
import content.minigame.barbassault.arena.PenanceType
|
||||
import content.minigame.barbassault.arena.npcs.dropPenanceEggCluster
|
||||
import content.minigame.barbassault.getBASession
|
||||
import core.api.*
|
||||
import core.api.EquipmentSlot
|
||||
import core.api.getItemFromEquipment
|
||||
import core.api.sendMessage
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.BattleState
|
||||
import core.game.node.entity.combat.CombatStyle
|
||||
|
|
@ -57,13 +58,13 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
|
|||
self.isWalks = true
|
||||
self.properties.isNPCWalkable = false
|
||||
self.walkRadius = 24
|
||||
self.isAggressive = true
|
||||
self.isRespawn = false
|
||||
|
||||
self.setAttribute("barbass-type", PenanceType.FIGHTER)
|
||||
|
||||
self.definition.combatDistance = 1
|
||||
self.properties.combatPulse.style = CombatStyle.MELEE
|
||||
self.isAggressive = true
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +74,7 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
|
|||
|
||||
dropPenanceEggCluster(killer,self)
|
||||
session.eventBus.emit(BarbAssEvent.NPCDied(self,player))
|
||||
|
||||
killer.removeAttribute("combat-time")
|
||||
super.onDeathFinished(self, killer)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ class PenanceRangerNPC : NPCBehavior(*PENANCE_RANGER_IDS.toIntArray()) {
|
|||
self.isWalks = true
|
||||
self.isNeverWalks = false
|
||||
self.walkRadius = 24
|
||||
self.isAggressive = true
|
||||
self.isRespawn = false
|
||||
self.definition.combatGraphics[1] = Graphics(866, 25, 0)
|
||||
self.setAttribute("barbass-type", PenanceType.RANGER)
|
||||
|
|
@ -60,13 +59,14 @@ class PenanceRangerNPC : NPCBehavior(*PENANCE_RANGER_IDS.toIntArray()) {
|
|||
|
||||
self.definition.combatDistance = 8
|
||||
self.properties.combatPulse.style = CombatStyle.RANGE
|
||||
self.isAggressive = true
|
||||
}
|
||||
|
||||
override fun onDeathFinished(self: NPC, killer: Entity) {
|
||||
super.onDeathFinished(self, killer)
|
||||
val player = killer as? Player ?: return
|
||||
val session = getBASession(killer) ?: return
|
||||
|
||||
killer.removeAttribute("combat-time")
|
||||
dropPenanceEggCluster(killer,self)
|
||||
session.eventBus.emit(BarbAssEvent.NPCDied(self,player))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,18 @@ 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.api.log
|
||||
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
|
||||
|
||||
class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
||||
|
|
@ -25,7 +31,9 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
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,7 +50,9 @@ 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,11 +67,19 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
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 (getClosestNodeWithEntry(2, Scenery.DOOR_20209) != null) {
|
||||
return State.ENTER_ROOM
|
||||
}
|
||||
if (isInLobbyOnly(location)) {
|
||||
return State.OUTSIDE_ROOM
|
||||
}
|
||||
return State.GET_TO_BA
|
||||
}
|
||||
|
||||
|
|
@ -71,18 +89,18 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
}
|
||||
|
||||
private fun outsideRoom() {
|
||||
val quickDoor = getClosestNodeWithEntry(60, Scenery.DOOR_20209)?: return
|
||||
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
|
||||
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) {
|
||||
forceMove(this, location, location.transform(0, -1, 0), 25, 60, null, 819) {
|
||||
addToQueue(this, null)
|
||||
combatHandler.walkTo(QUICK_START.randomWalkableLoc)
|
||||
}
|
||||
|
|
@ -108,8 +126,42 @@ class BABot(l: Location) : PvMBots(legitimizeLocation(l)) {
|
|||
|
||||
fun isInLobbyOnly(location: Location): Boolean {
|
||||
return getRegionBorders(10322).insideBorder(location)
|
||||
&& waveLobbies.none {it != MAIN_LOBBY && it.insideBorder(location)
|
||||
&& waveLobbies.none {
|
||||
it != MAIN_LOBBY
|
||||
&& it != QUICK_START
|
||||
&& it.insideBorder(location)
|
||||
}
|
||||
}
|
||||
|
||||
fun debugthis(info : Any) {
|
||||
log(this.javaClass, Log.FINE,state.toString())
|
||||
}
|
||||
|
||||
override fun AttackNpcsInRadius(bot: Player, radius: Int): Boolean {
|
||||
if (bot.inCombat()) return true
|
||||
|
||||
val creatures = FindTargets(bot, radius)
|
||||
if (creatures.isEmpty()) return false
|
||||
|
||||
for (npc in creatures) {
|
||||
if (!npc.inCombat()) {
|
||||
bot.attack(npc)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun FindTargets(entity: Entity, radius: Int): MutableList<Entity> {
|
||||
val localNPCs = getBASession(entity)?.sessionNpcs ?: return mutableListOf()
|
||||
|
||||
return localNPCs
|
||||
.asSequence()
|
||||
.filter(::checkValidTargets)
|
||||
.sortedBy { it.location.getDistance(entity.location) }
|
||||
.take(5)
|
||||
.toMutableList()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class BACombatState(private val bot: BABot) {
|
|||
|
||||
fun fightNPCs() {
|
||||
bot.customState = "Fight NPCs"
|
||||
bot.AttackNpcsInRadius(25)
|
||||
bot.AttackNpcsInRadius(bot,25)
|
||||
//use Called AttackStyle
|
||||
val baSession = getBASession(bot) ?: return
|
||||
val called = (baSession.roleCalls[BarbRole.ATTACKER]?.called ?: AttackerStyle.values().random() ) as AttackerStyle
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue