Adventure bot improvements

Adjusted max pulse count for bots from 50 -> 75
Adjusted max skill baseline by +4 for adventure bots to 69
Added 500 lines of unique
Added 45000 bot names
Added recovery methods for bots that get stuck
Added multiple random number functions to help add more variance
Added function to handle checking if a bot is near/in a Bank
Added function to handle getting a new city
Added function to add variability to locations given to bots
Added function to check if other players/bots are nearby
Added function to handle bots banking their inventories if a bank booth is nearby
Improved random number parameters
Improved how bots are spawned & added variance to spawn location
Improved how bots interact & handle the Grand Exchange location
Improved how bots handle starting in Lumbridge
Fixed bots referencing themselves in dialogue
Fixed bots talking when they are by themselves
Fixed multiple cases where bots would get stuck in a state
Fixed multiple logic errors
Fixed issues with bots banking but not switching states
This commit is contained in:
Player Name
2024-10-10 07:08:57 +00:00
committed by Ryan
parent 034c05f512
commit 59075798ea
7 changed files with 33854 additions and 270 deletions
@@ -53,7 +53,7 @@ class CombatBotAssembler {
val bot = CombatBot(location)
generateStats(bot, tier, Skills.RANGE, Skills.DEFENCE)
gearRangedBot(bot, crossbow ?: Random().nextInt() % 2 == 0)
gearRangedBot(bot, (crossbow ?: (Random().nextInt() % 2)) == 0)
return bot
}
@@ -82,7 +82,7 @@ class CombatBotAssembler {
fun MeleeAdventurer(tier: Tier, location: Location): CombatBot {
val bot = CombatBot(location)
var max = 0
val level = RandomFunction.random(25, 65).also {max = 99 }
val level = RandomFunction.random(25, 69).also {max = 99 }
generateStats(bot,tier,Skills.ATTACK, Skills.STRENGTH, Skills.DEFENCE)
bot.skills.setStaticLevel(Skills.HITPOINTS, level)
bot.skills.setStaticLevel(Skills.ATTACK, level + 5)
@@ -114,7 +114,7 @@ class CombatBotAssembler {
fun RangeAdventurer(tier: Tier, location: Location): CombatBot {
val bot = CombatBot(location)
var max = 0
val level = RandomFunction.random(35, 65).also {max = 75 }
val level = RandomFunction.random(35, 69).also {max = 75 }
generateStats(bot,tier,Skills.ATTACK, Skills.STRENGTH)
bot.skills.setStaticLevel(Skills.HITPOINTS, level)
bot.skills.setStaticLevel(Skills.DEFENCE, level)
@@ -98,7 +98,7 @@ class GeneralBotCreator {
}*/
if(!botScript.running) return true //has to be separated this way or it double-submits the respawn pulse.
if (botPulsesTriggeredThisTick++ >= 50)
if (botPulsesTriggeredThisTick++ >= 75)
return false
val idleRoll = RandomFunction.random(10)
+45 -2
View File
@@ -54,6 +54,7 @@ import kotlin.math.pow
import kotlin.math.sqrt
import core.ServerConstants
import core.api.utils.Vector
import kotlin.random.Random
class ScriptAPI(private val bot: Player) {
val GRAPHICSUP = Graphics(1576)
@@ -396,6 +397,20 @@ class ScriptAPI(private val bot: Player) {
}
}
/**
* @param location the location you want the coordinates randomized for.
* @param xMin the minimum range value X coordinates should be randomized by, must be xMin <= xMax ex: -1 min 1 max.
* @param xMax the maximum range value X coordinates should be randomized by, must be xMin <= xMax ex: -1 min 1 max.
* @param yMin the minimum range value Y coordinates should be randomized by, must be yMin <= yMax ex: -1 min 1 max.
* @param yMax the maximum range value Y coordinates should be randomized by, must be yMin <= yMax ex: -1 min 1 max.
* @param staticZ this value is static and does not change from what is given, must be actual Z value of location.
* @author Kermit
*/
fun randomizeLocationInRanges(location: Location, xMin: Int, xMax: Int, yMin: Int, yMax: Int, staticZ: Int): Location {
val newX = location.x + Random.nextInt(xMin, xMax)
val newY = location.y + Random.nextInt(yMin, yMax)
return Location(newX, newY, staticZ)
}
/**
* The iterator for long-distance walking. Limited by doors and large obstacles like mountains.
@@ -553,7 +568,7 @@ class ScriptAPI(private val bot: Player) {
1517 -> continue
1519 -> continue
1521 -> continue
else -> Repository.sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE.")
else -> sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.lowercase() + " on the GE.")
}
}
bot.bank.remove(item)
@@ -562,7 +577,35 @@ class ScriptAPI(private val bot: Player) {
return true
}
}
bot.pulseManager.run(toCounterPulseAll())
if (ge != null) {
bot.pulseManager.run(toCounterPulseAll())
}
}
/**
* Function to bank all items that are not excluded at a nearby bank.
* @author Kermit & Ceikry
*/
fun depositAtBank(){
val bank: Scenery? = getNearestNode("Bank booth", true) as Scenery?
class BankingPulse : MovementPulse(bot, bank, DestinationFlag.OBJECT) {
override fun pulse(): Boolean {
bot.faceLocation(bank?.location)
for (item in bot.inventory.toArray()) {
item ?: continue
when (item.id) {
Items.RUNE_AXE_1359, Items.TINDERBOX_590, Items.ADAMANT_PICKAXE_1271, Items.COINS_995 -> continue
}
bot.bank.add(item)
bot.inventory.remove(item)
}
// log(this::class.java, Log.FINE, "${bot.username} Just finished banking at ${bot.location} || Bank contents: ${bot.bank}")
return true
}
}
if (bank != null) {
bot.pulseManager.run(BankingPulse())
}
}
/**
+22 -12
View File
@@ -11,6 +11,7 @@ import core.game.bots.SkillingBotAssembler
import java.util.Timer
import java.util.concurrent.Executors
import kotlin.concurrent.schedule
import kotlin.random.Random
class ImmerseWorld : StartupListener {
@@ -24,6 +25,12 @@ class ImmerseWorld : StartupListener {
var assembler = CombatBotAssembler()
var skillingBotAssembler = SkillingBotAssembler()
private fun randomizeLocationInRanges(location: Location, xMin: Int, xMax: Int, yMin: Int, yMax: Int): Location {
val newX = location.x + Random.nextInt(xMin, xMax)
val newY = location.y + Random.nextInt(yMin, yMax)
return Location(newX, newY, 0)
}
fun spawnBots()
{
if(GameWorld.settings!!.enable_bots)
@@ -43,10 +50,10 @@ class ImmerseWorld : StartupListener {
}
}
fun immerseAdventurer() {
for (i in 0..(GameWorld.settings?.max_adv_bots ?: 50)) {
var random: Long = (10000..300000).random().toLong()
Timer().schedule(random) {
fun immerseAdventurer(){
for (i in 0..(GameWorld.settings?.max_adv_bots ?: 50)){
var random = Random.nextInt(20000, 400000).toLong()
Timer().schedule(random){
spawn_adventurers()
}
}
@@ -55,14 +62,17 @@ class ImmerseWorld : StartupListener {
fun spawn_adventurers() {
val lumbridge = Location.create(3221, 3219, 0)
val tiers = listOf<CombatBotAssembler.Tier>(CombatBotAssembler.Tier.LOW, CombatBotAssembler.Tier.MED)
GeneralBotCreator(
Adventurer(CombatStyle.MELEE),
assembler.MeleeAdventurer(tiers.random(), lumbridge)
)
GeneralBotCreator(
Adventurer(CombatStyle.RANGE),
assembler.RangeAdventurer(tiers.random(), lumbridge)
)
if (Random.nextBoolean()) {
GeneralBotCreator(
Adventurer(CombatStyle.MELEE),
assembler.MeleeAdventurer(tiers.random(), randomizeLocationInRanges(lumbridge,-1,1,-1,1))
)
} else {
GeneralBotCreator(
Adventurer(CombatStyle.RANGE),
assembler.RangeAdventurer(tiers.random(), randomizeLocationInRanges(lumbridge,-1,1,-1,1))
)
}
}
fun immerseFishingGuild() {