diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 0397cd2d..9c18f65e 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -17,10 +17,7 @@ import engine.objects.*; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; +import java.util.*; import java.util.concurrent.ThreadLocalRandom; /** @@ -90,6 +87,13 @@ public enum LootManager { return; } + if(!mob.getSafeZone()) { + SpecialLootHandler.RollContract(mob); + SpecialLootHandler.RollGlass(mob); + SpecialLootHandler.RollRune(mob); + SpecialLootHandler.RollRacialGuard(mob); + } + //determine if mob is in hotzone boolean inHotzone = false; @@ -127,7 +131,10 @@ public enum LootManager { if (ib == null) break; if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) { - ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ib.getName() + ". Are you tough enough to take it?"); + Zone camp = mob.getParentZone(); + Zone macro = camp.getParent(); + String name = camp.getName() + "(" + macro.getName() + ")"; + ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + name + " has found the " + ib.getName() + ". Are you tough enough to take it?"); chatMsg.setMessageType(10); chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); @@ -141,59 +148,6 @@ public enum LootManager { boolean hotzoneWasRan = false; float dropRate; - if (!mob.getSafeZone()) { - int contractLow = 1, contractHigh = 400; - int runeLow = 401, runeHigh = 800; - int resourceLow = 801, resourceHigh = 900; - int glassLow = 901, glassHigh = 910; - int guardLow = 911, guardHigh = 920; - - // Pre-compute adjusted high values - int contractAdjust = 0, runeAdjust = 0, resourceAdjust = 0, glassAdjust = 0, guardAdjust = 0; - if (mob.level < 50) { - int dif = 50 - mob.level; - contractAdjust = (int)(400 * (dif * 0.02f)); - runeAdjust = (int)(400 * (dif * 0.02f)); - resourceAdjust = (int)(100 * (dif * 0.02f)); - glassAdjust = (int)(10 * (dif * 0.02f)); - guardAdjust = (int)(10 * (dif * 0.02f)); - } - - // Generate a single random roll - int specialCaseRoll = ThreadLocalRandom.current().nextInt(1, 100001); - - // Calculate adjusted high values once - int contractHighAdjusted = contractHigh - contractAdjust; - int runeHighAdjusted = runeHigh - runeAdjust; - int resourceHighAdjusted = resourceHigh - resourceAdjust; - int glassHighAdjusted = glassHigh - glassAdjust; - int guardHighAdjusted = guardHigh - guardAdjust; - - // Check the roll range and handle accordingly - if (specialCaseRoll >= contractLow && specialCaseRoll <= contractHighAdjusted) { - SpecialCaseContractDrop(mob, entries); - } else if (specialCaseRoll >= runeLow && specialCaseRoll <= runeHighAdjusted) { - SpecialCaseRuneDrop(mob, entries); - } else if (specialCaseRoll >= resourceLow && specialCaseRoll <= resourceHighAdjusted) { - SpecialCaseResourceDrop(mob, entries); - } else if (specialCaseRoll >= glassLow && specialCaseRoll <= glassHighAdjusted) { - int glassID = rollRandomItem(126); - ItemBase glassItem = ItemBase.getItemBase(glassID); - if (glassItem != null) { - MobLoot toAddGlass = new MobLoot(mob, glassItem, false); - mob.getCharItemManager().addItemToInventory(toAddGlass); - } - } else if (specialCaseRoll >= guardLow && specialCaseRoll <= guardHighAdjusted) { - int guardContractID = racial_guard_uuids.get(new java.util.Random().nextInt(racial_guard_uuids.size())); - ItemBase guardContract = ItemBase.getItemBase(guardContractID); - if (guardContract != null) { - MobLoot toAddContract = new MobLoot(mob, guardContract, false); - mob.getCharItemManager().addItemToInventory(toAddContract); - } - } - } - - // Iterate all entries in this bootySet and process accordingly Zone zone = ZoneManager.findSmallestZone(mob.loc); for (BootySetEntry bse : entries) { @@ -268,32 +222,6 @@ public enum LootManager { } public static void SpecialCaseRuneDrop(Mob mob,ArrayList entries){ - //int lootTableID = 0; - //for(BootySetEntry entry : entries){ - // if(entry.bootyType.equals("LOOT")){ - // lootTableID = entry.genTable; - // break; - // } - //} - - // if(lootTableID == 0) - // return; - - //int RuneTableID = 0; - //for(GenTableEntry entry : _genTables.get(lootTableID)){ - // try { - // if (ItemBase.getItemBase(_itemTables.get(entry.itemTableID).get(0).cacheID).getType().equals(Enum.ItemType.RUNE)) { - // RuneTableID = entry.itemTableID; - // break; - // } - // }catch(Exception e){ - - // } - //} - - //if(RuneTableID == 0) - // return; - int roll = ThreadLocalRandom.current().nextInt(static_rune_ids.size() + 1); int itemId = static_rune_ids.get(0); try { @@ -377,7 +305,7 @@ public enum LootManager { if (itemUUID == 0) return null; - if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { + if (ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.RESOURCE) || ItemBase.getItemBase(itemUUID).getName().equals("Mithril")) { if(ThreadLocalRandom.current().nextInt(1,101) < 91) return null; // cut down world drops rates of resources by 90% int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); @@ -446,8 +374,23 @@ public enum LootManager { return inItem; if (prefixMod.action.length() > 0) { - inItem.setPrefix(prefixMod.action); - inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); + String action = prefixMod.action; + if(action.equals("PRE-108") || action.equals("PRE-058") || action.equals("PRE-031")){//massive, barons and avatars to be replaced by leg or warlords + int roll = ThreadLocalRandom.current().nextInt(1,100); + if(inItem.getItemBase().getRange() > 15){ + action = "PRE-040"; + }else { + if (roll > 50) { + //set warlords + action = "PRE-021"; + } else { + //set legendary + action = "PRE-040"; + } + } + } + inItem.setPrefix(action); + inItem.addPermanentEnchantment(action, 0, prefixMod.level, true); } return inItem; @@ -574,6 +517,10 @@ public enum LootManager { case RESOURCE: return; } + + if (ib.getUUID() == 1580021)//mithril + return; + toAdd.setIsID(true); mob.getCharItemManager().addItemToInventory(toAdd); } @@ -633,6 +580,8 @@ public enum LootManager { if (chanceRoll > bse.dropChance) return; + if(bse.itemBase == 1580021)//mithril + return; MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); if (lootItem != null) { @@ -662,17 +611,58 @@ public enum LootManager { return; switch (ib.getUUID()) { case 971070: //wrapped rune - ItemBase runeBase = null; - int roll = ThreadLocalRandom.current().nextInt(static_rune_ids.size() + 1); - int itemId = static_rune_ids.get(0); - try { - itemId = static_rune_ids.get(roll); - }catch(Exception e){ + Random random = new Random(); + int roll = random.nextInt(100); + int itemId; + ItemBase runeBase; + if (roll >= 90) { + //35 or 40 + roll = ThreadLocalRandom.current().nextInt(SpecialLootHandler.static_rune_ids_high.size() + 1); + itemId = SpecialLootHandler.static_rune_ids_high.get(0); + try { + itemId = SpecialLootHandler.static_rune_ids_high.get(roll); + } catch (Exception e) { - } - runeBase = ItemBase.getItemBase(itemId); - if(runeBase != null) { - winnings = new MobLoot(playerCharacter, runeBase, 1, false); + } + runeBase = ItemBase.getItemBase(itemId); + if (runeBase != null) { + MobLoot rune = new MobLoot(playerCharacter, runeBase, true); + + if (rune != null) + playerCharacter.getCharItemManager().addItemToInventory(rune); + } + } else if (roll >= 65 && roll <= 89) { + //30,35 or 40 + roll = ThreadLocalRandom.current().nextInt(SpecialLootHandler.static_rune_ids_mid.size() + 1); + itemId = SpecialLootHandler.static_rune_ids_mid.get(0); + try { + itemId = SpecialLootHandler.static_rune_ids_mid.get(roll); + } catch (Exception e) { + + } + runeBase = ItemBase.getItemBase(itemId); + if (runeBase != null) { + MobLoot rune = new MobLoot(playerCharacter, runeBase, true); + + if (rune != null) + playerCharacter.getCharItemManager().addItemToInventory(rune); + } + } else { + //5-30 + roll = ThreadLocalRandom.current().nextInt(SpecialLootHandler.static_rune_ids_low.size() + 1); + itemId = SpecialLootHandler.static_rune_ids_low.get(0); + try { + itemId = SpecialLootHandler.static_rune_ids_low.get(roll); + } catch (Exception ignored) { + + } + runeBase = ItemBase.getItemBase(itemId); + if (runeBase != null) { + MobLoot rune = new MobLoot(playerCharacter, runeBase, true); + + if (rune != null) + playerCharacter.getCharItemManager().addItemToInventory(rune); + } } break; case 971012: //wrapped glass @@ -763,7 +753,7 @@ public enum LootManager { ItemBase ib = ItemBase.getItemBase(selectedItem.cacheID); if(ib.getUUID() == Warehouse.coalIB.getUUID()){ //no more coal, give gold instead - if (itemMan.getGoldInventory().getNumOfItems() + 250000 > 10000000) { + if (itemMan.getGoldInventory().getNumOfItems() + 250000 > MBServerStatics.PLAYER_GOLD_LIMIT) { ErrorPopupMsg.sendErrorPopup(playerCharacter, 21); return; } @@ -941,8 +931,8 @@ public enum LootManager { } //present drop chance for all - if (ThreadLocalRandom.current().nextInt(100) < 35) - DropPresent(mob); + //if (ThreadLocalRandom.current().nextInt(100) < 35) + // DropPresent(mob); //random contract drop chance for all if (ThreadLocalRandom.current().nextInt(100) < 40) { diff --git a/src/engine/gameManager/SpecialLootHandler.java b/src/engine/gameManager/SpecialLootHandler.java new file mode 100644 index 00000000..363e5353 --- /dev/null +++ b/src/engine/gameManager/SpecialLootHandler.java @@ -0,0 +1,249 @@ +package engine.gameManager; +import engine.InterestManagement.WorldGrid; +import engine.math.Vector3fImmutable; +import engine.objects.*; +import engine.server.MBServerStatics; +import java.util.*; +import java.util.concurrent.ThreadLocalRandom; +public class SpecialLootHandler { + + public static final ArrayList static_rune_ids_low = new ArrayList<>(Arrays.asList( + 250001, 250002, 250003, 250004, 250005, 250006, 250010, 250011, + 250012, 250013, 250014, 250015, 250019, 250020, 250021, 250022, + 250023, 250024, 250028, 250029, 250030, 250031, 250032, 250033, + 250037, 250038, 250039, 250040, 250041, 250042 + )); + public static final ArrayList static_rune_ids_mid = new ArrayList<>(Arrays.asList( + 250006, 250007, 250008, + 250015, 250016, 250017, + 250024, 250025, 250026, + 250033, 250034, 250035, + 250042, 250043, 250044 + )); + public static final ArrayList static_rune_ids_high = new ArrayList<>(Arrays.asList( + 250007, 250008, + 250016, 250017, + 250025, 250026, + 250034, 250035, + 250043, 250044 + )); + public static final List DWARVEN_contracts = Arrays.asList( + 35250, 35251, 35252, 35253, 35254, 35255, 35256, 35257, 35258, 35259, 35260, 35261, 35262, 35263 + ); + public static final List INVORRI_contracts = Arrays.asList( + 35050, 35051, 35052, 35053, 35054, 35055, 35056, 35057, 35058, 35059, 35060, 35061, 35062, 35063 + ); + public static final List SHADE_contracts = Arrays.asList( + 35400, 35401, 35402, 35403, 35404, 35405, 35406, 35407, 35408, 35409, 35410, 35411, 35412, 35413, + 35414, 35415, 35416, 35417, 35418, 35419, 35420, 35421, 35422, 35423, 35424, 35425, 35426, 35427 + ); + public static final List VAMPIRE_contracts = Arrays.asList( + 35545, 35546, 35547, 35548, 35549, 35550, 35551, 35552, 35553, 35554, 35555, 35556, 35557, 35558, + 35559, 35560, 35561, 35562, 35563, 35564, 35565, 35566, 35567, 35568, 35569, 35570 + ); + public static final List IREKEI_contracts = Arrays.asList( + 35100, 35101, 35102, 35103, 35104, 35105, 35106, 35107, 35108, 35109, 35110, 35111, 35112, 35113, + 35114, 35115, 35116, 35117, 35118, 35119, 35120, 35121, 35122, 35123, 35124, 35125, 35126, 35127 + ); + public static final List AMAZON_contracts = Arrays.asList( + 35200, 35201, 35202, 35203, 35204, 35205, 35206, 35207, 35208, 35209, 35210, 35211, 35212, 35213 + ); + public static final List GWENDANNEN_contracts = Arrays.asList( + 35350, 35351, 35352, 35353, 35354, 35355, 35356, 35357, 35358, 35359, 35360, 35361, 35362, 35363, + 35364, 35365, 35366, 35367, 35368, 35369, 35370, 35371, 35372, 35373, 35374, 35375, 35376, 35377 + ); + public static final List NEPHILIM_contracts = Arrays.asList( + 35500, 35501, 35502, 35503, 35504, 35505, 35506, 35507, 35508, 35509, 35510, 35511, 35512, 35513, + 35514, 35515, 35516, 35517, 35518, 35519, 35520, 35521, 35522, 35523, 35524, 35525 + ); + public static final List ELVEN_contracts = Arrays.asList( + 35000, 35001, 35002, 35003, 35004, 35005, 35006, 35007, 35008, 35009, 35010, 35011, 35012, 35013, + 35014, 35015, 35016, 35017, 35018, 35019, 35020, 35021, 35022, 35023, 35024, 35025, 35026, 35027 + ); + public static final List CENTAUR_contracts = Arrays.asList( + 35150, 35151, 35152, 35153, 35154, 35155, 35156, 35157, 35158, 35159, 35160, 35161, 35162, 35163, + 35164, 35165, 35166, 35167, 35168, 35169, 35170, 35171, 35172, 35173, 35174, 35175, 35176, 35177 + ); + public static final List LIZARDMAN_contracts = Arrays.asList( + 35300, 35301, 35302, 35303, 35304, 35305, 35306, 35307, 35308, 35309, 35310, 35311, 35312, 35313 + ); + public static final List GLASS_ITEMS = Arrays.asList( + 7000100, 7000110, 7000120, 7000130, 7000140, 7000150, 7000160, 7000170, 7000180, 7000190, + 7000200, 7000210, 7000220, 7000230, 7000240, 7000250, 7000270, 7000280 + ); + public static final List STAT_RUNES = Arrays.asList( + 250001, 250002, 250003, 250004, 250005, 250006, 250007, 250008, 250010, 250011, + 250012, 250013, 250014, 250015, 250016, 250017, 250019, 250020, 250021, 250022, + 250023, 250024, 250025, 250026, 250028, 250029, 250030, 250031, 250032, 250033, + 250034, 250035, 250037, 250038, 250039, 250040, 250041, 250042, 250043, 250044 + ); + public static final List racial_guard = Arrays.asList( + 841,951,952,1050,1052,1180,1182,1250,1252,1350,1352,1450, + 1452,1500,1502,1525,1527,1550,1552,1575,1577,1600,1602,1650,1652,1700,980100, + 980102 + ); + public static void RollContract(Mob mob){ + Zone zone = getMacroZone(mob); + if(zone == null) + return; + int contactId = 0; + int roll = ThreadLocalRandom.current().nextInt(250); + if(roll == 125){ + contactId = getContractForZone(zone); + } + if(contactId == 0) + return; + ItemBase contractBase = ItemBase.getItemBase(contactId); + if(contractBase == null) + return; + if(mob.getCharItemManager() == null) + return; + MobLoot contract = new MobLoot(mob,contractBase,false); + mob.getCharItemManager().addItemToInventory(contract); + } + public static Zone getMacroZone(Mob mob){ + Zone parentZone = mob.parentZone; + if(parentZone == null) + return null; + while(!parentZone.isMacroZone() && !parentZone.equals(ZoneManager.getSeaFloor())){ + parentZone = parentZone.getParent(); + } + return parentZone; + } + public static int getContractForZone(Zone zone){ + Random random = new Random(); + switch (zone.getObjectUUID()) + { + case 178: + // Kralgaar Holm + return DWARVEN_contracts.get(random.nextInt(DWARVEN_contracts.size())); + case 122: + // Aurrochs Skrae + return INVORRI_contracts.get(random.nextInt(INVORRI_contracts.size())); + case 197: + // Ymur's Crown + return INVORRI_contracts.get(random.nextInt(INVORRI_contracts.size())); + case 234: + // Ecklund Wilds + return INVORRI_contracts.get(random.nextInt(INVORRI_contracts.size())); + case 313: + // Greensward Pyre + return SHADE_contracts.get(random.nextInt(SHADE_contracts.size())); + case 331: + // The Doomplain + return VAMPIRE_contracts.get(random.nextInt(VAMPIRE_contracts.size())); + case 353: + // Thollok Marsh + return LIZARDMAN_contracts.get(random.nextInt(LIZARDMAN_contracts.size())); + case 371: + // The Black Bog + return LIZARDMAN_contracts.get(random.nextInt(LIZARDMAN_contracts.size())); + case 388: + // Sevaath Mere + return LIZARDMAN_contracts.get(random.nextInt(LIZARDMAN_contracts.size())); + case 418: + // Valkos Wilds + return GWENDANNEN_contracts.get(random.nextInt(GWENDANNEN_contracts.size())); + case 437: + // Grimscairne + return SHADE_contracts.get(random.nextInt(SHADE_contracts.size())); + case 475: + // Phaedra's Prize + return AMAZON_contracts.get(random.nextInt(AMAZON_contracts.size())); + case 491: + // Holloch Forest + return GWENDANNEN_contracts.get(random.nextInt(GWENDANNEN_contracts.size())); + case 508: + // Aeran Belendor + return ELVEN_contracts.get(random.nextInt(ELVEN_contracts.size())); + case 532: + // Tainted Swamp + return NEPHILIM_contracts.get(random.nextInt(NEPHILIM_contracts.size())); + case 550: + // Aerath Hellendroth + return ELVEN_contracts.get(random.nextInt(ELVEN_contracts.size())); + case 569: + // Aedroch Highlands + return GWENDANNEN_contracts.get(random.nextInt(GWENDANNEN_contracts.size())); + case 590: + // Fellgrim Forest + return GWENDANNEN_contracts.get(random.nextInt(GWENDANNEN_contracts.size())); + case 616: + // Derros Plains + return CENTAUR_contracts.get(random.nextInt(CENTAUR_contracts.size())); + case 632: + // Ashfell Plain + return SHADE_contracts.get(random.nextInt(SHADE_contracts.size())); + case 717: + // Kharsoom + return IREKEI_contracts.get(random.nextInt(IREKEI_contracts.size())); + case 737: + // Leth'khalivar Desert + return IREKEI_contracts.get(random.nextInt(IREKEI_contracts.size())); + case 761: + // The Blood Sands + return IREKEI_contracts.get(random.nextInt(IREKEI_contracts.size())); + case 785: + // Vale of Nar Addad + return IREKEI_contracts.get(random.nextInt(IREKEI_contracts.size())); + case 824: + // Western Battleground + return NEPHILIM_contracts.get(random.nextInt(NEPHILIM_contracts.size())); + case 842: + // Pandemonium + return NEPHILIM_contracts.get(random.nextInt(NEPHILIM_contracts.size())); + case 951: + //Bone Marches + return VAMPIRE_contracts.get(random.nextInt(VAMPIRE_contracts.size())); + case 952: + //plain of ashes + return VAMPIRE_contracts.get(random.nextInt(VAMPIRE_contracts.size())); + } + return 0; + } + public static void RollGlass(Mob mob){ + int roll = ThreadLocalRandom.current().nextInt(10000); + if(roll != 5000) + return; + Random random = new Random(); + int glassId = GLASS_ITEMS.get(random.nextInt(GLASS_ITEMS.size())); + ItemBase glassBase = ItemBase.getItemBase(glassId); + if(glassBase == null) + return; + if(mob.getCharItemManager() == null) + return; + MobLoot glass = new MobLoot(mob,glassBase,false); + mob.getCharItemManager().addItemToInventory(glass); + } + public static void RollRune(Mob mob){ + int runeID = 0; + int roll = ThreadLocalRandom.current().nextInt(250); + Random random = new Random(); + if(roll == 125){ + runeID = STAT_RUNES.get(random.nextInt(STAT_RUNES.size())); + } + if(runeID == 0) + return; + ItemBase runeBase = ItemBase.getItemBase(runeID); + if(runeBase == null) + return; + if(mob.getCharItemManager() == null) + return; + MobLoot rune = new MobLoot(mob,runeBase,false); + mob.getCharItemManager().addItemToInventory(rune); + } + public static void RollRacialGuard(Mob mob){ + int roll = ThreadLocalRandom.current().nextInt(5000); + if(roll != 2500) + return; + Random random = new Random(); + int guardId = racial_guard.get(random.nextInt(racial_guard.size())); + ItemBase guardBase = ItemBase.getItemBase(guardId); + if(guardBase == null) + return; + if(mob.getCharItemManager() == null) + return; + MobLoot guard = new MobLoot(mob,guardBase,false); + mob.getCharItemManager().addItemToInventory(guard); + } +}