HornListener complaint errors gone!

This commit is contained in:
Tooze 2026-01-29 16:14:12 -05:00
parent 1213f1683f
commit 0d157b39dd
5 changed files with 73 additions and 35 deletions

View file

@ -13,7 +13,7 @@ class BaHornSystem : InteractionListener {
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
// 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!"),
@ -36,65 +36,99 @@ class BaHornSystem : InteractionListener {
}
override fun defineListeners() {
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, _ ->
on(Items.DEFENDER_HORN_10538, IntType.ITEM, "Tell-tofu", "Tell-worms", "Tell-meat","Medic", "Drop") { player, _ ->
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
if (optionClicked == "drop") { sendMessage(player, "I need that!"); 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)
)
"tell-meat" to (BarbassaultSession.PoisonFood.MEAT to BaCall.HEALER_MEAT),
"medic" to (null to BaCall.MEDIC) )
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, "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)
when (food) {
is BarbassaultSession.PoisonFood -> player.baSession?.onHornCall(player, food)
null -> player.baSession?.alertHealers(player)
}
true
}
on(HEALER_HORNS, IntType.ITEM, "Tell-tofu", "Tell-crackers", "Tell-worms") { player, _ ->
on(Items.COLLECTOR_HORN_10560, IntType.ITEM, "Tell-style1", "Tell-style2", "Tell-style3", "Tell-style4","Medic" , "Drop") { player, _ ->
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
if (optionClicked == "drop") { sendMessage(player, "I need that!"); 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),
"medic" to (null to BaCall.MEDIC) )
val pair = styleCallMap[optionClicked] ?: return@on false
val style = pair.first
val call = pair.second
sendChat(player, call.text)
when (style) {
is BarbassaultSession.AttackerStyle -> player.baSession?.onHornCall(player, style)
null-> player.baSession?.alertHealers(player)
}
true
}
on(ATTACKER_HORNS, IntType.ITEM, "Tell-red", "Tell-green", "Tell-blue", "Medic", "Drop") { player, _ ->
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
if (optionClicked == "drop") { sendMessage(player, "I need that!"); return@on false }
val collectorMap = mapOf(
"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 = collectorMap[optionClicked] ?: return@on false
val color = pair.first
val call = pair.second
sendChat(player, call.text)
when (color) {
is BarbassaultSession.EggColor -> player.baSession?.onHornCall(player, color)
null -> player.baSession?.alertHealers(player)
}
true
}
on(HEALER_HORNS, IntType.ITEM, "Tell-tofu", "Tell-crackers", "Tell-worms","Medic", "Drop") { player, _ ->
val optionClicked = player.getAttribute<String>("interact:option")?.lowercase() ?: return@on false
if (optionClicked == "drop") { sendMessage(player, "I need that!"); return@on false }
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
"tell-worms" to (BarbassaultSession.LureFood.WORMS to BaCall.DEFENDER_WORMS),
"medic" to (null to BaCall.MEDIC) )
val pair = lureMap[optionClicked] ?: return@on false
val lure = pair.first
val call = pair.second
sendChat(player, call.text)
player.baSession?.onHornCall(player, lure)
when (lure) {
is BarbassaultSession.LureFood -> player.baSession?.onHornCall(player, lure)
null -> player.baSession?.alertHealers(player)
}
true
}
}
object HornHelper {
//I should set a value in my players session instead of scanning the inventory every time for a horn.
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) }

View file

@ -22,6 +22,7 @@ class WaveCompleteInterface {
advance break down -->
https://youtu.be/OjkLXOQVWEQ?t=113
https://www.youtube.com/watch?v=gpSmUZcaMwY

View file

@ -35,6 +35,7 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
}
override fun beforeDamageReceived(self: NPC, attacker: Entity, state: BattleState) {
val firstBefore = state.estimatedHit
//I should set a value in my players session instead of scanning the inventory every time for a horn.
state.estimatedHit = firstBefore + (BaHornSystem.HornHelper.getAttackerHorn(attacker as Player)?.ordinal?.plus(1) ?: 0) +1
}

View file

@ -166,6 +166,8 @@ class BarbassaultLobby : InteractionListener, MapArea {
}
on(Scenery.SCROLL_TABLE_20149, IntType.SCENERY, "Take-from") { player, _ ->
//https://www.youtube.com/watch?v=bFw2os1aRvk
// okay we dont create a session untill we write our name on the scroll.
if(!player.inventory.containsItem(Item(Items.SCROLL_10512, 1)) ) {
//do you wish to take a scroll? yes ? no
sendDialogueOptions(player, "Take a recruitment scroll?", "Yes", "No")

View file

@ -30,8 +30,8 @@ class CurrentTeamInterface : ComponentPlugin() {
super.open(player, component)
player ?: return
if(player.inventory.containsItem(Item(Items.SCROLL_10512, 1)) ) {
setInterfaceText(player, player.username, CurrentTeam.ID, CurrentTeam.team[0].name)
//the leader might be able to take scroll between rooms? need Proof
// setInterfaceText(player, player.username, CurrentTeam.ID, CurrentTeam.team[0].name)
//we dont become leaders if we own a scroll , we become one when we write our name on scroll.
}
}
}