forked from MagicBane/Server
autoloot
This commit is contained in:
@@ -1242,6 +1242,50 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
killCleanup();
|
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() {
|
public void updateLocation() {
|
||||||
|
|||||||
Reference in New Issue
Block a user