mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-23 03:15:10 -06:00
Session now handles alternating Calls and updates teams RoleInterface when player makes a call
This commit is contained in:
parent
f28e607142
commit
cc2d65cccf
8 changed files with 219 additions and 49 deletions
|
|
@ -9,7 +9,7 @@ import core.game.interaction.InteractionListener
|
|||
import core.game.node.entity.player.Player
|
||||
import org.rs09.consts.Items
|
||||
|
||||
class HornListeners : InteractionListener {
|
||||
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
|
||||
|
|
@ -38,7 +38,7 @@ class HornListeners : InteractionListener {
|
|||
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.team.broadcastMedic(player)
|
||||
player.baSession?.alertHealers(player)
|
||||
return@on true
|
||||
}
|
||||
on(ALL_HORNS, IntType.ITEM, "Drop") { player, _ ->
|
||||
|
|
@ -48,63 +48,76 @@ class HornListeners : InteractionListener {
|
|||
//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
|
||||
}
|
||||
}
|
||||
|
|
@ -133,12 +146,12 @@ class HornListeners : InteractionListener {
|
|||
fun fromId(id: Int): AttackerHorn? = map[id]
|
||||
}
|
||||
}
|
||||
enum class HealerHorn(val itemId: Int) {
|
||||
LEVEL_ONE(Items.HEALER_HORN_10526),
|
||||
LEVEL_TWO(Items.HEALER_HORN_10527),
|
||||
LEVEL_THREE(Items.HEALER_HORN_10528),
|
||||
LEVEL_FOUR(Items.HEALER_HORN_10529),
|
||||
LEVEL_FIVE(Items.HEALER_HORN_10530);
|
||||
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%
|
||||
|
||||
companion object {
|
||||
private val map = values().associateBy(HealerHorn::itemId)
|
||||
|
|
@ -3,6 +3,7 @@ package content.minigame.barbassault.arena
|
|||
import content.minigame.barbassault.BarbRole
|
||||
import content.minigame.barbassault.BarbassaultTut
|
||||
import content.minigame.barbassault.BarbassaultTut.Companion.TutorialItemSpawn
|
||||
import content.minigame.barbassault.arena.BaHornSystem.HornHelper.getHealerHorn
|
||||
import content.minigame.barbassault.arena.scenery.DefenderTrap
|
||||
import content.minigame.barbassault.lobby.baSession
|
||||
import core.api.*
|
||||
|
|
@ -77,12 +78,7 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
}
|
||||
override fun areaEnter(entity: Entity) {
|
||||
val player = entity as? Player ?: return
|
||||
val wornIconId = getItemFromEquipment(player, EquipmentSlot.CAPE)?.id
|
||||
val interfaceId = getIconInterfaceId(wornIconId ?: -1)
|
||||
if (interfaceId != null) {
|
||||
//sendMessage(player,----- Wave: $Num -----")
|
||||
openOverlay(player, interfaceId)
|
||||
}
|
||||
|
||||
BarbassaultTut.BarbassTutNPCs.forEach {
|
||||
npc -> npc.init()
|
||||
npc.isWalks = false
|
||||
|
|
@ -141,9 +137,11 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
player.lock(5)
|
||||
GameWorld.Pulser.submit(object : Pulse(3, player) {
|
||||
override fun pulse(): Boolean {
|
||||
heal(player, 25)
|
||||
val healAmount = getHealerHorn(player)?.healAmount ?: 10
|
||||
//Should also restore run energy Amount
|
||||
heal(player, healAmount)
|
||||
player.unlock()
|
||||
sendMessage(player,"You've been healed \$Healed hitpoints.")
|
||||
sendMessage(player,"You've been healed $healAmount hitpoints.")
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
|
@ -180,6 +178,7 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
onEquip(ROLE_ICON) { player, _ ->
|
||||
if (player.baSession?.state == BarbassaultState.IN_ARENA) {
|
||||
sendMessage(player, "You can't remove that!")
|
||||
return@onEquip false
|
||||
}
|
||||
defineAreaBorders().forEach { border ->
|
||||
if (border.insideBorder(player)) {
|
||||
|
|
@ -215,7 +214,7 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
|
||||
private fun lureDrop(player: Player,item:Item){
|
||||
//val gi = GroundItemManager.create(GroundItem(item.dropItem,player.location,-1,null))
|
||||
|
||||
//todo ask for help with this.
|
||||
queueScript(player, strength = QueueStrength.SOFT) {
|
||||
val current = player.inventory.get(item.slot)
|
||||
if (current == null || current !== item) {
|
||||
|
|
@ -225,13 +224,14 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
PlayerMonitor.log(player, LogType.DUPE_ALERT, "Potential exploit attempt when player ${player.name} tried to drop ${item.amount}x ${item.id}. The item has been lost and will need to be refunded to the player, but how did they get this to happen? @Barbass")
|
||||
return@queueScript stopExecuting(player)
|
||||
}
|
||||
val droppedItem = item.dropItem
|
||||
|
||||
val droppedItem = item.dropItem
|
||||
val gi = GroundItemManager.create(droppedItem, player.location, player)
|
||||
setAttribute(player, "droppedItem:${droppedItem.id}", getWorldTicks() + 2)
|
||||
PlayerParser.save(player)
|
||||
gi.forceVisible = true
|
||||
addItemNode(gi,player.location,true)
|
||||
|
||||
return@queueScript stopExecuting(player)
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ class BarbassaultGameArea : InteractionListener, MapArea {
|
|||
}
|
||||
})
|
||||
}
|
||||
fun hasTools(player: Player): Boolean{
|
||||
private fun hasTools(player: Player): Boolean{
|
||||
if (getItemFromEquipment(player, EquipmentSlot.CAPE)?.id != DEFENDER_ICON) {return true}
|
||||
val requiredItems = listOf(Items.HAMMER_2347, Items.LOGS_11760)
|
||||
for (item in requiredItems) {
|
||||
|
|
@ -289,7 +289,7 @@ fun exitMiniGame(player: Player) {
|
|||
Items.HEALER_HORN_10526,Items.HEALER_HORN_10527,Items.HEALER_HORN_10528,Items.HEALER_HORN_10529,Items.HEALER_HORN_10530,
|
||||
Items.POISONED_WORMS_10540,Items.POISONED_TOFU_10539,Items.POISONED_MEAT_10541,
|
||||
)
|
||||
removeAll(player, barbassItems)
|
||||
// removeAll(player, barbassItems)
|
||||
|
||||
//todo should probably make sure familiars can't smuggle items out
|
||||
//(player.familiarManager.familiar as? BurdenBeast)?.container?.removeAll(barbassItems)//just in case someone smuggles a pet in.
|
||||
|
|
@ -297,21 +297,8 @@ fun exitMiniGame(player: Player) {
|
|||
//or lost game Send back to wave room
|
||||
|
||||
}
|
||||
val BA_ROLE_CAPE = mapOf( BarbRole.ATTACKER to 10556, BarbRole.DEFENDER to 10558, BarbRole.COLLECTOR to 10557, BarbRole.HEALER to 10559 )
|
||||
fun equipBARoleIcon(player: Player, role: BarbRole) {
|
||||
val itemId = BA_ROLE_CAPE[role] ?: return
|
||||
player.equipment.add(Item(itemId),true,false)
|
||||
//player.getEquipment().add(Item(itemId), true)
|
||||
}
|
||||
fun getIconInterfaceId(itemId: Int): Int? {
|
||||
return when (itemId) {
|
||||
ATTACKER_ICON -> Components.BARBASSAULT_OVER_ATT_485
|
||||
COLLECTOR_ICON -> Components.BARBASSAULT_OVER_COL_486
|
||||
DEFENDER_ICON -> Components.BARBASSAULT_OVER_DEF_487
|
||||
HEALER_ICON -> Components.BARBASSAULT_OVER_HEAL_488
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import core.api.*
|
|||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.map.Location
|
||||
|
|
@ -22,6 +23,7 @@ import core.game.world.map.zone.ZoneRestriction
|
|||
import core.tools.Log
|
||||
import core.tools.secondsToTicks
|
||||
import core.tools.ticksToSeconds
|
||||
import org.rs09.consts.Components
|
||||
import org.rs09.consts.NPCs
|
||||
import org.rs09.consts.Music
|
||||
import org.rs09.consts.Music.ASSAULT_AND_BATTERY_604
|
||||
|
|
@ -42,7 +44,7 @@ Player
|
|||
└─ role : BarbRole?
|
||||
*/
|
||||
|
||||
enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA, COMPLETE, END }
|
||||
enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA,FORFEIT, COMPLETE, END }
|
||||
|
||||
class BarbassaultSession( val activity: BarbassaultActivity ? = null) : MapArea {
|
||||
constructor(region: DynamicRegion, activity: BarbassaultActivity) : this(activity) {this.region = region; this.base = region.baseLocation}
|
||||
|
|
@ -87,6 +89,7 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) : MapArea
|
|||
player.properties.teleportLocation = Location.create(2593, 5264, 0)
|
||||
player.interfaceManager.closeOverlay()
|
||||
}
|
||||
// https://www.youtube.com/watch?v=vYKbHNZn80w
|
||||
destroyArena()
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +104,8 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) : MapArea
|
|||
|
||||
if (ticks <= 0) {
|
||||
enterArena()
|
||||
rollNewRoleCalls()
|
||||
//giveplayerHorns
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -118,10 +123,18 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) : MapArea
|
|||
}
|
||||
|
||||
private inner class GamePulse : Pulse(1) {
|
||||
private var roleCallTicks = secondsToTicks(30)
|
||||
|
||||
override fun pulse(): Boolean {
|
||||
if (state != BarbassaultState.IN_ARENA) return true
|
||||
|
||||
roleCallTicks--
|
||||
if (roleCallTicks <= 0) {
|
||||
rollNewRoleCalls()
|
||||
roleCallTicks = secondsToTicks(30)
|
||||
}
|
||||
// TODO: wave logic, timers, win/lose
|
||||
// reSpawnItems
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -161,24 +174,178 @@ class BarbassaultSession( val activity: BarbassaultActivity ? = null) : MapArea
|
|||
log(this::class.java, Log.FINE, "ENTERED Barbassault Arena")
|
||||
|
||||
val player = entity as? Player ?: return
|
||||
// val waveNum = player.getAttribute("barbass:wave", 1)
|
||||
val wornIconId = getItemFromEquipment(player, EquipmentSlot.CAPE)?.id
|
||||
val interfaceId = getIconInterfaceId(wornIconId ?: -1)
|
||||
if (interfaceId != null) {
|
||||
//sendMessage(player,----- Wave: $Num -----")
|
||||
openOverlay(player, interfaceId)
|
||||
|
||||
interfaceId?.let {
|
||||
sendMessage(player, "----- Wave: \$waveNum -----")
|
||||
openOverlay(player, it)
|
||||
}
|
||||
BarbassaultTut.BarbassTutNPCs.forEach {
|
||||
npc -> npc.init()
|
||||
|
||||
/** BarbassaultTut.BarbassTutNPCs.forEach {
|
||||
npc -> npc.init()
|
||||
npc.isWalks = false
|
||||
|
||||
}
|
||||
BarbassaultTut.spawnItems()
|
||||
**/
|
||||
}
|
||||
|
||||
override fun areaLeave(entity: Entity, logout: Boolean) {
|
||||
log(this::class.java, Log.FINE, "LEFT Barbassault Arena")
|
||||
var player = entity as Player
|
||||
exitMiniGame(player)
|
||||
//exitMiniGame(player)
|
||||
removeTimer(player, "teleblock")
|
||||
}
|
||||
}
|
||||
|
||||
private val BA_ROLE_CAPE = mapOf( BarbRole.ATTACKER to 10556, BarbRole.DEFENDER to 10558, BarbRole.COLLECTOR to 10557, BarbRole.HEALER to 10559 )
|
||||
private fun equipBARoleIcon(player: Player, role: BarbRole) {
|
||||
val itemId = BA_ROLE_CAPE[role] ?: return
|
||||
player.equipment.add(Item(itemId),true,false)
|
||||
//player.getEquipment().add(Item(itemId), true)
|
||||
}
|
||||
private fun getIconInterfaceId(itemId: Int): Int? {
|
||||
return when (itemId) {
|
||||
ATTACKER_ICON -> Components.BARBASSAULT_OVER_ATT_485
|
||||
COLLECTOR_ICON -> Components.BARBASSAULT_OVER_COL_486
|
||||
DEFENDER_ICON -> Components.BARBASSAULT_OVER_DEF_487
|
||||
HEALER_ICON -> Components.BARBASSAULT_OVER_HEAL_488
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun broadcast(message: String) {
|
||||
team.allPlayers().forEach {
|
||||
sendMessage(it, message)
|
||||
}
|
||||
}
|
||||
fun broadcastToRole(role: BarbRole, message: String) {
|
||||
team.allPlayers()
|
||||
.filter { team.getRoleForPlayer(it) == role }
|
||||
.forEach { sendMessage(it, message) }
|
||||
}
|
||||
fun alertHealers(player:Player){
|
||||
//alert healers UI you asked ro help ( Flashing cross next to name)
|
||||
}
|
||||
fun updateAttackerUI(player: Player, call: AttackerCall) {
|
||||
val style = call.called
|
||||
if (style == null) {
|
||||
setInterfaceText(player, "- - -", Components.BARBASSAULT_OVER_ATT_485, 4)
|
||||
setInterfaceText(player, "", Components.BARBASSAULT_OVER_ATT_485, 5)
|
||||
return
|
||||
}
|
||||
setInterfaceText(player, style.top, Components.BARBASSAULT_OVER_ATT_485, 4)
|
||||
setInterfaceText(player, style.bottom, Components.BARBASSAULT_OVER_ATT_485, 5)
|
||||
}
|
||||
fun updateOtherRoleUI(player: Player,call: RoleCall<*>,interfaceId: Int,childId: Int ) {
|
||||
val text = (call.called as? HasUIText)?.ui ?: "- - -"
|
||||
setInterfaceText(player, text, interfaceId, childId)
|
||||
}
|
||||
|
||||
fun updateRoleUI() {
|
||||
team.allPlayers().forEach { player ->
|
||||
val role = team.getRoleForPlayer(player) ?: return@forEach
|
||||
val call = roleCalls[role] ?: return@forEach
|
||||
|
||||
when (role) {
|
||||
BarbRole.ATTACKER -> {
|
||||
updateAttackerUI(player, call as AttackerCall)
|
||||
setInterfaceText(player, call.crossRoleDisplay(), Components.BARBASSAULT_OVER_ATT_485, 7)
|
||||
}
|
||||
BarbRole.COLLECTOR -> {
|
||||
updateOtherRoleUI(player, call, Components.BARBASSAULT_OVER_COL_486, 4)
|
||||
setInterfaceText(player, call.crossRoleDisplay(), Components.BARBASSAULT_OVER_COL_486, 6)
|
||||
}
|
||||
BarbRole.DEFENDER -> {
|
||||
updateOtherRoleUI(player, call, Components.BARBASSAULT_OVER_DEF_487, 3)
|
||||
setInterfaceText(player, call.crossRoleDisplay(), Components.BARBASSAULT_OVER_DEF_487, 5)
|
||||
}
|
||||
BarbRole.HEALER -> {
|
||||
updateOtherRoleUI(player, call, Components.BARBASSAULT_OVER_HEAL_488, 31)
|
||||
setInterfaceText(player, call.crossRoleDisplay(), Components.BARBASSAULT_OVER_HEAL_488, 33)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// may need to use this instead of my current method of, entering area, set icon -> set overlay based on icon
|
||||
fun getRoleInterface(role: BarbRole): Int? {
|
||||
return when (role) {
|
||||
BarbRole.ATTACKER -> Components.BARBASSAULT_OVER_ATT_485
|
||||
BarbRole.COLLECTOR -> Components.BARBASSAULT_OVER_COL_486
|
||||
BarbRole.DEFENDER -> Components.BARBASSAULT_OVER_DEF_487
|
||||
BarbRole.HEALER -> Components.BARBASSAULT_OVER_HEAL_488
|
||||
}
|
||||
}
|
||||
|
||||
fun rollNewRoleCalls() {
|
||||
roleCalls[BarbRole.ATTACKER] = AttackerCall(AttackerStyle.values().random())
|
||||
roleCalls[BarbRole.HEALER] = HealerCall(PoisonFood.values().random())
|
||||
roleCalls[BarbRole.DEFENDER] = DefenderCall(LureFood.values().random())
|
||||
roleCalls[BarbRole.COLLECTOR] = CollectorCall(EggColor.values().random())
|
||||
|
||||
roleCalls[BarbRole.COLLECTOR]?.toCall = roleCalls[BarbRole.ATTACKER]?.required
|
||||
roleCalls[BarbRole.ATTACKER]?.toCall = roleCalls[BarbRole.COLLECTOR]?.required
|
||||
roleCalls[BarbRole.HEALER]?.toCall = roleCalls[BarbRole.DEFENDER]?.required
|
||||
roleCalls[BarbRole.DEFENDER]?.toCall = roleCalls[BarbRole.HEALER]?.required
|
||||
updateRoleUI()
|
||||
}
|
||||
private val hornTargets = mapOf(
|
||||
BarbRole.COLLECTOR to BarbRole.ATTACKER,
|
||||
BarbRole.ATTACKER to BarbRole.COLLECTOR ,
|
||||
BarbRole.HEALER to BarbRole.DEFENDER,
|
||||
BarbRole.DEFENDER to BarbRole.HEALER
|
||||
)
|
||||
fun onHornCall(player: Player, calledValue: Any) {
|
||||
val callerRole = team.getRoleForPlayer(player) ?: return
|
||||
val targetRole = hornTargets[callerRole] ?: return
|
||||
val call = roleCalls[targetRole] ?: return
|
||||
|
||||
when (call) {
|
||||
is AttackerCall -> if (calledValue is AttackerStyle) call.call(calledValue)
|
||||
is HealerCall -> if (calledValue is PoisonFood) call.call(calledValue)
|
||||
is DefenderCall -> if (calledValue is LureFood) call.call(calledValue)
|
||||
is CollectorCall -> if (calledValue is EggColor) call.call(calledValue)
|
||||
}
|
||||
updateRoleUI()
|
||||
}
|
||||
fun onAttackerHit(style: AttackerStyle) {
|
||||
val call = roleCalls[BarbRole.ATTACKER] as? AttackerCall ?: return
|
||||
call.check(style)
|
||||
}
|
||||
|
||||
val roleCalls: MutableMap<BarbRole, RoleCall<*>> = mutableMapOf()
|
||||
interface HasUIText { val ui: String }
|
||||
enum class AttackerStyle(val top: String, val bottom: String) : HasUIText {
|
||||
STYLE_1("Controlled/","Bronze/Wind"),
|
||||
STYLE_2("Accurate/","Iron/Water"),
|
||||
STYLE_3("Aggressive/","Steel/Earth"),
|
||||
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") }
|
||||
class AttackerCall( override val required: AttackerStyle ) : RoleCall<AttackerStyle>()
|
||||
class HealerCall( override val required: PoisonFood ) : RoleCall<PoisonFood>()
|
||||
class DefenderCall( override val required: LureFood ) : RoleCall<LureFood>()
|
||||
class CollectorCall( override val required: EggColor ) : RoleCall<EggColor>()
|
||||
|
||||
sealed class RoleCall<T> {
|
||||
abstract val required: T
|
||||
var called: T? = null
|
||||
private set
|
||||
var succeeded: Boolean = false
|
||||
private set
|
||||
var toCall: Any? = null
|
||||
fun call(value: T) { called = value }
|
||||
fun check(value: T): Boolean { if (value == required) { succeeded = true; return true }; return false }
|
||||
fun crossRoleDisplay(): String {
|
||||
return when (this) {
|
||||
is CollectorCall -> (toCall as? AttackerStyle)?.name?.lowercase()?.replaceFirstChar { it.uppercase() } ?: "- - -"
|
||||
else -> (toCall as? HasUIText)?.ui ?: "- - -"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ data class LureItem(val item: Node, val location: Location, val isGood: Boolean)
|
|||
|
||||
val LureItems = intArrayOf(Items.WORMS_10515, Items.CRACKERS_10513, Items.TOFU_10514)
|
||||
val LureItemNodes = mutableListOf<LureItem>()
|
||||
|
||||
//todo make this part of miniGame instance instead of global.
|
||||
|
||||
fun addItemNode(item: GroundItem, location: Location, isGood: Boolean) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package content.minigame.barbassault.arenas.monsters
|
||||
|
||||
import content.minigame.barbassault.arena.HornHelper
|
||||
import content.minigame.barbassault.arena.BaHornSystem
|
||||
import core.api.*
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.combat.BattleState
|
||||
|
|
@ -35,7 +35,7 @@ class PenanceFighterNPC : NPCBehavior(*PENANCE_FIGHTER_IDS.toIntArray()) {
|
|||
}
|
||||
override fun beforeDamageReceived(self: NPC, attacker: Entity, state: BattleState) {
|
||||
val firstBefore = state.estimatedHit
|
||||
state.estimatedHit = firstBefore + (HornHelper.getAttackerHorn(attacker as Player)?.ordinal?.plus(1) ?: 0) +1
|
||||
state.estimatedHit = firstBefore + (BaHornSystem.HornHelper.getAttackerHorn(attacker as Player)?.ordinal?.plus(1) ?: 0) +1
|
||||
|
||||
}
|
||||
override fun onCreation (self: NPC) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package content.minigame.barbassault.arena.scenery
|
||||
|
||||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import content.minigame.barbassault.arena.monsters.PENANCE_RUNNER_IDS
|
||||
import content.minigame.barbassault.lobby.baSession
|
||||
import core.api.*
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.Entity
|
||||
|
|
@ -98,7 +100,7 @@ class DefenderTrap : MapArea {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//player.baSession.broadcastToRole("A Penance Runner broke a trap to the east/west!")
|
||||
//sendMessage(player,"A Penance Runner broke a trap to the east/west!") //When a runner dies to trap announce to Defenders
|
||||
//replaceScenery()
|
||||
//animateScenery
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package content.minigame.barbassault.arena.scenery
|
||||
|
||||
import content.minigame.barbassault.arena.BaHornSystem
|
||||
import core.api.EquipmentSlot
|
||||
import core.api.addItem
|
||||
import core.api.getItemFromEquipment
|
||||
|
|
@ -95,6 +96,7 @@ class ItemMachine: InteractionListener {
|
|||
}
|
||||
//Collector//
|
||||
on(Scenery.COLLECTOR_CONVERTER_21250, IntType.SCENERY, "Convert") { player, _ ->
|
||||
val bagLevel = BaHornSystem.HornHelper.getCollectorBag(player)
|
||||
if (!hasCape(player, 10557)) return@on true
|
||||
|
||||
//Items.RED_EGG_10532
|
||||
|
|
@ -127,7 +129,7 @@ class ItemMachine: InteractionListener {
|
|||
private fun hasAnyVial(player: Player): Boolean {
|
||||
return ALL_HEALER_VAILS.any { player.inventory.contains(it,1) }
|
||||
}
|
||||
private fun hasCape(player: Player, capeId: Int): Boolean {
|
||||
fun hasCape(player: Player, capeId: Int): Boolean {
|
||||
return getItemFromEquipment(player, EquipmentSlot.CAPE)?.id == capeId
|
||||
}
|
||||
private enum class DispenserType(val message: String) {
|
||||
|
|
|
|||
|
|
@ -34,12 +34,10 @@ class CurrentTeamInterface : ComponentPlugin() {
|
|||
//the leader might be able to take scroll between rooms? need Proof
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
fun updateCurrentTeam(player: Player) {
|
||||
val team = player.baSession?.team
|
||||
|
||||
|
||||
for (slotIndex in 0 until BarbTeam.MAX_SLOTS) {
|
||||
val uiSlot = CurrentTeam.team[slotIndex]
|
||||
val partySlot = team?.getSlot(slotIndex)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue