forked from 2009Scape/Server
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.
This commit is contained in:
parent
1f538d2976
commit
7779d03654
1 changed files with 49 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue