diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 5e3f0d4f..498bc909 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -90,6 +90,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; @@ -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) { diff --git a/src/engine/gameManager/SpecialLootHandler.java b/src/engine/gameManager/SpecialLootHandler.java new file mode 100644 index 00000000..7d09bd57 --- /dev/null +++ b/src/engine/gameManager/SpecialLootHandler.java @@ -0,0 +1,266 @@ +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 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){ + for(Zone zone : ZoneManager.macroZones){ + HashSet inZone = WorldGrid.getObjectsInRangePartial(zone.getLoc(),zone.getBounds().getHalfExtents().x * 2f, MBServerStatics.MASK_MOB); + if(inZone.contains(mob)){ + return zone; + } + } + return null; + } + + 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); + } +} diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 0eb10a2f..bf2c17d8 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -246,7 +246,7 @@ public class MobAI { //no weapons, default mob attack speed 3 seconds. - MobVsMobRetaliate(target,mob); + //MobVsMobRetaliate(target,mob); ItemBase mainHand = mob.getWeaponItemBase(true); ItemBase offHand = mob.getWeaponItemBase(false);