mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 10:25:13 -06:00
Collectors Collection bag, Pickup eggs to bag, "lookin" and "empty" options
This commit is contained in:
parent
c316929e65
commit
90469d6126
6 changed files with 85 additions and 29 deletions
|
|
@ -2,7 +2,6 @@ package content.minigame.barbassault
|
|||
|
||||
import content.minigame.barbassault.arena.BarbassaultSession
|
||||
import core.api.getTimer
|
||||
import core.api.hasTimerActive
|
||||
import core.api.registerTimer
|
||||
import core.api.spawnTimer
|
||||
import core.game.node.entity.Entity
|
||||
|
|
@ -11,8 +10,6 @@ import core.game.node.entity.player.Player
|
|||
import core.game.system.timer.PersistTimer
|
||||
import core.game.system.timer.RSTimer
|
||||
import core.game.system.timer.TimerFlag
|
||||
import core.game.system.timer.impl.Poison
|
||||
import core.game.system.timer.impl.PoisonImmunity
|
||||
import core.tools.secondsToTicks
|
||||
|
||||
//thank you Ceikry
|
||||
|
|
|
|||
|
|
@ -15,26 +15,13 @@ data class BarbAssaultPoints( val atk: Int = 0, val col: Int = 0, val def: Int =
|
|||
operator fun minus(other: BarbAssaultPoints): BarbAssaultPoints = BarbAssaultPoints(atk - other.atk,col - other.col,def - other.def,heal - other.heal).clamped()
|
||||
operator fun plus(other: BarbAssaultPoints): BarbAssaultPoints = BarbAssaultPoints(atk + other.atk,col + other.col,def + other.def,heal + other.heal).clamped()
|
||||
fun clamped(): BarbAssaultPoints = BarbAssaultPoints(atk.coerceIn(0, 500), col.coerceIn(0, 500), def.coerceIn(0, 500), heal.coerceIn(0, 500) )
|
||||
fun getPoints(role: BarbRole): Int = when (role) { BarbRole.ATTACKER -> atk; BarbRole.COLLECTOR -> col; BarbRole.DEFENDER -> def; BarbRole.HEALER -> heal; }
|
||||
}
|
||||
|
||||
|
||||
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) )
|
||||
fun getLevel(role: BarbRole): Int = when (role) { BarbRole.ATTACKER -> atk; BarbRole.COLLECTOR -> col; BarbRole.DEFENDER -> def; BarbRole.HEALER -> heal; }
|
||||
|
||||
fun BarbAssaultLevels.getLevel(role: BarbRole): Int = when (role) {
|
||||
BarbRole.ATTACKER -> atk
|
||||
BarbRole.COLLECTOR -> col
|
||||
BarbRole.DEFENDER -> def
|
||||
BarbRole.HEALER -> heal
|
||||
}
|
||||
|
||||
fun BarbAssaultPoints.getPoints(role: BarbRole): Int = when (role) {
|
||||
BarbRole.ATTACKER -> atk
|
||||
BarbRole.COLLECTOR -> col
|
||||
BarbRole.DEFENDER -> def
|
||||
BarbRole.HEALER -> heal
|
||||
}
|
||||
|
||||
val ALL_BARBASS_ITEMS = arrayOf(
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ import core.game.world.map.Direction
|
|||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import getCollectorBag
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Scenery
|
||||
import resetCollectorBag
|
||||
|
||||
|
||||
//1889 5407 - Barb assualt QUEEN area -- 7508
|
||||
|
|
@ -56,6 +58,7 @@ 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 )
|
||||
val ALL_COLLECTION_BAGS = intArrayOf(Items.COLLECTION_BAG_10521,Items.COLLECTION_BAG_10522,Items.COLLECTION_BAG_10523,Items.COLLECTION_BAG_10524,Items.COLLECTION_BAG_10525)
|
||||
object BA_ARENA { val MAIN = 7509; val QUEEN = 7508; val all = listOf(MAIN, QUEEN) }
|
||||
|
||||
override fun defineListeners() {
|
||||
|
|
@ -218,6 +221,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
if (session.team.getRoleForPlayer(player) != BarbRole.DEFENDER) {
|
||||
sendMessage(player,"not a Defender")
|
||||
}
|
||||
//if (getCollectorBag(player).addToBag())
|
||||
session.pickUpGroundItem(player, node as BAGroundSpawn)
|
||||
return@on true
|
||||
}
|
||||
|
|
@ -233,19 +237,34 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
on(EggCannon.ALL_EGGS, IntType.GROUNDITEM, "Take") { player, node ->
|
||||
if (node !is GroundItem) return@on true
|
||||
val session = getBASession(player) ?: return@on true
|
||||
//todo find correct message
|
||||
if (session.team.getRoleForPlayer(player) != BarbRole.COLLECTOR) { sendMessage(player,"not a collector") ; return@on false }
|
||||
//todo find authentic message
|
||||
if (session.team.getRoleForPlayer(player) != BarbRole.COLLECTOR) { sendMessage(player, "You need to be a collector to do that");return@on false }
|
||||
|
||||
val currentCall = (session.roleCalls[BarbRole.COLLECTOR] as? BarbassaultSession.CollectorCall)?.required
|
||||
if (node.id != currentCall?.itemId()){
|
||||
handleWrongEgg(player,node)
|
||||
return@on false
|
||||
val currentCall = (session.roleCalls[BarbRole.COLLECTOR]as? BarbassaultSession.CollectorCall)?.required
|
||||
if (node.id != currentCall?.itemId()) { handleWrongEgg(player,node); return@on false }
|
||||
|
||||
val eggInBag = getCollectorBag(player).addToBag(node)
|
||||
|
||||
if (eggInBag) {
|
||||
session.destroyGroundItem(node as BAGroundSpawn)
|
||||
session.eventBus.emit(EggCollected(player,1))
|
||||
return@on true
|
||||
}
|
||||
|
||||
val didPickUp = session.pickUpGroundItem(player, node as BAGroundSpawn)
|
||||
if (!didPickUp) { handleWrongEgg(player,node,false) }
|
||||
if (!didPickUp) { handleWrongEgg(player,node,false); return@on true }
|
||||
|
||||
session.eventBus.emit(EggCollected(player,1))
|
||||
return@on true
|
||||
}
|
||||
on(ALL_COLLECTION_BAGS, IntType.ITEM, "Look-In") { player, node ->
|
||||
getCollectorBag(player).lookInBag()
|
||||
return@on true
|
||||
}
|
||||
on(ALL_COLLECTION_BAGS, IntType.ITEM, "Empty") { player, node ->
|
||||
resetCollectorBag(player)
|
||||
return@on true
|
||||
}
|
||||
}
|
||||
fun handleWrongEgg(player: Player, groundItem: GroundItem,point: Boolean = true){
|
||||
val session = getBASession(player) ?: return
|
||||
|
|
@ -257,7 +276,8 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
Items.BLUE_EGG_10533 -> BLUE_EGG_BREAK_875
|
||||
else -> 874
|
||||
}
|
||||
Graphics(gfx)
|
||||
//player.Graphics(gfx)
|
||||
sendMessage(player,"The egg exploded")
|
||||
session.destroyGroundItem(groundItem as BAGroundSpawn)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.rs09.consts.Components
|
|||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.Music.ASSAULT_AND_BATTERY_604
|
||||
import org.rs09.consts.NPCs
|
||||
import removeCollectorBag
|
||||
|
||||
|
||||
enum class BarbassaultState { PARTY_CREATION, STARTING, IN_ARENA,FORFEIT, COMPLETE,DEATH, END }
|
||||
|
|
@ -383,6 +384,7 @@ class BarbassaultSession( val activity: BAActivity ? = null) :LogoutListener, M
|
|||
|
||||
removeTimer(player, "teleblock")
|
||||
zone.cleanItems(player,ALL_BARBASS_ITEMS)
|
||||
removeCollectorBag(player)
|
||||
clearLogoutListener(player, "ba-logout")
|
||||
player.fullRestore()
|
||||
destroyArena()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
import content.minigame.barbassault.getBALevels
|
||||
import core.api.sendMessage
|
||||
import core.api.sendDialogueLines
|
||||
import core.game.container.Container
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Items
|
||||
|
||||
fun getCollectorBag(player: Player): CollectorBagManager {
|
||||
return player.getAttribute<CollectorBagManager>(CollectorBagManager.KEY) ?: CollectorBagManager(player).also { player.setAttribute(CollectorBagManager.KEY, it) }
|
||||
}
|
||||
fun removeCollectorBag(player: Player) = player.removeAttribute(CollectorBagManager.KEY)
|
||||
fun resetCollectorBag(player: Player) = player.setAttribute(CollectorBagManager.KEY,CollectorBagManager(player))
|
||||
|
||||
class CollectorBagManager(val player: Player) {
|
||||
val bag: CollectorBag = CollectorBag(getCollectorBagCapacity(getBALevels(player).col))
|
||||
|
||||
fun getCollectorBagCapacity(level: Int): Int = when (level) { 1 -> 2; 2 -> 3; 3 -> 6; 4 -> 7; 5 -> 8; else -> 2 }
|
||||
fun lookInBag() {
|
||||
val green = bag.getEggCount(Items.GREEN_EGG_10531)
|
||||
val red = bag.getEggCount(Items.RED_EGG_10532)
|
||||
val blue = bag.getEggCount(Items.BLUE_EGG_10533)
|
||||
|
||||
sendDialogueLines(player,"The collection bag contains:","$green poison eggs, $red explosive eggs","and $blue stun eggs.")
|
||||
}
|
||||
companion object {
|
||||
val VALID_EGGS = setOf(Items.RED_EGG_10532,Items.GREEN_EGG_10531,Items.BLUE_EGG_10533)
|
||||
val KEY = "collector_bag_manager"
|
||||
}
|
||||
|
||||
class CollectorBag(val capacity: Int) {
|
||||
|
||||
var container = Container(3)
|
||||
|
||||
fun totalEggs(): Int = container.toArray().filterNotNull().sumOf { it.amount }
|
||||
fun freeEggSpace(): Int = capacity - totalEggs()
|
||||
fun getEggCount(itemId: Int): Int = container.toArray().filterNotNull().count { it.id == itemId }
|
||||
|
||||
}
|
||||
|
||||
fun addToBag(node: Node): Boolean {
|
||||
if (node.id !in VALID_EGGS) return false
|
||||
if (bag.freeEggSpace() <= 0) { sendMessage(player, "Your bag is full."); return false }
|
||||
|
||||
val egg = Item(node.id, 1)
|
||||
bag.container.add(egg)
|
||||
sendMessage(player, "You put the egg in the bag.")
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +182,6 @@ class EggCannon : ComponentPlugin() {
|
|||
|
||||
companion object {
|
||||
val ALL_EGGS = intArrayOf(Items.GREEN_EGG_10531,Items.RED_EGG_10532,Items.BLUE_EGG_10533,Items.OMEGA_EGG_10537)
|
||||
|
||||
fun openTurretIface(player: Player?) {
|
||||
player ?: return
|
||||
if (getBASession(player)?.eggHopper?.totalCount() == 0) {
|
||||
|
|
@ -211,7 +210,7 @@ class EggCannon : ComponentPlugin() {
|
|||
val added = result?.get(color) ?: 0
|
||||
//load from collector bag too
|
||||
if(invCount > 0){
|
||||
val result = session?.eggHopper?.addEgg(itemId,invCount)
|
||||
// val result = session?.eggHopper?.addEgg(itemId,invCount)
|
||||
val color = session?.eggHopper?.eggColorMap?.get(itemId)
|
||||
val added = result?.get(color) ?: 0
|
||||
sendMessage(player,"You load the hopper.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue