mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Runecrafting pouches now synchronise across bank instances
BoB can no longer be used to smuggle weapons to Entrana
This commit is contained in:
parent
d65a53b275
commit
cf08e700fb
4 changed files with 21 additions and 14 deletions
|
|
@ -75,11 +75,11 @@ class PouchManager(val player: Player) {
|
||||||
pouch.currentCap = pouch.capacity
|
pouch.currentCap = pouch.capacity
|
||||||
pouch.charges = pouch.maxCharges
|
pouch.charges = pouch.maxCharges
|
||||||
pouch.remakeContainer()
|
pouch.remakeContainer()
|
||||||
|
replaceAllItems(player, itemId, itemId - 1) //in case the player had more copies
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isDecayedPouch(itemId)) {
|
if (!isDecayedPouch(itemId)) {
|
||||||
val slot = player.inventory.getSlot(Item(itemId))
|
replaceAllItems(player, itemId, itemId + 1)
|
||||||
replaceSlot(player, slot, Item(itemId + 1))
|
|
||||||
}
|
}
|
||||||
sendMessage(player, "Your pouch has decayed through use.") //https://www.youtube.com/watch?v=FUcPYrgPUlQ
|
sendMessage(player, "Your pouch has decayed through use.") //https://www.youtube.com/watch?v=FUcPYrgPUlQ
|
||||||
pouch.charges = 9 * pouch.currentCap //implied by multiple contemporaneous sources, quantified only by https://oldschool.runescape.wiki/w/Large_pouch
|
pouch.charges = 9 * pouch.currentCap //implied by multiple contemporaneous sources, quantified only by https://oldschool.runescape.wiki/w/Large_pouch
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import core.game.node.entity.player.Player;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
import org.rs09.consts.Items;
|
import org.rs09.consts.Items;
|
||||||
|
|
||||||
|
import static core.api.ContentAPIKt.replaceAllItems;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the dark mages dialogue.
|
* Handles the dark mages dialogue.
|
||||||
* @author Vexia
|
* @author Vexia
|
||||||
|
|
@ -153,14 +155,7 @@ public final class DarkMageDialogue extends DialoguePlugin {
|
||||||
pouch.getContainer().add(essItem);
|
pouch.getContainer().add(essItem);
|
||||||
}
|
}
|
||||||
if (id != Items.SMALL_POUCH_5509) {
|
if (id != Items.SMALL_POUCH_5509) {
|
||||||
if (player.getInventory().contains(id + 1, 1)) {
|
replaceAllItems(player, id + 1, id);
|
||||||
player.getInventory().remove(new Item(id + 1, 1));
|
|
||||||
player.getInventory().add(new Item(id, 1));
|
|
||||||
}
|
|
||||||
if (player.getBank().contains(id + 1, 1)) {
|
|
||||||
player.getBank().remove(new Item(id + 1, 1));
|
|
||||||
player.getBank().add(new Item(id, 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -408,14 +408,21 @@ fun replaceSlot(player: Player, slot: Int, item: Item, currentItem: Item? = null
|
||||||
*/
|
*/
|
||||||
fun replaceAllItems(player: Player, itemId: Int, replaceId: Int) {
|
fun replaceAllItems(player: Player, itemId: Int, replaceId: Int) {
|
||||||
val item = Item(itemId)
|
val item = Item(itemId)
|
||||||
for (container in arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary)) {
|
val containers = if (player.familiarManager.hasFamiliar() && player.familiarManager.familiar.isBurdenBeast()) {
|
||||||
|
arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary, (player.familiarManager.familiar as BurdenBeast).container)
|
||||||
|
} else {
|
||||||
|
arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary)
|
||||||
|
}
|
||||||
|
for (container in containers) {
|
||||||
val hasItems = container.getAll(item)
|
val hasItems = container.getAll(item)
|
||||||
if (!item.definition.isStackable && (container == player.inventory || container == player.equipment)) {
|
if (!item.definition.isStackable && container != player.bankPrimary && container != player.bankSecondary) {
|
||||||
|
// just replace
|
||||||
for (target in hasItems) {
|
for (target in hasItems) {
|
||||||
val newItem = Item(replaceId, target.amount)
|
val newItem = Item(replaceId, target.amount)
|
||||||
container.replace(newItem, target.slot, true)
|
container.replace(newItem, target.slot, true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// add to existing stack if possible
|
||||||
if (hasItems.size > 0) {
|
if (hasItems.size > 0) {
|
||||||
val target = hasItems[0]
|
val target = hasItems[0]
|
||||||
var count = 0
|
var count = 0
|
||||||
|
|
|
||||||
|
|
@ -605,8 +605,13 @@ public class ItemDefinition extends Definition<Item> {
|
||||||
* @return {@code True} if so.
|
* @return {@code True} if so.
|
||||||
*/
|
*/
|
||||||
public static boolean canEnterEntrana(Player player) {
|
public static boolean canEnterEntrana(Player player) {
|
||||||
Container[] container = new Container[] { player.getInventory(), player.getEquipment() };
|
Container[] containers;
|
||||||
for (Container c : container) {
|
if (player.getFamiliarManager().hasFamiliar() && player.getFamiliarManager().getFamiliar().isBurdenBeast()) {
|
||||||
|
containers = new Container[] { player.getInventory(), player.getEquipment(), ((BurdenBeast) player.getFamiliarManager().getFamiliar()).getContainer() };
|
||||||
|
} else {
|
||||||
|
containers = new Container[] { player.getInventory(), player.getEquipment() };
|
||||||
|
}
|
||||||
|
for (Container c : containers) {
|
||||||
for (Item i : c.toArray()) {
|
for (Item i : c.toArray()) {
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue