diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 7159e15b..78186abb 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -85,6 +85,10 @@ public enum LootManager { if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet)) RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone); + //check for special gifts 1/100 to drop present + if(ThreadLocalRandom.current().nextInt(1,101) == 50) + DropPresent(mob); + //lastly, check mobs inventory for godly or disc runes to send a server announcement for (Item it : mob.getInventory()) { @@ -429,7 +433,7 @@ public enum LootManager { //check if player owns the gift he is trying to open - if (itemMan.doesCharOwnThisItem(gift.getObjectUUID()) == false) + if (!itemMan.doesCharOwnThisItem(gift.getObjectUUID())) return; //roll 1-100 for the gen table selection @@ -450,46 +454,57 @@ public enum LootManager { //create the item from the table, quantity is always 1 - MobLoot winnings = new MobLoot(playerCharacter, ItemBase.getItemBase(selectedItem.cacheID), 1, false); + ItemBase ib = ItemBase.getItemBase(selectedItem.cacheID); + if(ib.getUUID() == Warehouse.coalIB.getUUID()){ + //no more coal, give gold instead + if (itemMan.getGoldInventory().getNumOfItems() + 250000 > 10000000) { + ErrorPopupMsg.sendErrorPopup(playerCharacter, 21); + return; + } + itemMan.addGoldToInventory(250000,false); + itemMan.updateInventory(); + }else { + MobLoot winnings = new MobLoot(playerCharacter, ib, 1, false); - if (winnings == null) - return; + if (winnings == null) + return; - //early exit if the inventory of the player will not old the item + //early exit if the inventory of the player will not hold the item - if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) { - ErrorPopupMsg.sendErrorPopup(playerCharacter, 21); - return; - } + if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) { + ErrorPopupMsg.sendErrorPopup(playerCharacter, 21); + return; + } - //determine if the winning item needs a prefix + //determine if the winning item needs a prefix - if(selectedRow.pModTable != 0){ - int prefixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); - ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll); - if(prefix != null) - winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true); - } + if (selectedRow.pModTable != 0) { + int prefixRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1); + ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll); + if (prefix != null) + winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true); + } - //determine if the winning item needs a suffix + //determine if the winning item needs a suffix - if(selectedRow.sModTable != 0){ - int suffixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); - ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll); - if (suffix != null) - winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true); - } - winnings.setIsID(true); + if (selectedRow.sModTable != 0) { + int suffixRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1); + ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll); + if (suffix != null) + winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true); + } + winnings.setIsID(true); - //remove gift from inventory + //remove gift from inventory - itemMan.consume(gift); + itemMan.consume(gift); - //add winnings to player inventory + //add winnings to player inventory - Item playerWinnings = winnings.promoteToItem(playerCharacter); - itemMan.addItemToInventory(playerWinnings); - itemMan.updateInventory(); + Item playerWinnings = winnings.promoteToItem(playerCharacter); + itemMan.addItemToInventory(playerWinnings); + itemMan.updateInventory(); + } } public static int rollRandomItem(int itemTable){ @@ -585,4 +600,15 @@ public enum LootManager { return null; } + + public static void DropPresent(Mob mob){ + int random = ThreadLocalRandom.current().nextInt(ItemBase.AnniverseryGifts.size()); + int presentID = ItemBase.AnniverseryGifts.get(random); + ItemBase presentBase = ItemBase.getItemBase(presentID); + if(presentBase != null){ + MobLoot lootItem = new MobLoot(mob, presentBase, true); + mob.getCharItemManager().addItemToInventory(lootItem); + } + + } } diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index d6ef538e..de37e948 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -421,31 +421,12 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { itemMan.consume(item); } break; - //ANNIVERSERY GIFT case 31: - // *** Disabled for now: Needs bootyset created - - //if (ib.getUUID() == 971012) { - // int random = ThreadLocalRandom.current().nextInt(ItemBase.AnniverseryGifts.size()); - // int annyID = ItemBase.AnniverseryGifts.get(random); - - // ItemBase annyIB = ItemBase.getItemBase(annyID); - // if (annyIB != null) { - // Item gift = MobLoot.createItemForPlayer(player, annyIB); - // if (gift != null) { - // itemMan.addItemToInventory(gift); - // itemMan.consume(item); - // } - // } - // break; - //} - LootManager.peddleFate(player,item); break; case 30: //water bucket case 8: //potions, tears of saedron - case 5: //runes, petition, warrant, scrolls if (uuid > 3000 && uuid < 3050) { //Discipline Runes if (ApplyRuneMsg.applyRune(uuid, origin, player)) { @@ -528,7 +509,6 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { } // Send piss bucket animation - VisualUpdateMessage vum = new VisualUpdateMessage(player, 16323); vum.configure(); DispatchMessage.sendToAllInRange(player, vum);