From 70a3a0b0dea20533087ef1f80773317374d718c7 Mon Sep 17 00:00:00 2001 From: Seelad Date: Sat, 8 Aug 2026 21:11:10 -0400 Subject: [PATCH] Fix item use on deposit box to be accurate, fix
being double counted in some cases, fix double 'log' on log burning. --- .../player/dialogue/align/TextAlignment.kt | 4 +- .../DepositBoxActions.kt | 38 +++++++++++++++++++ .../scripts/DepositBoxScript.kt | 8 +++- .../skills/firemaking/BurnLogEvents.kt | 2 +- .../skills/firemaking/CampfireEvents.kt | 2 +- .../kotlin/dev/openrune/util/TextAlignment.kt | 4 +- 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/api/player/src/main/kotlin/org/rsmod/api/player/dialogue/align/TextAlignment.kt b/api/player/src/main/kotlin/org/rsmod/api/player/dialogue/align/TextAlignment.kt index cf928fd86..d29a45e84 100644 --- a/api/player/src/main/kotlin/org/rsmod/api/player/dialogue/align/TextAlignment.kt +++ b/api/player/src/main/kotlin/org/rsmod/api/player/dialogue/align/TextAlignment.kt @@ -69,7 +69,9 @@ public class TextAlignment @Inject constructor() { if (char == '>' && tagStart != -1) { val tag = text.substring(tagStart + 1, index) tagStart = -1 - lineBuilder.append('<').append(tag).append('>') + if (tag != "br") { + lineBuilder.append('<').append(tag).append('>') + } when (tag) { "br" -> { lineBuffer[lineCount] = lineBuilder.substring(lineStart) diff --git a/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/DepositBoxActions.kt b/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/DepositBoxActions.kt index 80e5a0252..2410c8a05 100644 --- a/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/DepositBoxActions.kt +++ b/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/DepositBoxActions.kt @@ -1,9 +1,11 @@ package org.rsmod.content.interfaces.depositbox +import dev.openrune.ServerCacheManager import org.rsmod.api.player.protect.ProtectedAccess import org.rsmod.api.player.vars.boolVarBit import org.rsmod.api.player.vars.intVarBit import org.rsmod.api.player.vars.intVarp +import org.rsmod.api.utils.format.formatAmount import org.rsmod.content.interfaces.bank.QuantityMode import org.rsmod.content.interfaces.depositbox.configs.DepositBoxConfig import org.rsmod.content.interfaces.depositbox.configs.DepositBoxConstants @@ -62,6 +64,42 @@ internal fun ProtectedAccess.depositOption1Qty(): Int = QuantityMode.All -> Int.MAX_VALUE } +internal fun ProtectedAccess.heldDepositCount(slot: Int): Int { + val obj = inv[slot] ?: return 0 + val objType = ServerCacheManager.getItem(obj.id) ?: return 0 + return inv.count(obj, objType) +} + +internal suspend fun ProtectedAccess.requestDepositQuantity(count: Int): Int { + if (count == 1) { + return 1 + } + val amount = when { + count > 10 -> choice5( + "1", 1, + "5", 5, + "10", 10, + "X", null, + "All", Int.MAX_VALUE, + title = "How many would you like to deposit?", + ) + count > 5 -> choice4( + "1", 1, + "5", 5, + "X", null, + "All", Int.MAX_VALUE, + title = "How many would you like to deposit?", + ) + else -> choice3( + "1", 1, + "X", null, + "All", Int.MAX_VALUE, + title = "How many would you like to deposit?", + ) + } + return amount ?: countDialog("How many would you like to deposit? 1 - ${count.formatAmount}") +} + internal fun ProtectedAccess.playDepositAnim() { anim(DepositBoxConstants.OPEN_SEQ) } diff --git a/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/scripts/DepositBoxScript.kt b/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/scripts/DepositBoxScript.kt index bdba548c1..f1ab94cbd 100644 --- a/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/scripts/DepositBoxScript.kt +++ b/content/interfaces/deposit-box/src/main/kotlin/org.rsmod.content.interfaces.depositbox/scripts/DepositBoxScript.kt @@ -9,7 +9,9 @@ import org.rsmod.api.script.onOpLocCategoryU import org.rsmod.content.interfaces.bank.scripts.BankInvScript import org.rsmod.content.interfaces.depositbox.configs.DepositBoxConstants import org.rsmod.content.interfaces.depositbox.depositInventoryItem +import org.rsmod.content.interfaces.depositbox.heldDepositCount import org.rsmod.content.interfaces.depositbox.opLocUDepositAll +import org.rsmod.content.interfaces.depositbox.requestDepositQuantity import org.rsmod.events.EventBus import org.rsmod.plugin.scripts.PluginScript import org.rsmod.plugin.scripts.ScriptContext @@ -42,7 +44,11 @@ constructor(private val eventBus: EventBus, private val bankInv: BankInvScript) depositInventoryItem(bankInv, invSlot, Int.MAX_VALUE) return } - val amount = countDialog() + val count = heldDepositCount(invSlot) + if (count <= 0) { + return + } + val amount = requestDepositQuantity(count) if (amount <= 0) { return } diff --git a/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/BurnLogEvents.kt b/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/BurnLogEvents.kt index eeb2c9590..3819d1409 100644 --- a/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/BurnLogEvents.kt +++ b/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/BurnLogEvents.kt @@ -116,7 +116,7 @@ public class BurnLogEvents @Inject constructor( BurnMethod.Bow -> (log.statReq.first().t1 + 20).coerceAtMost(99) } if (player.firemakingLvl < reqLevel) { - player.mes("You need a Firemaking level of $reqLevel to burn ${log.input.name} logs this way.") + player.mes("You need a Firemaking level of $reqLevel to burn ${log.input.name} this way.") return false } diff --git a/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/CampfireEvents.kt b/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/CampfireEvents.kt index 1db5ade5f..36a976a19 100644 --- a/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/CampfireEvents.kt +++ b/content/skills/firemaking/src/main/kotlin/org/rsmod/content/skills/firemaking/CampfireEvents.kt @@ -172,7 +172,7 @@ class CampfireEvents @Inject constructor( private fun ProtectedAccess.hasFiremakingLevelOrMes(log: FiremakingLogsRow): Boolean { if (player.firemakingLvl >= log.statReq.first().t1) return true - player.mes("You need a Firemaking level of ${log.statReq.first().t1} to burn ${log.input.name} logs.") + player.mes("You need a Firemaking level of ${log.statReq.first().t1} to burn ${log.input.name}.") return false } diff --git a/or-cache/src/main/kotlin/dev/openrune/util/TextAlignment.kt b/or-cache/src/main/kotlin/dev/openrune/util/TextAlignment.kt index 8cfdd1f2d..7937a2cbd 100644 --- a/or-cache/src/main/kotlin/dev/openrune/util/TextAlignment.kt +++ b/or-cache/src/main/kotlin/dev/openrune/util/TextAlignment.kt @@ -70,7 +70,9 @@ object TextAlignment { if (char == '>' && tagStart != -1) { val tag = text.substring(tagStart + 1, index) tagStart = -1 - lineBuilder.append('<').append(tag).append('>') + if (tag != "br") { + lineBuilder.append('<').append(tag).append('>') + } when (tag) { "br" -> { lineBuffer[lineCount] = lineBuilder.substring(lineStart)