From d4d320264c4a93d331aad7db2178b95f5cf09f77 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 14 Sep 2025 19:19:00 -0500 Subject: [PATCH] autoloot --- src/engine/objects/Mob.java | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 70602b02..52054417 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1242,6 +1242,50 @@ public class Mob extends AbstractIntelligenceAgent { } } killCleanup(); + + if (attacker.getObjectType() == GameObjectType.PlayerCharacter) { + autoLoot((PlayerCharacter)attacker, this); + } + } + + public static void autoLoot(PlayerCharacter pc, Mob mob){ + for (Item loot : mob.charItemManager.getInventory(true)) { + try { + if (loot != null && loot.getObjectType() == GameObjectType.MobLoot) { + if (loot.getItemBaseID() == 7) { + if (GroupManager.getGroup(pc) != null && GroupManager.getGroup(pc).getSplitGold()) { + GroupManager.goldSplit(pc, loot, pc.getClientConnection(), mob); + } else { + if (mob.charItemManager.getGoldInventory().getNumOfItems() > 0) { + if (pc.charItemManager.getGoldInventory().getNumOfItems() + loot.getNumOfItems() <= MBServerStatics.PLAYER_GOLD_LIMIT) { + pc.charItemManager.addGoldToInventory(loot.getNumOfItems(), false); + mob.charItemManager.delete(loot); + } + } + } + } else { + if (pc.charItemManager.hasRoomInventory(loot.getItemBase().getWeight())) { + Item convert = ((MobLoot) loot).promoteToItem(pc); + if (convert != null) { + pc.charItemManager.addItemToInventory(convert); + if (GroupManager.getGroup(pc) != null && GroupManager.getGroup(pc).getSplitGold()) { + String name = loot.getName(); + String text = pc.getFirstName() + " has looted " + name + '.'; + ChatManager.chatGroupInfoCanSee(pc, text); + } + mob.charItemManager.delete(loot); + } + } + } + } + }catch(Exception ignored){ + + } + } + pc.charItemManager.updateInventory(); + mob.charItemManager.updateInventory(); + //if(mob.charItemManager.getInventory().size() < 1) + // mob.despawn(); } public void updateLocation() {