Browse Source

autoloot

mixbane
FatBoy-DOTC 7 days ago
parent
commit
d4d320264c
  1. 44
      src/engine/objects/Mob.java

44
src/engine/objects/Mob.java

@ -1242,6 +1242,50 @@ public class Mob extends AbstractIntelligenceAgent { @@ -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() {

Loading…
Cancel
Save