Skip to content

Commit 305843b

Browse files
committed
Banking fixes
Fix withdrawing non stackable items as stacks Fix not being able to withdraw more noted items than you have space left in inventory.
1 parent be8a77f commit 305843b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/engine/world/items/item-container.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { filestore } from '@server/game/game-server';
44
import { hasValueNotNull } from '@engine/util/data';
55
import { findItem } from '@engine/config/config-handler';
66
import { logger } from '@runejs/core';
7+
import { fromNote } from '.';
78

89

910
export interface ContainerUpdateEvent {
@@ -308,7 +309,7 @@ export class ItemContainer {
308309
if(!itemDefinition) {
309310
throw new Error(`Item ID ${ item.itemId } not found!`);
310311
}
311-
if(itemDefinition.stackable || everythingStacks) {
312+
if(itemDefinition.stackable || everythingStacks || fromNote(item) > -1) {
312313
if(this.has(item.itemId)) {
313314
const invItem = this.items[this.findIndex(item.itemId)];
314315
return invItem.amount + item.amount <= 2147483647;

src/plugins/objects/bank/bank.plugin.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
114114
}
115115

116116
let itemIdToAdd: number = details.itemId;
117+
let stackable = details.itemDetails.stackable;
117118
if (details.player.settings.bankWithdrawNoteMode) {
118119
const toNoteId: number = toNote(details.itemId);
119120
if (toNoteId > -1) {
120121
itemIdToAdd = toNoteId;
122+
stackable = true;
121123
} else {
122124
details.player.sendMessage('This item can not be withdrawn as a note.');
123125
}
@@ -154,7 +156,7 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
154156
countToRemove = itemAmount;
155157
}
156158

157-
if (!details.itemDetails.stackable) {
159+
if (!stackable) {
158160
const slots = playerInventory.getOpenSlotCount();
159161
if (slots < countToRemove) {
160162
countToRemove = slots;
@@ -170,7 +172,11 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
170172
amount: removeFromContainer(playerBank, details.itemId, countToRemove)
171173
};
172174

173-
playerInventory.add({ itemId: itemToAdd.itemId, amount: itemToAdd.amount });
175+
if (stackable)
176+
playerInventory.add({ itemId: itemToAdd.itemId, amount: itemToAdd.amount });
177+
else
178+
for(let count = 0; count < itemToAdd.amount; count++)
179+
playerInventory.add({ itemId: itemToAdd.itemId, amount: 1 });
174180

175181
updateBankingInterface(details.player);
176182
};

0 commit comments

Comments
 (0)