Healers vial restores health on players

This commit is contained in:
Tooze 2026-05-23 16:59:25 -04:00
parent 950b591ac6
commit f44ec73f95
2 changed files with 54 additions and 29 deletions

View file

@ -1,28 +1,24 @@
package content.minigame.barbassault.arena
import content.minigame.barbassault.*
import content.minigame.barbassault.BAGraphics.BLUE_EGG_BREAK_875
import content.minigame.barbassault.BAGraphics.GREEN_EGG_BREAK_873
import content.minigame.barbassault.BAGraphics.RED_EGG_BREAK_874
import content.minigame.barbassault.BAGraphics.RED_EGG_EXPLOSION_975
import content.minigame.barbassault.BarbRole
import content.minigame.barbassault.LureItems
import content.minigame.barbassault.arena.BAHornSystem.HornHelper.getHealerHorn
import content.minigame.barbassault.arena.BarbAssEvent.EggCollected
import content.minigame.barbassault.arena.BarbAssEvent.HitpointsHealed
import content.minigame.barbassault.arena.BarbassaultSession.AttackerStyle
import content.minigame.barbassault.arena.scenery.EggCannon
import content.minigame.barbassault.arena.scenery.EggCannon.Companion.loadEggHopper
import content.minigame.barbassault.arena.scenery.EggCannon.Companion.loadHopperEggs
import content.minigame.barbassault.arena.scenery.EggCannon.Companion.showEggHopperCount
import content.minigame.barbassault.getBALevels
import content.minigame.barbassault.getBASession
import content.minigame.barbassault.isBARole
import core.api.*
import core.game.global.action.ClimbActionHandler
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.interaction.QueueStrength
import core.game.node.Node
import core.game.node.entity.Entity
import core.game.node.entity.combat.BattleState
import core.game.node.entity.combat.CombatStyle
import core.game.node.entity.npc.NPC
@ -32,7 +28,6 @@ import core.game.node.entity.player.info.PlayerMonitor
import core.game.node.item.GroundItem
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.GameWorld
import core.game.world.GameWorld.Pulser
import core.game.world.map.Direction
import core.game.world.map.Location
@ -58,8 +53,8 @@ class BarbassaultArenaListener : InteractionListener {
val ROLE_ICON = intArrayOf( ATTACKER_ICON, DEFENDER_ICON, COLLECTOR_ICON, HEALER_ICON )
val Fix_trap_IDs = intArrayOf( Scenery.RUNNER_TRAP1_20230, Scenery.BROKEN_TRAP0_20231 )
val All_HEALING_VIALS = intArrayOf(Items.HEALING_VIAL_10546,Items.HEALING_VIAL1_10545,Items.HEALING_VIAL2_10544,Items.HEALING_VIAL3_10543,Items.HEALING_VIAL4_10542 )
object BA_ARENA { val MAIN = 7509; val QUEEN = 7508; val all = listOf(MAIN, QUEEN) }
//base.transform(0,0,0)
override fun defineListeners() {
//Wrong food message "That's the wrong type of poisoned food to use! Penalty!"
@ -137,14 +132,14 @@ class BarbassaultArenaListener : InteractionListener {
if (isBARole(player, BarbRole.HEALER)) {
player.animate(Animation(5407))
player.lock(5)
GameWorld.Pulser.submit(object : Pulse(3, player) {
//todo use quescript here instead
Pulser.submit(object : Pulse(3, player) {
override fun pulse(): Boolean {
//todo switch to Healer level instead of Horn in inv
val healAmount = getHealerHorn(player)?.healAmount ?: 10
//Should also restore run energy Amount
heal(player, healAmount)
val restoreAmount = getHealerHealAmount(player)
heal(player, restoreAmount)
player.settings.updateRunEnergy((-restoreAmount).toDouble())
player.unlock()
sendMessage(player,"You've been healed $healAmount hitpoints.")
sendMessage(player,"You've been healed $restoreAmount hitpoints.")
getBASession(player)?.updateBarbHealerIfaceHPOfPlayer(player)
return true
}
@ -152,22 +147,47 @@ class BarbassaultArenaListener : InteractionListener {
}
return@on true
}
//todo use vial on player
//"The player's hitpoints are full." //Error message if target player hp is full
//sendamount heal for conversion to points at end.
onUseWithPlayer(*All_HEALING_VIALS) { player, _, target ->
//todo quescirpt this and emote
target as Player
if (target.skills.lifepoints >= target.skills.maximumLifepoints) {
sendMessage(player, "The player's hitpoints are full.")
return@onUseWithPlayer true
}
val current = All_HEALING_VIALS.firstOrNull { player.inventory.containsAtLeastOneItem(it) }?: return@onUseWithPlayer true
val index = All_HEALING_VIALS.indexOf(current)
if (index > 0) {
val session = getBASession(player)
val next = All_HEALING_VIALS[index - 1]
player.inventory.remove(Item(current))
player.inventory.add(Item(next))
val restoreAmount = minOf(getHealerHealAmount(player) ,target.skills.maximumLifepoints - target.skills.lifepoints)
sendMessage(target,"You've been healed $restoreAmount hitpoints.")
sendMessage(player,"You healed $restoreAmount hitpoints.")
heal(target, restoreAmount)
target.settings.updateRunEnergy((-restoreAmount).toDouble())
session?.updateBarbHealerIfaceHPOfPlayer(target)
session?.eventBus?.emit(HitpointsHealed(player,restoreAmount))
}
return@onUseWithPlayer true
}
on(Scenery.HEALER_SPRING_20150, IntType.SCENERY, "Take-from") { player, _ ->
val healLevel = getBALevels(player).heal
//emote 5400
/* HEALING_VIAL_10546 -- empty
HEALING_VIAL1_10545 // 1
HEALING_VIAL2_10544
HEALING_VIAL3_10543
HEALING_VIAL4_10542 // 4
*/
sendMessage(player,"You filled the vial.")
//todo quescript this
player.animate(Animation(5400))
if (player.inventory.containsAtLeastOneItem(All_HEALING_VIALS)) {
val current = All_HEALING_VIALS.firstOrNull { player.inventory.containsAtLeastOneItem(it) } ?: return@on true
player.inventory.remove(Item(current))
player.inventory.add(Item(Items.HEALING_VIAL4_10542))
sendMessage(player,"You filled the vial.")
}
return@on true
}
//CATALYTIC_RUNE_12851, ELEMENTAL_RUNE_12850
onUnequip(ROLE_ICON) { player, _ ->
if (getBASession(player)?.state == BarbassaultState.IN_ARENA){
@ -289,6 +309,11 @@ class BarbassaultArenaListener : InteractionListener {
}
return false
}
fun getHealerHealAmount(player: Player): Int {
val healerHealAmounts = intArrayOf(5, 15, 20, 25, 35)
val level = getBALevels(player).heal
return healerHealAmounts.getOrElse(level) { healerHealAmounts.last() }
}
}
object BACombatValidation {

View file

@ -27,7 +27,7 @@ class RoleSelectInterface : ComponentPlugin() {
isopen = false
closeInterface(leader)
//if team.recruit not on team, team.recruit?.player?.baSession = null
setBASession(team.recruit!!.player,null)
(team.recruit?.player )?.let { setBASession(it ,null) }
team.recruit = null
}
return@setCloseEvent true