From 7779d03654e6fa06b94e2ca4819eee90d373f748 Mon Sep 17 00:00:00 2001 From: randy Date: Fri, 8 Nov 2024 15:42:16 -0700 Subject: [PATCH] Added Beast of Burden Looting Mob drops will go to a beast of burden inventory if there is room. The Pack Yak, if it has Winter Storage scrolls in its inventory, will instead send drops straight to the bank at the cost of one scroll. --- .../node/entity/npc/drop/NPCDropTables.java | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Server/src/main/core/game/node/entity/npc/drop/NPCDropTables.java b/Server/src/main/core/game/node/entity/npc/drop/NPCDropTables.java index 5a5db3d49..7421228f7 100644 --- a/Server/src/main/core/game/node/entity/npc/drop/NPCDropTables.java +++ b/Server/src/main/core/game/node/entity/npc/drop/NPCDropTables.java @@ -23,6 +23,11 @@ import core.api.utils.NPCDropTable; import core.game.ge.GrandExchange; import core.game.world.repository.Repository; +import content.global.skill.summoning.familiar.BurdenBeast; +import content.global.skill.summoning.familiar.Forager; +import content.global.skill.summoning.SummoningPouch; +import content.global.skill.summoning.familiar.PackYakNPC; + import java.util.ArrayList; import java.util.List; @@ -106,9 +111,17 @@ public final class NPCDropTables { item = item.getPlugin().getItem(item, npc); } if (!item.getDefinition().isStackable() && item.getAmount() > 1) { + if (hasValidFamiliar(player)) { + for (int i = 0; i < item.getAmount(); i++) { + if (!addItemFamiliar(player, new Item(item.getId()))) { + GroundItemManager.create(new Item(item.getId()), l, player); + } + } + } else { for (int i = 0; i < item.getAmount(); i++) { GroundItemManager.create(new Item(item.getId()), l, player); } + } return; } announceIfRare(player, item); @@ -121,7 +134,11 @@ public final class NPCDropTables { GroundItemManager.create(item, l); } } else { - GroundItem groundItem = GroundItemManager.create(item, l, getLooter(player, npc, item)); + Player looter = getLooter(player, npc, item); + if (hasValidFamiliar(looter) && addItemFamiliar(looter, item)) { + return; + } + GroundItem groundItem = GroundItemManager.create(item, l, looter); if(player instanceof AIPlayer) { AIRepository.addItem(groundItem); } @@ -134,6 +151,37 @@ public final class NPCDropTables { } } + /** Snowlab custom looting + * Check if the player has a valid familiar that can loot. + * @param player The player + * @return true if they have a valid familiar. + */ + private boolean hasValidFamiliar(Player player) { + if (!(player instanceof AIPlayer) && player.getFamiliarManager().hasFamiliar() && player.getFamiliarManager().getFamiliar().isBurdenBeast() && !(player.getFamiliarManager().getFamiliar() instanceof Forager) && !SummoningPouch.get(player.getFamiliarManager().getFamiliar().getPouchId()).abyssal){ + return true; + } else { + return false; + } + } + /** Snowlab custom looting + * Attempt adding item to familiar inventory. + * @param player The player + * @return true if item was successfully added. + */ + private boolean addItemFamiliar(Player player, Item item) { + if ((player.getFamiliarManager().getFamiliar() instanceof PackYakNPC) && ((BurdenBeast) player.getFamiliarManager().getFamiliar()).getContainer().contains(12435, 1) && player.getBank().add(item)) { + ((BurdenBeast) player.getFamiliarManager().getFamiliar()).getContainer().remove(new Item(12435, 1)); + player.sendMessage("Your familiar picked up and banked " + item.getAmount() + " " + item.getName() + "."); + return true; + } + if (((BurdenBeast) player.getFamiliarManager().getFamiliar()).getContainer().add(item)) { + player.sendMessage("Your familiar picked up " + item.getAmount() + " " + item.getName() + "."); + return true; + } else { + return false; + } + } + /** * Gets the looting player. * @param player the player.