From 4932ee36eacf19264537eaea6b861dcb1a2a865f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 29 Jul 2023 19:04:59 -0500 Subject: [PATCH 1/5] catch code for loot crash --- src/engine/loot/LootManager.java | 175 ++++++++++++++++--------------- 1 file changed, 90 insertions(+), 85 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 02582c5b..5e66c0f4 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -16,6 +16,7 @@ import engine.gameManager.ZoneManager; import engine.net.DispatchMessage; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; +import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; @@ -47,7 +48,6 @@ public class LootManager { } public static void GenerateMobLoot(Mob mob, boolean fromDeath) { - try{ //determine if mob is in hotzone boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); //get multiplier form config manager @@ -76,107 +76,115 @@ public class LootManager { } } - } catch(Exception e){ - //TODO catch whatever went wrong - } } private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { - if (fromDeath) { - //do equipment here - if (mob.getEquip() != null) { - for (MobEquipment me : mob.getEquip().values()) { - if (me.getDropChance() == 0) - continue; - float equipmentRoll = ThreadLocalRandom.current().nextInt(101); - float dropChance = me.getDropChance() * 100; - if (equipmentRoll <= (dropChance * multiplier)) { - MobLoot ml = new MobLoot(mob, me.getItemBase(), false); - if(ml.getPrefix().isEmpty() == true && ml.getSuffix().isEmpty() == true){ - ml.setIsID(true); + int roll; // table roll + BootySetEntry entry = null; + int setCount = 0; + try { + if (fromDeath) { + //do equipment here + if (mob.getEquip() != null) { + for (MobEquipment me : mob.getEquip().values()) { + if (me.getDropChance() == 0) + continue; + float equipmentRoll = ThreadLocalRandom.current().nextInt(101); + float dropChance = me.getDropChance() * 100; + if (equipmentRoll <= (dropChance * multiplier)) { + MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + if (ml.getPrefix().isEmpty() == true && ml.getSuffix().isEmpty() == true) { + ml.setIsID(true); + } + mob.getCharItemManager().addItemToInventory(ml); } - mob.getCharItemManager().addItemToInventory(ml); } } + return; } - return; - } - for (BootySetEntry bse : entries) { - int roll; - float dropChance = bse.dropChance * multiplier; - switch (bse.bootyType) { - case "GOLD": - roll = ThreadLocalRandom.current().nextInt(101); - if (roll > dropChance) { - //early exit, failed to hit minimum chance roll OR booty was generated from mob's death - break; - } - //determine and add gold to mob inventory - int gold = new Random().nextInt(bse.highGold - bse.lowGold) + bse.lowGold; - if (gold > 0) { - MobLoot goldAmount = new MobLoot(mob, (int) (gold * multiplier)); - mob.getCharItemManager().addItemToInventory(goldAmount); - } - break; - case "LOOT": - roll = ThreadLocalRandom.current().nextInt(101); - if (roll > dropChance) { - //early exit, failed to hit minimum chance roll + for (BootySetEntry bse : entries) { + entry = bse; + float dropChance = bse.dropChance * multiplier; + switch (bse.bootyType) { + case "GOLD": + roll = ThreadLocalRandom.current().nextInt(101); + if (roll > dropChance) { + //early exit, failed to hit minimum chance roll OR booty was generated from mob's death + break; + } + //determine and add gold to mob inventory + int gold = new Random().nextInt(bse.highGold - bse.lowGold) + bse.lowGold; + if (gold > 0) { + MobLoot goldAmount = new MobLoot(mob, (int) (gold * multiplier)); + mob.getCharItemManager().addItemToInventory(goldAmount); + } break; - } - //iterate the booty tables and add items to mob inventory - MobLoot toAdd = getGenTableItem(bse.lootTable, mob); - if (toAdd != null) { - if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){ - toAdd.setIsID(true); + case "LOOT": + roll = ThreadLocalRandom.current().nextInt(101); + if (roll > dropChance) { + //early exit, failed to hit minimum chance roll + break; } - mob.getCharItemManager().addItemToInventory(toAdd); - } - if (inHotzone) { - if (generalItemTables.containsKey(bse.lootTable + 1)) { - int lootTableID = bse.lootTable + 1; - MobLoot toAddHZ = getGenTableItem(lootTableID, mob); - if (toAddHZ != null) - if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){ - toAdd.setIsID(true); - } + //iterate the booty tables and add items to mob inventory + MobLoot toAdd = getGenTableItem(bse.lootTable, mob); + if (toAdd != null) { + if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { + toAdd.setIsID(true); + } + mob.getCharItemManager().addItemToInventory(toAdd); + } + if (inHotzone) { + if (generalItemTables.containsKey(bse.lootTable + 1)) { + int lootTableID = bse.lootTable + 1; + MobLoot toAddHZ = getGenTableItem(lootTableID, mob); + if (toAddHZ != null) + if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { + toAdd.setIsID(true); + } mob.getCharItemManager().addItemToInventory(toAddHZ); + } } - } - break; - case "ITEM": - MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); - if (disc != null && !fromDeath) - mob.getCharItemManager().addItemToInventory(disc); + break; + case "ITEM": + MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); + if (disc != null && !fromDeath) + mob.getCharItemManager().addItemToInventory(disc); - break; - } - } - if (inHotzone) { - //hotzone glass roll, 1% chance to roll on glass table - if (ThreadLocalRandom.current().nextInt(101) > 99) { - int roll2 = TableRoll(mob.level); - if (itemTables.get(126).getRowForRange(roll2) == null) { - return; - } - ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2); - if(tableRow == null){ - return; + break; } - int itemUUID = tableRow.cacheID; - if (itemUUID == 0) { - return; + } + if (inHotzone) { + //hotzone glass roll, 1% chance to roll on glass table + if (ThreadLocalRandom.current().nextInt(101) > 99) { + int roll2 = TableRoll(mob.level); + if (itemTables.get(126).getRowForRange(roll2) == null) { + return; + } + ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2); + if (tableRow == null) { + return; + } + int itemUUID = tableRow.cacheID; + if (itemUUID == 0) { + return; + } + MobLoot toAddHZ = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if (toAddHZ != null) + mob.getCharItemManager().addItemToInventory(toAddHZ); } - MobLoot toAddHZ = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - if (toAddHZ != null) - mob.getCharItemManager().addItemToInventory(toAddHZ); } + setCount++; + }catch(Exception e){ + //catch crash bug + int tableID = entry.lootTable; + String bootyType = entry.bootyType; + int itemBase = entry.itemBase; + Logger.error("FAILED LOOT ROLL: TableID: " + tableID + "bootyType: " + bootyType + " itemUUID: " + itemBase); } } public static MobLoot getGenTableItem(int genTableID, Mob mob) { - try { if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { return null; } @@ -237,9 +245,6 @@ public class LootManager { } } return outItem; - }catch(Exception e){ - return null; - } } private static int TableRoll(int mobLevel){ int max = (int)(4.882 * mobLevel + 121.0); From 707fc9f7568dff3d32414f29adc696e023ce697c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 29 Jul 2023 20:57:24 -0500 Subject: [PATCH 2/5] fixed mob loot crash --- src/engine/loot/LootManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 5e66c0f4..a3d3be43 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -137,11 +137,12 @@ public class LootManager { if (generalItemTables.containsKey(bse.lootTable + 1)) { int lootTableID = bse.lootTable + 1; MobLoot toAddHZ = getGenTableItem(lootTableID, mob); - if (toAddHZ != null) - if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { - toAdd.setIsID(true); + if (toAddHZ != null) { + if (toAddHZ.getPrefix() != null && toAddHZ.getPrefix().isEmpty() == true && toAddHZ.getSuffix() != null && toAddHZ.getSuffix().isEmpty() == true) { + toAddHZ.setIsID(true); } - mob.getCharItemManager().addItemToInventory(toAddHZ); + mob.getCharItemManager().addItemToInventory(toAddHZ); + } } } break; From 23af1d252ef960b50ba21b245da5e6ae7836f4d6 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Jul 2023 11:43:26 -0500 Subject: [PATCH 3/5] cleanup loot manager --- src/engine/loot/LootManager.java | 200 +++++++++++++++---------------- 1 file changed, 96 insertions(+), 104 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index a3d3be43..db3395f0 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -53,14 +53,14 @@ public class LootManager { //get multiplier form config manager float multiplier = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); if (inHotzone) { - //if mob is inside hotzone, use the hotzone gold multiplier form the config instead + //if mob is inside hotzone, use the hotzone multiplier from the config instead multiplier = Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue()); } //iterate the booty sets - if (mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet)) { + if (mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet) == true) { RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, multiplier, inHotzone, fromDeath); } - if (mob.bootySet != 0) { + if (mob.bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.bootySet) == true) { RunBootySet(NPCManager._bootySetMap.get(mob.bootySet), mob, multiplier, inHotzone, fromDeath); } //lastly, check mobs inventory for godly or disc runes to send a server announcement @@ -77,114 +77,32 @@ public class LootManager { } } } - private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { - int roll; // table roll - BootySetEntry entry = null; - int setCount = 0; - try { if (fromDeath) { - //do equipment here - if (mob.getEquip() != null) { - for (MobEquipment me : mob.getEquip().values()) { - if (me.getDropChance() == 0) - continue; - float equipmentRoll = ThreadLocalRandom.current().nextInt(101); - float dropChance = me.getDropChance() * 100; - if (equipmentRoll <= (dropChance * multiplier)) { - MobLoot ml = new MobLoot(mob, me.getItemBase(), false); - if (ml.getPrefix().isEmpty() == true && ml.getSuffix().isEmpty() == true) { - ml.setIsID(true); - } - mob.getCharItemManager().addItemToInventory(ml); - } - } + DropEquipment(mob,multiplier); + if (inHotzone) { + //all mobs in HZ get to roll for glass + RollForGlass(mob); } return; } for (BootySetEntry bse : entries) { - entry = bse; - float dropChance = bse.dropChance * multiplier; switch (bse.bootyType) { case "GOLD": - roll = ThreadLocalRandom.current().nextInt(101); - if (roll > dropChance) { - //early exit, failed to hit minimum chance roll OR booty was generated from mob's death - break; - } - //determine and add gold to mob inventory - int gold = new Random().nextInt(bse.highGold - bse.lowGold) + bse.lowGold; - if (gold > 0) { - MobLoot goldAmount = new MobLoot(mob, (int) (gold * multiplier)); - mob.getCharItemManager().addItemToInventory(goldAmount); - } + GenerateGoldDrop(mob,bse,multiplier); break; case "LOOT": - roll = ThreadLocalRandom.current().nextInt(101); - if (roll > dropChance) { - //early exit, failed to hit minimum chance roll - break; - } - //iterate the booty tables and add items to mob inventory - MobLoot toAdd = getGenTableItem(bse.lootTable, mob); - if (toAdd != null) { - if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { - toAdd.setIsID(true); - } - mob.getCharItemManager().addItemToInventory(toAdd); - } + GenerateNormalLootDrop(mob,bse,multiplier); if (inHotzone) { - if (generalItemTables.containsKey(bse.lootTable + 1)) { - int lootTableID = bse.lootTable + 1; - MobLoot toAddHZ = getGenTableItem(lootTableID, mob); - if (toAddHZ != null) { - if (toAddHZ.getPrefix() != null && toAddHZ.getPrefix().isEmpty() == true && toAddHZ.getSuffix() != null && toAddHZ.getSuffix().isEmpty() == true) { - toAddHZ.setIsID(true); - } - mob.getCharItemManager().addItemToInventory(toAddHZ); - } - } + GenerateHotzoneLootDrop(mob,bse,multiplier); } break; case "ITEM": - MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); - if (disc != null && !fromDeath) - mob.getCharItemManager().addItemToInventory(disc); - + GenerateItemLootDrop(mob,bse); break; } } - if (inHotzone) { - //hotzone glass roll, 1% chance to roll on glass table - if (ThreadLocalRandom.current().nextInt(101) > 99) { - int roll2 = TableRoll(mob.level); - if (itemTables.get(126).getRowForRange(roll2) == null) { - return; - } - ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2); - if (tableRow == null) { - return; - } - int itemUUID = tableRow.cacheID; - if (itemUUID == 0) { - return; - } - MobLoot toAddHZ = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - if (toAddHZ != null) - mob.getCharItemManager().addItemToInventory(toAddHZ); - } - } - setCount++; - }catch(Exception e){ - //catch crash bug - int tableID = entry.lootTable; - String bootyType = entry.bootyType; - int itemBase = entry.itemBase; - Logger.error("FAILED LOOT ROLL: TableID: " + tableID + "bootyType: " + bootyType + " itemUUID: " + itemBase); - } } - - public static MobLoot getGenTableItem(int genTableID, Mob mob) { if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { return null; @@ -256,6 +174,91 @@ public class LootManager { int roll = ThreadLocalRandom.current().nextInt(max-min) + min; return roll; } + public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, float multiplier){ + int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; + if (chanceRoll > bse.dropChance) { + //early exit, failed to hit minimum chance roll OR booty was generated from mob's death + return; + } + //determine and add gold to mob inventory + int high = (int)(bse.highGold * multiplier); + int low = (int)(bse.lowGold * multiplier); + int gold = ThreadLocalRandom.current().nextInt(high - low) + low; + if (gold > 0) { + MobLoot goldAmount = new MobLoot(mob, (int) (gold * multiplier)); + mob.getCharItemManager().addItemToInventory(goldAmount); + } + } + public static void GenerateNormalLootDrop(Mob mob, BootySetEntry bse,float multiplier){ + int chanceRoll = ThreadLocalRandom.current().nextInt(101); + if (chanceRoll > bse.dropChance) { + //early exit, failed to hit minimum chance roll + return; + } + //iterate the booty tables and add items to mob inventory + MobLoot toAdd = getGenTableItem(bse.lootTable, mob); + if (toAdd != null) { + if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { + toAdd.setIsID(true); + } + mob.getCharItemManager().addItemToInventory(toAdd); + } + } + public static void GenerateHotzoneLootDrop(Mob mob, BootySetEntry bse, float multiplier){ + if (generalItemTables.containsKey(bse.lootTable + 1)) { + int lootTableID = bse.lootTable + 1; + MobLoot toAdd = getGenTableItem(lootTableID, mob); + if (toAdd != null) { + if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { + toAdd.setIsID(true); + } + mob.getCharItemManager().addItemToInventory(toAdd); + } + } + } + public static void RollForGlass(Mob mob){ + if (ThreadLocalRandom.current().nextInt(101) > 99) { + int roll2 = TableRoll(mob.level); + if (itemTables.get(126).getRowForRange(roll2) == null) { + return; + } + ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2); + if (tableRow == null) { + return; + } + int itemUUID = tableRow.cacheID; + if (itemUUID == 0) { + return; + } + MobLoot toAddHZ = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if (toAddHZ != null) + mob.getCharItemManager().addItemToInventory(toAddHZ); + } + } + public static void DropEquipment(Mob mob, float multiplier){ + //do equipment here + if (mob.getEquip() != null) { + for (MobEquipment me : mob.getEquip().values()) { + if (me.getDropChance() == 0) + continue; + float equipmentRoll = ThreadLocalRandom.current().nextInt(101); + float dropChance = me.getDropChance() * 100; + if (equipmentRoll <= (dropChance * multiplier)) { + MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + if (ml.getPrefix().isEmpty() == true && ml.getSuffix().isEmpty() == true) { + ml.setIsID(true); + } + mob.getCharItemManager().addItemToInventory(ml); + } + } + } + return; + } + public static void GenerateItemLootDrop(Mob mob, BootySetEntry bse){ + MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); + if (disc != null) + mob.getCharItemManager().addItemToInventory(disc); + } public static void AddGenTableRow(int tableID, GenTableRow row) { if (!generalItemTables.containsKey(tableID)) { //create the new table @@ -268,7 +271,6 @@ public class LootManager { toAdd.rows.add(row); } } - public static void AddItemTableRow(int tableID, ItemTableRow row) { if (!itemTables.containsKey(tableID)) { //create the new table @@ -281,7 +283,6 @@ public class LootManager { toAdd.rows.add(row); } } - public static void AddModTypeTableRow(int tableID, ModTypeTableRow row) { if (!modTypeTables.containsKey(tableID)) { //create the new table @@ -294,7 +295,6 @@ public class LootManager { toAdd.rows.add(row); } } - public static void AddModTableRow(int tableID, ModTableRow row) { if (!modTables.containsKey(tableID)) { //create the new table @@ -307,7 +307,6 @@ public class LootManager { toAdd.rows.add(row); } } - public static class GenTable { public ArrayList rows = new ArrayList(); @@ -321,7 +320,6 @@ public class LootManager { return outRow; } } - public static class ItemTable { public ArrayList rows = new ArrayList(); @@ -338,7 +336,6 @@ public class LootManager { return outRow; } } - public static class ModTypeTable { public ArrayList rows = new ArrayList(); @@ -352,7 +349,6 @@ public class LootManager { return outRow; } } - public static class ModTable { public ArrayList rows = new ArrayList(); @@ -369,7 +365,6 @@ public class LootManager { return outRow; } } - public static class GenTableRow { public int minRoll; public int maxRoll; @@ -385,7 +380,6 @@ public class LootManager { this.sModTable = rs.getInt("sModTableID"); } } - public static class ItemTableRow { public int minRoll; public int maxRoll; @@ -402,7 +396,6 @@ public class LootManager { } } - public static class ModTypeTableRow { public int minRoll; public int maxRoll; @@ -415,7 +408,6 @@ public class LootManager { } } - public static class ModTableRow { public int minRoll; public int maxRoll; From c104d9fa002114e2961419c6dcf7135e2b92d059 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Jul 2023 13:55:08 -0500 Subject: [PATCH 4/5] r8 loot roll work --- src/engine/devcmd/cmds/simulateBootyCmd.java | 5 ++- src/engine/loot/LootManager.java | 32 +++++++++++++++----- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/engine/devcmd/cmds/simulateBootyCmd.java b/src/engine/devcmd/cmds/simulateBootyCmd.java index c6eed230..e946c3a6 100644 --- a/src/engine/devcmd/cmds/simulateBootyCmd.java +++ b/src/engine/devcmd/cmds/simulateBootyCmd.java @@ -87,7 +87,7 @@ public class simulateBootyCmd extends AbstractDevCmd { ArrayList Offerings = new ArrayList(); ArrayList OtherDrops = new ArrayList(); int failures = 0; - for (int i = 0; i < 100; ++i) { + for (int i = 0; i < 1; ++i) { try { mob.loadInventory(); @@ -141,6 +141,9 @@ public class simulateBootyCmd extends AbstractDevCmd { output += "GLASS DROPS: " + GlassItems.size() + newline; output += "RUNE DROPS: " + Runes.size() + newline; output += "CONTRACTS DROPS: " + Contracts.size() + newline; + for (Item contract : Contracts){ + output += contract.getName() + newline; + } output += "RESOURCE DROPS: " + Resources.size() + newline; output += "OFFERINGS DROPPED: " + Offerings.size() + newline; output += "OTHER ITEMS DROPPED: " + OtherDrops.size() + newline; diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index db3395f0..04cef78b 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -93,8 +93,14 @@ public class LootManager { break; case "LOOT": GenerateNormalLootDrop(mob,bse,multiplier); - if (inHotzone) { - GenerateHotzoneLootDrop(mob,bse,multiplier); + if (inHotzone && mob.level < 80) { + if (generalItemTables.containsKey(bse.lootTable + 1)) { + GenerateHotzoneLootDrop(mob, bse, multiplier); + } + RollForGlass(mob); + } + if(mob.level > 80){ + RollForGlass(mob); } break; case "ITEM": @@ -166,6 +172,9 @@ public class LootManager { return outItem; } private static int TableRoll(int mobLevel){ + if(mobLevel > 65){ + mobLevel = 65; + } int max = (int)(4.882 * mobLevel + 121.0); if(max > 320){ max = 320; @@ -190,23 +199,33 @@ public class LootManager { } } public static void GenerateNormalLootDrop(Mob mob, BootySetEntry bse,float multiplier){ - int chanceRoll = ThreadLocalRandom.current().nextInt(101); - if (chanceRoll > bse.dropChance) { + try{ + int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; + if (chanceRoll > bse.dropChance * multiplier) { //early exit, failed to hit minimum chance roll return; } //iterate the booty tables and add items to mob inventory MobLoot toAdd = getGenTableItem(bse.lootTable, mob); if (toAdd != null) { - if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { + if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ toAdd.setIsID(true); } mob.getCharItemManager().addItemToInventory(toAdd); } + } + catch(Exception e){ + //TODO chase down loot generation error, affects roughly 2% of drops + int i = 0; + } } public static void GenerateHotzoneLootDrop(Mob mob, BootySetEntry bse, float multiplier){ - if (generalItemTables.containsKey(bse.lootTable + 1)) { int lootTableID = bse.lootTable + 1; + int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; + if (chanceRoll > bse.dropChance * multiplier) { + //early exit, failed to hit minimum chance roll + return; + } MobLoot toAdd = getGenTableItem(lootTableID, mob); if (toAdd != null) { if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { @@ -215,7 +234,6 @@ public class LootManager { mob.getCharItemManager().addItemToInventory(toAdd); } } - } public static void RollForGlass(Mob mob){ if (ThreadLocalRandom.current().nextInt(101) > 99) { int roll2 = TableRoll(mob.level); From 46bb1cd8e8f89ded5953dcb6db2941a34eec93ad Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 30 Jul 2023 14:05:28 -0500 Subject: [PATCH 5/5] tweak roll ranges, fix r8 loot bug --- src/engine/devcmd/cmds/simulateBootyCmd.java | 11 +++++++---- src/engine/loot/LootManager.java | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/engine/devcmd/cmds/simulateBootyCmd.java b/src/engine/devcmd/cmds/simulateBootyCmd.java index e946c3a6..ac51788e 100644 --- a/src/engine/devcmd/cmds/simulateBootyCmd.java +++ b/src/engine/devcmd/cmds/simulateBootyCmd.java @@ -68,9 +68,12 @@ public class simulateBootyCmd extends AbstractDevCmd { case Mob: Mob mob = (Mob) target; output += "Name: " + mob.getName() + newline; - int minRollRange = mob.getLevel() + 0 + mob.getParentZone().minLvl; - int maxRollRange = (mob.getLevel() * 2) + 120 + (mob.getParentZone().maxLvl * 2); - output += "Roll Range: " + minRollRange + " - " + maxRollRange + newline; + int max = (int)(4.882 * mob.level + 127.0); + if(max > 320){ + max = 320; + } + int min = (int)(4.469 * mob.level - 3.469); + output += "Roll Range: " + min + " - " + max + newline; output += "Special Loot:" + newline; if (mob.bootySet != 0) { for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.bootySet)) { @@ -87,7 +90,7 @@ public class simulateBootyCmd extends AbstractDevCmd { ArrayList Offerings = new ArrayList(); ArrayList OtherDrops = new ArrayList(); int failures = 0; - for (int i = 0; i < 1; ++i) { + for (int i = 0; i < 100; ++i) { try { mob.loadInventory(); diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 04cef78b..40e9c3ca 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -175,7 +175,7 @@ public class LootManager { if(mobLevel > 65){ mobLevel = 65; } - int max = (int)(4.882 * mobLevel + 121.0); + int max = (int)(5.882 * mobLevel + 127.0); if(max > 320){ max = 320; } @@ -235,7 +235,8 @@ public class LootManager { } } public static void RollForGlass(Mob mob){ - if (ThreadLocalRandom.current().nextInt(101) > 99) { + int glassRoll = ThreadLocalRandom.current().nextInt(100) + 1; + if (glassRoll >= 99 - mob.getRank()){ int roll2 = TableRoll(mob.level); if (itemTables.get(126).getRowForRange(roll2) == null) { return;