Improved handling of clue scroll tiers

This commit is contained in:
Bishop
2026-04-19 09:37:22 +00:00
committed by Ryan
parent 8fd363a43c
commit 5d34fac117
3 changed files with 32 additions and 2 deletions
@@ -7,6 +7,7 @@ import core.api.utils.WeightBasedTable
import core.api.utils.WeightedItem
import core.game.interaction.InteractionListener
import core.game.interaction.IntType
import content.global.activity.ttrail.TreasureTrailManager
class ImplingJarListener : InteractionListener {
@@ -15,8 +16,14 @@ class ImplingJarListener : InteractionListener {
override fun defineListeners() {
on(JARS, IntType.ITEM, "loot"){ player, node ->
val jar = node.asItem()
val table = ImplingLoot.forId(jar.id) ?: return@on false
val effectiveTable = if (TreasureTrailManager.getInstance(player).hasClue()) {
table.excluding(*WeightBasedTable.CLUE_SCROLL_SLOTS)
} else {
table
}
val loot = ImplingLoot.forId(jar.id)?.roll()?.firstOrNull() ?: return@on false
val loot = effectiveTable.roll().firstOrNull() ?: return@on false
if(removeItem(player, jar, Container.INVENTORY)) {
addItemOrDrop(player, loot.id, loot.amount)
@@ -14,6 +14,7 @@ import core.game.interaction.IntType
import core.game.node.entity.player.Player
import core.game.node.item.Item
import org.rs09.consts.Sounds
import content.global.activity.ttrail.TreasureTrailManager
class ThievingListeners : InteractionListener {
@@ -66,7 +67,12 @@ class ThievingListeners : InteractionListener {
}
player.animator.animate(PICKPOCKET_ANIM)
val lootTable = pickpocketRoll(player, pickpocketData.low, pickpocketData.high, pickpocketData.table)
val effectiveTable = if (TreasureTrailManager.getInstance(player).hasClue()) {
pickpocketData.table.excluding(*WeightBasedTable.CLUE_SCROLL_SLOTS)
} else {
pickpocketData.table
}
val lootTable = pickpocketRoll(player, pickpocketData.low, pickpocketData.high, effectiveTable)
if(lootTable == null){
node.asNpc().face(player)
node.asNpc().animator.animate(NPC_ANIM)
@@ -182,6 +182,22 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
return this
}
fun excluding(vararg ids: Int): WeightBasedTable {
val idSet = ids.toHashSet()
val filtered = WeightBasedTable()
for (item in this) {
if (item.id !in idSet) {
filtered.add(item)
}
}
for (item in guaranteedItems) {
if (item.id !in idSet) {
filtered.add(item)
}
}
return filtered
}
companion object {
@JvmStatic
fun create(vararg items: WeightedItem): WeightBasedTable {
@@ -197,6 +213,7 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
val SLOT_CLUE_EASY = Items.TOOLKIT_1
val SLOT_CLUE_MEDIUM = Items.ROTTEN_POTATO_5733
val SLOT_CLUE_HARD = Items.GRANITE_LOBSTER_POUCH_12070
val CLUE_SCROLL_SLOTS = intArrayOf(SLOT_CLUE_EASY, SLOT_CLUE_MEDIUM, SLOT_CLUE_HARD)
val SLOT_CELEDT = Items.NULL_799
val SLOT_USDT = Items.SACRED_CLAY_POUCH_CLASS_1_14422
val SLOT_HDT = Items.SACRED_CLAY_POUCH_CLASS_2_14424