def Lure food.

Persist, runners seek it, remove and adds BAgroundItems.
more naming changes
This commit is contained in:
Tooze 2026-05-21 01:41:54 -04:00
parent 85fb2fec63
commit f2ef4d23ff
8 changed files with 92 additions and 64 deletions

View file

@ -19,8 +19,7 @@ data class BarbAssaultPoints( val atk: Int = 0, val col: Int = 0, val def: Int =
data class BarbAssaultLevels(val atk: Int, val col: Int, val def: Int, val heal: Int) {
fun clamped(): BarbAssaultLevels = BarbAssaultLevels(
atk.coerceIn(1, 5), col.coerceIn(1, 5), def.coerceIn(1, 5), heal.coerceIn(1, 5)
fun clamped(): BarbAssaultLevels = BarbAssaultLevels( atk.coerceIn(1, 5), col.coerceIn(1, 5), def.coerceIn(1, 5), heal.coerceIn(1, 5)
)
}
@ -56,4 +55,28 @@ val ALL_BARBASS_ITEMS = arrayOf(
Item(Items.COLLECTOR_HORN_10560),
Item(Items.COLLECTION_BAG_10521),Item(Items.COLLECTION_BAG_10522),Item(Items.COLLECTION_BAG_10523),Item(Items.COLLECTION_BAG_10524),Item(Items.COLLECTION_BAG_10525),
Item(Items.BLUE_EGG_10533),Item(Items.RED_EGG_10532),Item(Items.GREEN_EGG_10531),
)
)
object BAGraphics {
const val GREEN_LARGE_EXPLOSION_867 = 867
const val RED_LARGE_EXPLOSION_868 = 868
const val BLUE_LARGE_EXPLOSION_869 = 869
const val GREEN_EGG_BREAK_873 = 873
const val RED_EGG_BREAK_874 = 874
const val BLUE_EGG_BREAK_875 = 875
const val PENANCE_HEALER_BAD_BREATH_863 = 863
const val PENANCE_HEALER_GOOD_BREATH_864 = 864
const val GREEN_LARGE_EXPLOSION2_876 = 876
const val RED_EGG_EXPLOSION_975 = 975
const val GREEN_EGG_PROJECTILE_977 = 977
const val RED_EGG_PROJECTILE_978 = 978
const val Blue_EGG_PROJECTILE_978 = 979
const val YELLOW_EGG_PROJECTILE_980 = 980
const val STUNN_BIRDYS_981 = 981
}

View file

@ -16,12 +16,18 @@ import core.game.global.action.ClimbActionHandler
import core.game.global.action.DropListener
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.combat.BattleState
import core.game.node.entity.combat.CombatStyle
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.player.info.LogType
import core.game.node.entity.player.info.PlayerMonitor
import core.game.node.entity.player.info.login.PlayerParser
import core.game.node.item.GroundItem
import core.game.node.item.GroundItemManager
import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.GameWorld
import core.game.world.GameWorld.Pulser
@ -176,32 +182,48 @@ class BarbassaultArenaListener : InteractionListener {
if (session.team.getRoleForPlayer(player) != BarbRole.DEFENDER) {
sendMessage(player,"not a Defender")
}
session.pickUpGroundItem(player, node as GroundItem)
session.pickUpGroundItem(player, node as BAGroundSpawn)
return@on true
}
on(LureItems, IntType.ITEM, "Drop") { player, node ->
DropListener.drop(player, node.asItem())
val session = getBASession(player) ?: return@on true
val currentCall = (session.roleCalls[BarbRole.DEFENDER] as? BarbassaultSession.DefenderCall)?.required
sendMessage(player,currentCall?.itemId().toString())
val flag = node.id == currentCall?.itemId()
handleDropItem(player,node,flag)
val gItem = player.getAttribute<GroundItem>("droppedItem:${node.id}")
(gItem as SessionGroundSpawn).flag = true
session.BAgroundItems.add(gItem)
//delete from ground as runner "eats"
return@on true
}
on(EggCannon.ALL_EGGS, IntType.GROUNDITEM, "Take") { player, node ->
if (node !is GroundItem) return@on true
val session = getBASession(player) ?: return@on true
if (session.team.getRoleForPlayer(player) != BarbRole.COLLECTOR) {
//todo find correct message
sendMessage(player,"not a collector")
}
session.pickUpGroundItem(player,node)
//todo find correct message
session.pickUpGroundItem(player, node as BAGroundSpawn)
return@on true
}
}
fun handleDropItem(player: Player, node: Node, flag: Boolean? = false): Boolean {
val item = node as? Item ?: return false
queueScript(player, strength = QueueStrength.SOFT) {
val current = player.inventory.get(item.slot)
val session = getBASession(player) ?: return@queueScript stopExecuting(player)
if (current == null || current !== item) { return@queueScript stopExecuting(player) }
if (player.inventory.replace(null, item.slot) !== item) { PlayerMonitor.log(player, LogType.DUPE_ALERT, "Potential exploit attempt when player ${player.name} tried to drop ${item.amount}x ${item.id}. BA session Items"); return@queueScript stopExecuting(player) }
val droppedItem = item.dropItem
val groundItem = BAGroundSpawn(session,60,droppedItem,player.location,flag)
groundItem.init()
// sendMessage(player, session.BAgroundItems.toString())
setAttribute(player, "droppedItem:${droppedItem.id}", getWorldTicks() + 2)
return@queueScript stopExecuting(player)
}
return true
}
fun playerChangeScenery(player: Player,anim: Int ,node: Node, newSceneryId: Int, pulseDelay: Int = 3, message: String = "") {
player.animate(Animation(anim))

View file

@ -6,8 +6,8 @@ import core.game.node.item.Item
import core.game.world.GameWorld
import core.game.world.map.Location
class SessionGroundSpawn(private var session: BarbassaultSession, private var respawnRate: Int, item: Item?, location: Location?,
var flag: Boolean? = null) : GroundItem(item, location) {
class BAGroundSpawn(private var session: BarbassaultSession, private var respawnRate: Int, item: Item?, location: Location?,
var flag: Boolean? = null) : GroundItem(item, location) {
private var active = true
private var autoSpawn = true
@ -16,8 +16,9 @@ class SessionGroundSpawn(private var session: BarbassaultSession, private var re
}
fun init(): GroundItem {
session.BAgroundItems.add(this)
return GroundItemManager.create(this)
val thisGroundItem = GroundItemManager.create(this)
session.BAgroundItems.add(thisGroundItem as BAGroundSpawn)
return thisGroundItem
}
override fun isActive(): Boolean {
@ -46,7 +47,7 @@ class SessionGroundSpawn(private var session: BarbassaultSession, private var re
}
GameWorld.Pulser.submit(object : Pulse(respawnRate) {
override fun pulse(): Boolean {
GroundItemManager.create(this@SessionGroundSpawn)
GroundItemManager.create(this@BAGroundSpawn)
return true
}
})

View file

@ -18,7 +18,6 @@ import core.game.node.entity.Entity
import core.game.node.entity.impl.PulseManager
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.item.GroundItem
import core.game.node.item.GroundItemManager
import core.game.node.item.Item
import core.game.system.task.Pulse
@ -54,7 +53,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
var currentNPCCount = SpawnCaps(0,0,0,0)
val npcTunnel: List<PenanceNpcTunnel> = listOf( PenanceNpcTunnel(PenanceType.RUNNER,42,46,0,Direction.SOUTH), PenanceNpcTunnel(PenanceType.HEALER,36,47,0,Direction.SOUTH), PenanceNpcTunnel(PenanceType.FIGHTER,24,47,0,Direction.SOUTH), PenanceNpcTunnel(PenanceType.RANGER,18,46,0,Direction.SOUTH) )
val BAgroundItems = mutableListOf<SessionGroundSpawn>()
val BAgroundItems = mutableListOf<BAGroundSpawn>()
val arenaSpawnItems: List<ArenaSpawnItems> = listOf(ArenaSpawnItems(Items.HAMMER_2347,location(32,42,0)),ArenaSpawnItems(Items.LOGS_11760,location(30,46,0)),ArenaSpawnItems(Items.LOGS_11760,location(29,47,0)))
val eggHopper = EggCannon.EggHopper()
@ -204,24 +203,27 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
val spawnLoc = spawnItem.location
val alreadyExists = groundItems.any { it.id == spawnItem.id && it.location == spawnLoc && !it.isRemoved }
if (!alreadyExists) {
val thisGroundItem = produceGroundSpawnItem(6,Item(spawnItem.id, 1),spawnLoc) //produceGroundItem(leader, spawnItem.id, 1, spawnLoc).apply {
//sendMessage(leader, "spawned item: $spawnLoc")
BAgroundItems.add(thisGroundItem)
produceGroundSpawnItem(6,Item(spawnItem.id, 1),spawnLoc)
}
}
}
fun pickUpGroundItem(player: Player,node:GroundItem){
if (!player.inventory.add(node)) {
node.isActive = false
(node as SessionGroundSpawn).isAutoSpawn = false
BAgroundItems.remove(node)
removeGroundItem(node)
fun pickUpGroundItem(player: Player,node:BAGroundSpawn){
if (player.inventory.add(node)) {
destroyGroundItem(node)
return
}
sendMessage(player,"You don't have enough inventory space to hold that item.")
}
fun findClosestLure(target: Location): SessionGroundSpawn? {
fun destroyGroundItem(node: BAGroundSpawn){
node.isActive = false
node.isAutoSpawn = false
BAgroundItems.remove(node)
GroundItemManager.destroy(node)
}
fun findClosestLure(target: Location): BAGroundSpawn? {
return BAgroundItems
.asSequence()
.filter { it.id in LureItems }
@ -379,8 +381,8 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
sessionNpcs.add(npc)
return npc
}
fun produceGroundSpawnItem(rate:Int,item: Item,location: Location): SessionGroundSpawn {
val thisGroundItem = SessionGroundSpawn(this,rate,item,base.transform(location))
fun produceGroundSpawnItem(rate:Int,item: Item,location: Location): BAGroundSpawn {
val thisGroundItem = BAGroundSpawn(this,rate,item,base.transform(location))
thisGroundItem.init()
return thisGroundItem
}
@ -599,9 +601,13 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
STYLE_4("Defensive/","Mithril/Fire");
override val ui: String get() = top
}
enum class EggColor(override val ui: String): HasUIText { RED("Red Eggs"), GREEN("Green Eggs"),BLUE("Blue Eggs") }
enum class PoisonFood(override val ui: String): HasUIText { TOFU("Pois. Tofu"), WORMS("Pois. Worms"), MEAT("Pois. Meat") }
enum class LureFood(override val ui: String): HasUIText { TOFU("Tofu"), CRACKERS("Crackers"), WORMS("Worms") }
enum class LureFood(override val ui: String) : HasUIText {
TOFU("Tofu"), CRACKERS("Crackers"), WORMS("Worms");
fun itemId(): Int = when (this) { WORMS -> Items.WORMS_10515; CRACKERS -> Items.CRACKERS_10513; TOFU -> Items.TOFU_10514 }
}
class AttackerCall( override val required: AttackerStyle ) : RoleCall<AttackerStyle>()
class HealerCall( override val required: PoisonFood ) : RoleCall<PoisonFood>()
class DefenderCall( override val required: LureFood ) : RoleCall<LureFood>()

View file

@ -41,7 +41,6 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
override fun beforeDamageReceived(self: NPC, attacker: Entity, state: BattleState) {
val player = attacker as? Player ?: return
if (!player.isArtificial) {
state.estimatedHit = BarbAssaultCombat.applyAttackValidation(self, player, state)
}

View file

@ -1,9 +1,8 @@
package content.minigame.barbassault.arena.npcs
import content.minigame.barbassault.arena.SessionGroundSpawn
import content.minigame.barbassault.arena.BAGroundSpawn
import content.minigame.barbassault.getBASession
import core.api.sendMessage
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.item.Item
@ -30,7 +29,7 @@ fun dropPenanceEggCluster(killer: Player, npc: NPC? = null) {
for (i in eggs.indices) {
val tile = tiles[i]
val thisGroundItem = SessionGroundSpawn(session,60,Item(eggs[i],1),tile)
val thisGroundItem = BAGroundSpawn(session,60,Item(eggs[i],1),tile)
thisGroundItem.init()
}
}
@ -110,28 +109,5 @@ fun findClosestNPCIDFromPlayer(player: Player, targetNPC: Int, range: Int = 14):
return closest
}
object BAGraphics {
const val GREEN_LARGE_EXPLOSION_867 = 867
const val RED_LARGE_EXPLOSION_868 = 868
const val BLUE_LARGE_EXPLOSION_869 = 869
const val GREEN_EGG_BREAK_873 = 873
const val RED_EGG_BREAK_874 = 874
const val BLUE_EGG_BREAK_875 = 875
const val PENANCE_HEALER_BAD_BREATH_863 = 863
const val PENANCE_HEALER_GOOD_BREATH_864 = 864
const val GREEN_LARGE_EXPLOSION2_876 = 876
const val RED_EGG_EXPLOSION_975 = 975
const val GREEN_EGG_PROJECTILE_977 = 977
const val RED_EGG_PROJECTILE_978 = 978
const val Blue_EGG_PROJECTILE_978 = 979
const val YELLOW_EGG_PROJECTILE_980 = 980
const val STUNN_BIRDYS_981 = 981
}

View file

@ -57,7 +57,7 @@ class PenanceRunnerNPC : NPCBehavior(*PENANCE_RUNNER_IDS.toIntArray()) {
forceWalk(self,groundItem.location ,"DUMB")
if (self.location == groundItem.location) {
sendChat(self,if (groundItem.flag == true) GOOD_EAT else BAD_EAT)
removeGroundItem(groundItem)
session.destroyGroundItem(groundItem)
self.resetWalk()
}
}

View file

@ -1,10 +1,11 @@
package content.minigame.barbassault.arena.scenery
import content.minigame.barbassault.BAGraphics.Blue_EGG_PROJECTILE_978
import content.minigame.barbassault.BAGraphics.GREEN_EGG_PROJECTILE_977
import content.minigame.barbassault.BAGraphics.RED_EGG_PROJECTILE_978
import content.minigame.barbassault.BAGraphics.YELLOW_EGG_PROJECTILE_980
import content.minigame.barbassault.BarbRole
import content.minigame.barbassault.arena.npcs.BAGraphics.Blue_EGG_PROJECTILE_978
import content.minigame.barbassault.arena.npcs.BAGraphics.GREEN_EGG_PROJECTILE_977
import content.minigame.barbassault.arena.npcs.BAGraphics.RED_EGG_PROJECTILE_978
import content.minigame.barbassault.arena.npcs.BAGraphics.YELLOW_EGG_PROJECTILE_980
import content.minigame.barbassault.arena.npcs.findClosestNPCIDFromPlayer
import content.minigame.barbassault.arena.npcs.findClosestTargetNPCIDFromNPC
import content.minigame.barbassault.arena.PenanceType