From eaeb2eb9437a6cc85eb032edb477a69e3a18142f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 10 Mar 2025 20:14:11 -0500 Subject: [PATCH] forge manager cleanup and special drop rates --- .../gameManager/SpecialLootHandler.java | 23 ++++++++--- src/engine/objects/ItemFactory.java | 38 ++++++------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/engine/gameManager/SpecialLootHandler.java b/src/engine/gameManager/SpecialLootHandler.java index 7d09bd57..44f74e1e 100644 --- a/src/engine/gameManager/SpecialLootHandler.java +++ b/src/engine/gameManager/SpecialLootHandler.java @@ -105,13 +105,24 @@ public class SpecialLootHandler { } 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; - } + + Zone parentZone = mob.parentZone; + if(parentZone == null) + return null; + + while(!parentZone.isMacroZone() && !parentZone.equals(ZoneManager.getSeaFloor())){ + parentZone = parentZone.getParent(); } - return null; + + return parentZone; + + //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){ diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 818ea434..928d4055 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -26,6 +26,7 @@ import org.joda.time.DateTime; import org.pmw.tinylog.Logger; import java.util.ArrayList; +import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -679,58 +680,40 @@ public class ItemFactory { return null; } - for (byte temp : vendor.getItemModTable()) { - - if (itemModTable != temp) - continue; - - prefixMod = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(temp)); - suffixMod = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(temp)); - } + Random random = new Random(); + prefixMod = vendor.getModTypeTable().get(random.nextInt(vendor.getModTypeTable().size())); + suffixMod = vendor.getModSuffixTable().get(random.nextInt(vendor.getModTypeTable().size())); if (prefixMod == 0 && suffixMod == 0) { Logger.info("Failed to find modTables for item " + ib.getName()); return null; } - // Roll on the tables for this vendor + ArrayList prefixTable = LootManager._modTypeTables.get(prefixMod); + ArrayList suffixTable = LootManager._modTypeTables.get(suffixMod); - ModTypeTableEntry prefixTypeTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - ModTypeTableEntry suffixTypeTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + ModTypeTableEntry prefixTypeTable = prefixTable.get(random.nextInt(prefixTable.size())); + ModTypeTableEntry suffixTypeTable = suffixTable.get(random.nextInt(suffixTable.size())); // Sanity check. if (prefixTypeTable == null || suffixTypeTable == null) return null; - int rollPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); + int rollPrefix = ThreadLocalRandom.current().nextInt(100); if (rollPrefix < vendor.getLevel() + 30) { - int randomPrefix = TableRoll(vendor.getLevel()); - if(vendor.contract.getName().contains("Heavy") || vendor.contract.getName().contains("Medium") || vendor.contract.getName().contains("Leather")) - randomPrefix += vendor.level * 0.5f; - if(randomPrefix > 320) - randomPrefix = 320; prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); - if (prefixEntry != null) prefix = prefixEntry.action; - } - int rollSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - - // Always have at least one mod on a magic rolled item. - // Suffix will be our backup plan. + int rollSuffix = ThreadLocalRandom.current().nextInt( 100); if (rollSuffix < vendor.getLevel() + 30) { int randomSuffix = TableRoll(vendor.getLevel()); - if(vendor.contract.getName().contains("Heavy") || vendor.contract.getName().contains("Medium") || vendor.contract.getName().contains("Leather")) - randomSuffix += vendor.level * 0.25f; - if(randomSuffix > 320) - randomSuffix = 320; suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); if (suffixEntry != null) @@ -1092,4 +1075,5 @@ public class ItemFactory { return ml; } + }