work towards solving "Error loading content: HornListeners"

This commit is contained in:
Tooze 2026-01-28 23:21:25 -05:00
parent e179c3eabb
commit 1213f1683f
2 changed files with 69 additions and 145 deletions

View file

@ -10,9 +10,10 @@ import core.game.node.entity.player.Player
import org.rs09.consts.Items
class BaHornSystem : InteractionListener {
val ATTACKER_HORNS = intArrayOf(Items.ATTACKER_HORN_10516,Items.ATTACKER_HORN_10517,Items.ATTACKER_HORN_10518,Items.ATTACKER_HORN_10519,Items.ATTACKER_HORN_10520)
val HEALER_HORNS = intArrayOf(Items.HEALER_HORN_10526,Items.HEALER_HORN_10527,Items.HEALER_HORN_10528,Items.HEALER_HORN_10529,Items.HEALER_HORN_10530 )
val ALL_HORNS = intArrayOf(Items.COLLECTOR_HORN_10560,Items.DEFENDER_HORN_10538) + HEALER_HORNS + ATTACKER_HORNS
private val ATTACKER_HORNS = intArrayOf( Items.ATTACKER_HORN_10516, Items.ATTACKER_HORN_10517, Items.ATTACKER_HORN_10518, Items.ATTACKER_HORN_10519, Items.ATTACKER_HORN_10520 )
private val HEALER_HORNS = intArrayOf( Items.HEALER_HORN_10526, Items.HEALER_HORN_10527, Items.HEALER_HORN_10528, Items.HEALER_HORN_10529, Items.HEALER_HORN_10530 )
private val ALL_HORNS = intArrayOf( Items.COLLECTOR_HORN_10560, Items.DEFENDER_HORN_10538 ) + HEALER_HORNS + ATTACKER_HORNS
enum class BaCall(val text: String) {
COLLECTOR_RED("Collector: Red Eggs!"),
@ -35,105 +36,70 @@ class BaHornSystem : InteractionListener {
}
override fun defineListeners() {
on(ALL_HORNS, IntType.ITEM, "Medic") { player, _ ->
sendChat(player,BaCall.MEDIC.text)
//pretty sure there is an emote with this (wave hand, panic face?)
player.baSession?.alertHealers(player)
return@on true
on(ALL_HORNS, IntType.ITEM, "Drop") { player, _ -> sendMessage(player, "I need that!"); false }
on(Items.DEFENDER_HORN_10538, IntType.ITEM, "Tell-tofu", "Tell-worms", "Tell-meat") { player, _ ->
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
val defenderMap = mapOf(
"tell-tofu" to (BarbassaultSession.PoisonFood.TOFU to BaCall.HEALER_TOFU),
"tell-worms" to (BarbassaultSession.PoisonFood.WORMS to BaCall.HEALER_WORMS),
"tell-meat" to (BarbassaultSession.PoisonFood.MEAT to BaCall.HEALER_MEAT)
)
val pair = defenderMap[optionClicked] ?: return@on false
val food = pair.first
val call = pair.second
sendChat(player, call.text)
player.baSession?.onHornCall(player, food)
true
}
on(ALL_HORNS, IntType.ITEM, "Drop") { player, _ ->
sendMessage(player,"I need that!") // not authentic
return@on false
on(ALL_HORNS, IntType.ITEM, "Tell-style1", "Tell-style2", "Tell-style3", "Tell-style4","Tell-red", "Tell-green", "Tell-blue", "Medic") { player, _ ->
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
val styleCallMap = mapOf(
"tell-style1" to (BarbassaultSession.AttackerStyle.STYLE_1 to BaCall.ATTACKER_STYLE_1),
"tell-style2" to (BarbassaultSession.AttackerStyle.STYLE_2 to BaCall.ATTACKER_STYLE_2),
"tell-style3" to (BarbassaultSession.AttackerStyle.STYLE_3 to BaCall.ATTACKER_STYLE_3),
"tell-style4" to (BarbassaultSession.AttackerStyle.STYLE_4 to BaCall.ATTACKER_STYLE_4),
"tell-red" to (BarbassaultSession.EggColor.RED to BaCall.COLLECTOR_RED),
"tell-green" to (BarbassaultSession.EggColor.GREEN to BaCall.COLLECTOR_GREEN),
"tell-blue" to (BarbassaultSession.EggColor.BLUE to BaCall.COLLECTOR_BLUE),
"medic" to (null to BaCall.MEDIC) )
val pair = styleCallMap[optionClicked] ?: return@on false
val styleOrColor = pair.first
val call = pair.second
sendChat(player, call.text)
when (styleOrColor) {
is BarbassaultSession.AttackerStyle -> player.baSession?.onHornCall(player, styleOrColor)
is BarbassaultSession.EggColor -> player.baSession?.onHornCall(player, styleOrColor)
null -> player.baSession?.alertHealers(player)
}
true
}
//ATTACKER
on(ATTACKER_HORNS, IntType.ITEM, "Tell-red") { player, _ ->
sendChat(player,BaCall.COLLECTOR_RED.text)
player.baSession?.onHornCall(player,BarbassaultSession.EggColor.RED)
//player.baSession.team.broadcastColl(red)
return@on true
}
on(ATTACKER_HORNS, IntType.ITEM, "Tell-green") { player, _ ->
sendChat(player,BaCall.COLLECTOR_GREEN.text)
player.baSession?.onHornCall(player,BarbassaultSession.EggColor.GREEN)
//player.baSession.team.broadcastColl(green)
return@on true
}
on(ATTACKER_HORNS, IntType.ITEM, "Tell-blue") { player, _ ->
sendChat(player,BaCall.COLLECTOR_BLUE.text)
player.baSession?.onHornCall(player,BarbassaultSession.EggColor.BLUE)
//player.baSession.team.broadcastColl(blue)
return@on true
}
//DEFENDER
on(Items.DEFENDER_HORN_10538, IntType.ITEM, "Tell-tofu") { player, _ ->
sendChat(player,BaCall.HEALER_TOFU.text)
player.baSession?.onHornCall(player,BarbassaultSession.PoisonFood.TOFU)
//player.baSession.team.broadcastDef(tofu)
return@on true
}
on(Items.DEFENDER_HORN_10538, IntType.ITEM, "Tell-worms") { player, _ ->
sendChat(player,BaCall.HEALER_WORMS.text)
player.baSession?.onHornCall(player,BarbassaultSession.PoisonFood.WORMS)
//player.baSession.team.broadcastDef(worms)
return@on true
}
on(Items.DEFENDER_HORN_10538, IntType.ITEM, "Tell-meat") { player, _ ->
sendChat(player,BaCall.HEALER_MEAT.text)
player.baSession?.onHornCall(player,BarbassaultSession.PoisonFood.MEAT)
//player.baSession.team.broadcastDef(meat)
return@on true
}
//COLLECTOR
on(Items.COLLECTOR_HORN_10560, IntType.ITEM, "Tell-style1") { player, _ ->
sendChat(player,BaCall.ATTACKER_STYLE_1.text)
player.baSession?.onHornCall(player,BarbassaultSession.AttackerStyle.STYLE_1)
return@on true
}
on(Items.COLLECTOR_HORN_10560, IntType.ITEM, "Tell-style2") { player, _ ->
sendChat(player,BaCall.ATTACKER_STYLE_2.text)
player.baSession?.onHornCall(player, BarbassaultSession.AttackerStyle.STYLE_2)
return@on true
}
on(Items.COLLECTOR_HORN_10560, IntType.ITEM, "Tell-style3") { player, _ ->
sendChat(player,BaCall.ATTACKER_STYLE_3.text)
player.baSession?.onHornCall(player,BarbassaultSession.AttackerStyle.STYLE_3)
return@on true
}
on(Items.COLLECTOR_HORN_10560, IntType.ITEM, "Tell-style4") { player, _ ->
sendChat(player,BaCall.ATTACKER_STYLE_4.text)
player.baSession?.onHornCall(player,BarbassaultSession.AttackerStyle.STYLE_4)
return@on true
}
//HEALER
on(HEALER_HORNS, IntType.ITEM, "Tell-tofu") { player, _ ->
sendChat(player,BaCall.DEFENDER_TOFU.text)
player.baSession?.onHornCall(player, BarbassaultSession.LureFood.TOFU)
return@on true
}
on(HEALER_HORNS, IntType.ITEM, "Tell-crackers") { player, _ ->
sendChat(player,BaCall.DEFENDER_CRACKERS.text)
player.baSession?.onHornCall(player, BarbassaultSession.LureFood.CRACKERS)
return@on true
}
on(HEALER_HORNS, IntType.ITEM, "tell-worms") { player, _ ->
sendChat(player,BaCall.DEFENDER_WORMS.text)
player.baSession?.onHornCall(player, BarbassaultSession.LureFood.WORMS)
return@on true
on(HEALER_HORNS, IntType.ITEM, "Tell-tofu", "Tell-crackers", "Tell-worms") { player, _ ->
val lureMap = mapOf(
"tell-tofu" to (BarbassaultSession.LureFood.TOFU to BaCall.DEFENDER_TOFU),
"tell-crackers" to (BarbassaultSession.LureFood.CRACKERS to BaCall.DEFENDER_CRACKERS),
"tell-worms" to (BarbassaultSession.LureFood.WORMS to BaCall.DEFENDER_WORMS)
)
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
val pair = lureMap[optionClicked] ?: return@on false
val lure = pair.first
val call = pair.second
sendChat(player, call.text)
player.baSession?.onHornCall(player, lure)
true
}
}
object HornHelper {
fun getAttackerHorn(player: Player): AttackerHorn? {
return AttackerHorn.values().firstOrNull { inInventory(player, it.itemId) }
}
fun getHealerHorn(player: Player): HealerHorn? {
return HealerHorn.values().firstOrNull { inInventory(player, it.itemId) }
}
fun getCollectorBag(player: Player): CollectionBag? {
return CollectionBag.values().firstOrNull { inInventory(player, it.itemId) }
}
fun getAttackerHorn(player: Player): AttackerHorn? = AttackerHorn.values().firstOrNull { inInventory(player, it.itemId) }
fun getHealerHorn(player: Player): HealerHorn? = HealerHorn.values().firstOrNull { inInventory(player, it.itemId) }
fun getCollectorBag(player: Player): CollectionBag? = CollectionBag.values().firstOrNull { inInventory(player, it.itemId) }
}
enum class AttackerHorn(val itemId: Int) {
LEVEL_ONE(Items.ATTACKER_HORN_10516),
LEVEL_TWO(Items.ATTACKER_HORN_10517),
@ -146,18 +112,20 @@ class BaHornSystem : InteractionListener {
fun fromId(id: Int): AttackerHorn? = map[id]
}
}
enum class HealerHorn(val itemId: Int, val healAmount: Int) {
LEVEL_ONE(Items.HEALER_HORN_10526, 5), // energy 20%
LEVEL_TWO(Items.HEALER_HORN_10527, 15), // energy 25%
LEVEL_THREE(Items.HEALER_HORN_10528, 20),// energy 30%
LEVEL_FOUR(Items.HEALER_HORN_10529, 25), // energy 35%
LEVEL_FIVE(Items.HEALER_HORN_10530, 35); // energy 40%
LEVEL_ONE(Items.HEALER_HORN_10526, 5),
LEVEL_TWO(Items.HEALER_HORN_10527, 15),
LEVEL_THREE(Items.HEALER_HORN_10528, 20),
LEVEL_FOUR(Items.HEALER_HORN_10529, 25),
LEVEL_FIVE(Items.HEALER_HORN_10530, 35);
companion object {
private val map = values().associateBy(HealerHorn::itemId)
fun fromId(id: Int): HealerHorn? = map[id]
}
}
enum class CollectionBag(val itemId: Int) {
LEVEL_ONE(Items.COLLECTION_BAG_10521),
LEVEL_TWO(Items.COLLECTION_BAG_10522),

View file

@ -1,44 +0,0 @@
package content.minigame.barbassault.arena
import core.api.MapArea
import core.api.getRegionBorders
import core.game.node.entity.player.Player
import core.game.world.map.build.DynamicRegion
import core.game.world.map.zone.ZoneBorders
import core.game.world.map.zone.ZoneRestriction
class BarbassaultArena(
private val session: BarbassaultSession
) : MapArea {
private lateinit var region: DynamicRegion
fun create() {
region = DynamicRegion.create(BarbassaultGameArea.BA_ARENA.MAIN)
//zone.register(*defineAreaBorders())
}
fun spawnPlayers(players: List<Player>) {
val base = region.baseLocation
players.forEach {
it.properties.teleportLocation =
base.transform(36, 24, 0)
}
}
fun destroy() {
//zone.unregister(*defineAreaBorders())
region.clear()
}
override fun defineAreaBorders(): Array<ZoneBorders> =
arrayOf(getRegionBorders(7509))
override fun getRestrictions(): Array<ZoneRestriction> =
arrayOf(
ZoneRestriction.CANNON,
ZoneRestriction.FIRES,
ZoneRestriction.RANDOM_EVENTS,
ZoneRestriction.TELEPORT
)
}