mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-21 10:25:13 -06:00
Load egg hopper from collector bag
This commit is contained in:
parent
90469d6126
commit
e4d13bce0a
2 changed files with 41 additions and 16 deletions
|
|
@ -276,7 +276,7 @@ class BarbassaultArenaListener : InteractionListener {
|
|||
Items.BLUE_EGG_10533 -> BLUE_EGG_BREAK_875
|
||||
else -> 874
|
||||
}
|
||||
//player.Graphics(gfx)
|
||||
Graphics.send(Graphics(gfx), player.location)
|
||||
sendMessage(player,"The egg exploded")
|
||||
session.destroyGroundItem(groundItem as BAGroundSpawn)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import core.game.node.item.Item
|
|||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import getCollectorBag
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
|
||||
|
|
@ -200,23 +201,47 @@ class EggCannon : ComponentPlugin() {
|
|||
ALL_EGGS.forEach { loadHopperEggs(player, it) }
|
||||
//Load hopper emote, Same as place table??
|
||||
}
|
||||
fun loadHopperEggs(player: Player?,itemId: Int ){
|
||||
fun loadHopperEggs(player: Player?, itemId: Int) {
|
||||
player ?: return
|
||||
//todo fix egg hopper
|
||||
val session = getBASession(player)
|
||||
val invCount = amountInInventory(player, itemId)
|
||||
val result = session?.eggHopper?.addEgg(itemId,invCount)
|
||||
val color = session?.eggHopper?.eggColorMap?.get(itemId)
|
||||
val added = result?.get(color) ?: 0
|
||||
//load from collector bag too
|
||||
if(invCount > 0){
|
||||
// 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.")
|
||||
removeItem(player, Item(itemId, added))
|
||||
|
||||
val session = getBASession(player) ?: return
|
||||
val hopper = session.eggHopper
|
||||
|
||||
val color = hopper.eggColorMap[itemId] ?: return
|
||||
|
||||
val current = when (itemId) {
|
||||
Items.GREEN_EGG_10531 -> hopper.green
|
||||
Items.RED_EGG_10532 -> hopper.red
|
||||
Items.BLUE_EGG_10533 -> hopper.blue
|
||||
Items.OMEGA_EGG_10537 -> hopper.yellow
|
||||
else -> 0
|
||||
}
|
||||
//if hopper full messsage "You can't load any more $eggType eggs."
|
||||
|
||||
val free = 5 - current
|
||||
if (free <= 0) { sendMessage(player, "You can't load any more $color eggs."); return }
|
||||
|
||||
var loaded = 0
|
||||
val collectorBag = getCollectorBag(player).bag
|
||||
val bagCount = collectorBag.getEggCount(itemId)
|
||||
val fromBag = minOf(free, bagCount)
|
||||
|
||||
repeat(fromBag) { collectorBag.container.remove(Item(itemId, 1)); loaded++ }
|
||||
|
||||
val remaining = free - loaded
|
||||
if (remaining > 0) {
|
||||
val invCount = amountInInventory(player, itemId)
|
||||
val fromInv = minOf(remaining, invCount)
|
||||
|
||||
if (fromInv > 0) {
|
||||
removeItem(player, Item(itemId, fromInv))
|
||||
loaded += fromInv
|
||||
}
|
||||
}
|
||||
|
||||
if (loaded <= 0) { return }
|
||||
|
||||
hopper.addEgg(itemId, loaded)
|
||||
sendMessage(player, "You load the hopper.")
|
||||
}
|
||||
fun showEggHopperCount(player: Player?){
|
||||
player ?: return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue