all pennance Cleared Message

This commit is contained in:
Tooze 2026-05-25 12:19:23 -04:00
parent e4d13bce0a
commit 2cdd2654eb
8 changed files with 41 additions and 48 deletions

View file

@ -1,11 +1,13 @@
package content.minigame.barbassault
import content.minigame.barbassault.arena.BarbassaultSession
import content.minigame.barbassault.arena.PenanceType
import core.api.getTimer
import core.api.registerTimer
import core.api.spawnTimer
import core.game.node.entity.Entity
import core.game.node.entity.combat.ImpactHandler
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.system.timer.PersistTimer
import core.game.system.timer.RSTimer
@ -23,13 +25,13 @@ const val BA_SESSION_KEY = "ba-session"
* or `null` if they are not participating in Barbarian Assault.
*/
//getBASession(player)
fun getBASession(player: Player): BarbassaultSession? = player.getAttribute(BA_SESSION_KEY)
fun getBASession(entity: Entity): BarbassaultSession? = entity.getAttribute(BA_SESSION_KEY)
fun setBASession(player: Player, session: BarbassaultSession?) {
fun setBASession(entity: Entity, session: BarbassaultSession?) {
if (session == null) {
player.removeAttribute(BA_SESSION_KEY)
entity.removeAttribute(BA_SESSION_KEY)
} else {
player.setAttribute(BA_SESSION_KEY, session)
entity.setAttribute(BA_SESSION_KEY, session)
}
}
@ -262,3 +264,4 @@ fun applyBAPoison (entity: Entity, source: Entity, severity: Int) {
registerTimer(entity, spawnTimer<BAPoison>(source, severity))
}
}

View file

@ -51,17 +51,17 @@ open class BAActivity : ActivityPlugin("barbassault",false, true, true,ZoneRestr
//BERR must of been good, idk why I put this in here
return super.continueAttack(e, target, style, message)
}
override fun death(e: Entity?, killer: Entity?): Boolean {
val ename = e?.name
log(this.javaClass, Log.FINE,"$ename has died in Barbass")
override fun death(e: Entity, killer: Entity?): Boolean {
log(this.javaClass, Log.FINE,"${e.name} has died in Barbass")
val session = getBASession(e) ?:return false
if (e is Player) {
val session = getBASession(e)
session?.state = BarbassaultState.DEATH
session.state = BarbassaultState.DEATH
e.getProperties().setTeleportLocation(null)
return true
}
if (e is NPC) {
// dropPenanceEggCluster(e)
session.pennanceClearedMessage(e)
}
return false
}

View file

@ -131,9 +131,7 @@ class BAHornSystem : InteractionListener {
//I should set a value in my players session instead of scanning the inventory every time for a horn.
//multiple horn IDs suggest retail would use a gearSet check to apply a damage modifier.
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),
@ -148,29 +146,4 @@ class BAHornSystem : InteractionListener {
}
}
enum class HealerHorn(val itemId: Int, val healAmount: Int) {
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),
LEVEL_THREE(Items.COLLECTION_BAG_10523),
LEVEL_FOUR(Items.COLLECTION_BAG_10524),
LEVEL_FIVE(Items.COLLECTION_BAG_10525);
companion object {
private val map = values().associateBy(CollectionBag::itemId)
fun fromId(id: Int): CollectionBag? = map[id]
}
}
}

View file

@ -12,6 +12,7 @@ import content.minigame.barbassault.getBASession
import content.minigame.barbassault.getBAWave
import content.minigame.barbassault.lobby.*
import content.minigame.barbassault.lobby.BALobby.Companion.waveLobbies
import content.minigame.barbassault.setBASession
import core.api.*
import core.game.node.Node
import core.game.node.entity.Entity
@ -35,6 +36,7 @@ import org.rs09.consts.Items
import org.rs09.consts.Music.ASSAULT_AND_BATTERY_604
import org.rs09.consts.NPCs
import removeCollectorBag
import kotlin.text.lowercase
enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA,FORFEIT, COMPLETE,DEATH, END }
@ -52,6 +54,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
val sessionNpcs = mutableListOf<NPC>()
var currentNPCCount = SpawnCaps(0,0,0,0)
var currentNPCDeathCount = SpawnCaps(0,0,0,0)
var npcTunnel: List<PenanceNpcTunnel> = listOf(
PenanceNpcTunnel(PenanceType.RANGER,location(17,47,0),location(18,46,0),Direction.SOUTH),
@ -184,6 +187,15 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
tracker.defenderStats.runnersPast++
}
}
fun pennanceClearedMessage(npc: NPC) {
val session = getBASession(npc) ?: return
val type = npc.getAttribute<PenanceType>("barbass-type")
session.currentNPCDeathCount[type]++
if (session.currentNPCDeathCount[type] == session.currentWaveDefinition.caps[type]) {
type.toString()
session.broadcast("All of the Penance ${type.name.lowercase().replaceFirstChar { it.uppercase() }}s have been killed!")
}
}
fun setCaveBlocked(node: Node, blocked: Boolean) {
val tunnel = npcTunnel.firstOrNull { t -> base.transform(t.caveLocation) == node.location } ?: return
@ -217,7 +229,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
val npc = sessionNPCSpawn(npcId, location(30, 31, 0), spawn.direction)
npc?.location = base.transform(spawn.spawnOffset)
npc?.setAttribute(BA_SESSION_KEY, this)
setBASession(npc as Entity,this)
currentNPCCount[type]++
return isCaveBlocked(type)
@ -393,9 +405,9 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
fun produceGroundSpawnItem(rate:Int,item: Item,location: Location): BAGroundSpawn = BAGroundSpawn(this, rate, item, base.transform(location)).also { it.init() }
fun spawnEggCannons() {
eggCannonNpcWest = sessionNPCSpawn( NPCs.EGG_LAUNCHER_5026, base.transform(21, 34, 0), Direction.NORTH )
eggCannonNpcWest = sessionNPCSpawn( NPCs.EGG_LAUNCHER_5026, location(21, 34, 0), Direction.NORTH )
if (team.wave == 10) return
eggCannonNpcEast = sessionNPCSpawn( NPCs.EGG_LAUNCHER_5026, base.transform(40, 34, 0), Direction.NORTH )
eggCannonNpcEast = sessionNPCSpawn( NPCs.EGG_LAUNCHER_5026, location(40, 34, 0), Direction.NORTH )
}
fun clearGroundItems(){
@ -430,7 +442,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
player.equipment.add(Item(itemId),true,false)
}
private fun broadcast(message: String) = team.allPlayers().forEach { sendMessage(it, message) }
fun broadcast(message: String) = team.allPlayers().forEach { sendMessage(it, message) }
fun broadcastToRole(role: BarbRole, message: String) = team.getPlayersByRole(role).forEach { sendMessage(it, message) }
fun updateBarbHealerIfaceHPOfPlayer(player: Player) = team.getPlayersByRole(BarbRole.HEALER).forEach { HealerIfaceHPUpdatePlayer(it, player)}

View file

@ -3,6 +3,7 @@ package content.minigame.barbassault.arenas.monsters
import content.minigame.barbassault.BarbRole
import content.minigame.barbassault.arena.BarbAssEvent
import content.minigame.barbassault.arena.BACombatValidation
import content.minigame.barbassault.arena.PenanceType
import content.minigame.barbassault.arena.npcs.dropPenanceEggCluster
import content.minigame.barbassault.getBASession
import core.api.*
@ -54,14 +55,12 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
override fun onCreation (self: NPC) {
self.setAttribute("agg_radius",6)
self.isWalks = true
// self.isNeverWalks = false
self.properties.isNPCWalkable = false
self.walkRadius = 24
self.isAggressive = true
self.isRespawn = false
self.setAttribute("barbass-role", BarbRole.ATTACKER)
self.setAttribute("barbass-type", PenanceType.FIGHTER)
self.definition.combatDistance = 1
self.properties.combatPulse.style = CombatStyle.MELEE
@ -70,10 +69,11 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
override fun onDeathFinished(self: NPC, killer: Entity) {
val player = killer as? Player ?: return
val session = getBASession(player) ?: return
val session = getBASession(self) ?: return
dropPenanceEggCluster(killer,self)
session.eventBus.emit(BarbAssEvent.NPCDied(self,player))
super.onDeathFinished(self, killer)
}

View file

@ -2,6 +2,7 @@ package content.minigame.barbassault.arena.npcs
import content.minigame.barbassault.BarbRole
import content.minigame.barbassault.arena.BarbAssEvent
import content.minigame.barbassault.arena.PenanceType
import content.minigame.barbassault.getBASession
import core.game.node.entity.Entity
import core.game.node.entity.combat.CombatStyle
@ -30,9 +31,10 @@ class PenanceHealerNPC : NPCBehavior(*PENANCE_HEALER_IDS) {
}
override fun onCreation (self: NPC) {
self.setAttribute("barbass-role", BarbRole.HEALER)
self.setAttribute("barbass-type", PenanceType.HEALER)
self.isWalks = true
self.walkRadius = 24
self.isRespawn = false
// self.isIgnoreAttackRestrictions(self)
//self.getSkills().setStaticLevel(Skills.HITPOINTS,15)

View file

@ -3,6 +3,7 @@ package content.minigame.barbassault.arena.npcs
import content.minigame.barbassault.BarbRole
import content.minigame.barbassault.arena.BarbAssEvent
import content.minigame.barbassault.arena.BACombatValidation
import content.minigame.barbassault.arena.PenanceType
import content.minigame.barbassault.getBASession
import core.api.*
import core.api.getItemFromEquipment
@ -52,8 +53,10 @@ class PenanceRangerNPC : NPCBehavior(*PENANCE_RANGER_IDS.toIntArray()) {
self.isNeverWalks = false
self.walkRadius = 24
self.isAggressive = true
self.isRespawn = false
self.definition.combatGraphics[1] = Graphics(866, 25, 0)
self.setAttribute("barbass-role",BarbRole.ATTACKER)
self.setAttribute("barbass-type", PenanceType.RANGER)
self.definition.combatDistance = 8
self.properties.combatPulse.style = CombatStyle.RANGE

View file

@ -44,7 +44,7 @@ class PenanceRunnerNPC : NPCBehavior(*PENANCE_RUNNER_IDS.toIntArray()) {
self.walkRadius = 24
self.destinationFlag
self.setAttribute("barbass-role", BarbRole.DEFENDER)
self.setAttribute("barbass-type", PenanceType.RUNNER)
}
var stateTicks = 0