From 38339eae3f7b17580a977f3c580352202efbfeee Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 31 Jul 2023 19:20:41 -0500 Subject: [PATCH 01/88] hotzone roll tweaks --- src/engine/loot/LootManager.java | 45 +++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index b2de6c0a..6b733f60 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -81,37 +81,57 @@ public class LootManager { DropEquipment(mob,multiplier); return; } + Boolean hasRolledForGlass = false; for (BootySetEntry bse : entries) { switch (bse.bootyType) { case "GOLD": GenerateGoldDrop(mob,bse,multiplier); break; case "LOOT": - GenerateNormalLootDrop(mob,bse,multiplier); + GenerateNormalLootDrop(mob,bse,multiplier,inHotzone); if (inHotzone && mob.level < 80) { if (generalItemTables.containsKey(bse.lootTable + 1)) { GenerateHotzoneLootDrop(mob, bse, multiplier); + } else{ + //if hotzone equivalent table doesn't exist, roll for glass + RollForGlass(mob); + hasRolledForGlass = true; } } if(mob.level > 80){ RollForGlass(mob); } + RollLootTableForHotzone(mob, bse); break; case "ITEM": GenerateItemLootDrop(mob,bse,multiplier); break; } } - if(inHotzone){ + if(inHotzone && hasRolledForGlass == false){ RollForGlass(mob); } } - public static MobLoot getGenTableItem(int genTableID, Mob mob) { + public static void RollLootTableForHotzone(Mob mob, BootySetEntry bse){ + MobLoot toAdd = getGenTableItem(bse.lootTable, mob,true); + if (toAdd != null) { + if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ + toAdd.setIsID(true); + } + mob.getCharItemManager().addItemToInventory(toAdd); + } + } + public static MobLoot getGenTableItem(int genTableID, Mob mob, Boolean isHotzone) { if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { return null; } MobLoot outItem; - int genRoll = new Random().nextInt(100)+1; + int genRoll; + if(isHotzone){ + genRoll = ThreadLocalRandom.current().nextInt(32) + 77; + } else { + genRoll = new Random().nextInt(100) + 1; + } GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); if (selectedRow == null) { return null; @@ -195,7 +215,7 @@ public class LootManager { mob.getCharItemManager().addItemToInventory(goldAmount); } } - public static void GenerateNormalLootDrop(Mob mob, BootySetEntry bse,float multiplier){ + public static void GenerateNormalLootDrop(Mob mob, BootySetEntry bse,float multiplier, Boolean inHotzone){ try{ int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; if (chanceRoll > bse.dropChance * multiplier) { @@ -203,7 +223,7 @@ public class LootManager { return; } //iterate the booty tables and add items to mob inventory - MobLoot toAdd = getGenTableItem(bse.lootTable, mob); + MobLoot toAdd = getGenTableItem(bse.lootTable, mob,inHotzone); if (toAdd != null) { if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ toAdd.setIsID(true); @@ -218,12 +238,13 @@ public class LootManager { } public static void GenerateHotzoneLootDrop(Mob mob, BootySetEntry bse, float multiplier){ 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); + //hotzone roll will ignore chance from inherited table + //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, true); if (toAdd != null) { if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { toAdd.setIsID(true); From 48817d7ecbc52624f5babb5c7b532860454155a8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 31 Jul 2023 20:42:56 -0500 Subject: [PATCH 02/88] hotzone roll tweaks --- src/engine/loot/LootManager.java | 55 ++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 6b733f60..f29937e2 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -82,26 +82,27 @@ public class LootManager { return; } Boolean hasRolledForGlass = false; + Boolean hasExtraRolled = false; + int hotzoneTable = 0; for (BootySetEntry bse : entries) { switch (bse.bootyType) { case "GOLD": GenerateGoldDrop(mob,bse,multiplier); break; case "LOOT": - GenerateNormalLootDrop(mob,bse,multiplier,inHotzone); + GenerateNormalLootDrop(mob,bse,multiplier,false); if (inHotzone && mob.level < 80) { if (generalItemTables.containsKey(bse.lootTable + 1)) { - GenerateHotzoneLootDrop(mob, bse, multiplier); - } else{ - //if hotzone equivalent table doesn't exist, roll for glass - RollForGlass(mob); - hasRolledForGlass = true; + //GenerateHotzoneLootDrop(mob, bse, multiplier); + hotzoneTable = bse.lootTable + 1; } } - if(mob.level > 80){ - RollForGlass(mob); + if(mob.level < 80){ + if (inHotzone && hasExtraRolled == false) { + RollLootTableForHotzone(mob, bse); + hasExtraRolled = true; + } } - RollLootTableForHotzone(mob, bse); break; case "ITEM": GenerateItemLootDrop(mob,bse,multiplier); @@ -111,6 +112,9 @@ public class LootManager { if(inHotzone && hasRolledForGlass == false){ RollForGlass(mob); } + if (hotzoneTable != 0) { + GenerateHotzoneLootDrop(mob, hotzoneTable, multiplier); + } } public static void RollLootTableForHotzone(Mob mob, BootySetEntry bse){ MobLoot toAdd = getGenTableItem(bse.lootTable, mob,true); @@ -138,7 +142,7 @@ public class LootManager { } int itemTableId = selectedRow.itemTableID; //gets the 1-320 roll for this mob - int roll2 = TableRoll(mob.level); + int roll2 = TableRoll(mob.level,isHotzone); ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); if (tableRow == null) { return null; @@ -163,7 +167,7 @@ public class LootManager { int prefixroll = ThreadLocalRandom.current().nextInt(100)+1; if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); - ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level)); + ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level,isHotzone)); if (prefixMod != null && prefixMod.action.length() > 0) { outItem.setPrefix(prefixMod.action); outItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); @@ -177,7 +181,7 @@ public class LootManager { ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); - ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level)); + ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level,isHotzone)); if (suffixMod != null && suffixMod.action.length() > 0) { outItem.setSuffix(suffixMod.action); outItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); @@ -188,7 +192,7 @@ public class LootManager { } return outItem; } - private static int TableRoll(int mobLevel){ + private static int TableRoll(int mobLevel, Boolean isHotzone){ if(mobLevel > 65){ mobLevel = 65; } @@ -197,6 +201,12 @@ public class LootManager { max = 321; } int min = (int)(4.469 * mobLevel - 3.469); + //if(isHotzone == true){ + // min += mobLevel; + // if(min > 220){ + // min = 220; + // } + //} int roll = ThreadLocalRandom.current().nextInt(max-min) + min; return roll; } @@ -236,15 +246,14 @@ public class LootManager { int i = 0; } } - public static void GenerateHotzoneLootDrop(Mob mob, BootySetEntry bse, float multiplier){ - int lootTableID = bse.lootTable + 1; - //hotzone roll will ignore chance from inherited table + public static void GenerateHotzoneLootDrop(Mob mob, int tableID, float multiplier){ + int lootTableID = tableID; //int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; //if (chanceRoll > bse.dropChance * multiplier) { - // //early exit, failed to hit minimum chance roll + //early exit, failed to hit minimum chance roll // return; //} - MobLoot toAdd = getGenTableItem(lootTableID, mob, true); + MobLoot toAdd = getGenTableItem(lootTableID, mob, false); if (toAdd != null) { if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { toAdd.setIsID(true); @@ -254,8 +263,14 @@ public class LootManager { } public static void RollForGlass(Mob mob){ int glassRoll = ThreadLocalRandom.current().nextInt(100) + 1; - if (glassRoll >= 99) { - int roll2 = TableRoll(mob.level); + int glassChance = 99 - mob.getRank(); + if (glassRoll >= glassChance) { + //int roll2 = TableRoll(mob.level,false); + int max = (int)(4.882 * mob.level + 127.0); + if(max > 321){ + max = 321; + } + int roll2 = ThreadLocalRandom.current().nextInt(max - (int)((mob.level * 0.5) + (mob.level * 0.5))); if (itemTables.get(126).getRowForRange(roll2) == null) { return; } From 93359ae147a15a2604cb3b0b5f4078f7c5b914c2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 31 Jul 2023 21:28:41 -0500 Subject: [PATCH 03/88] hotzone roll tweaks --- src/engine/loot/LootManager.java | 80 +++++++++++++++----------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index f29937e2..b2e184f1 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -77,41 +77,40 @@ public class LootManager { } } private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { - if (fromDeath) { - DropEquipment(mob,multiplier); - return; - } - Boolean hasRolledForGlass = false; - Boolean hasExtraRolled = false; - int hotzoneTable = 0; - for (BootySetEntry bse : entries) { - switch (bse.bootyType) { - case "GOLD": - GenerateGoldDrop(mob,bse,multiplier); - break; - case "LOOT": - GenerateNormalLootDrop(mob,bse,multiplier,false); - if (inHotzone && mob.level < 80) { - if (generalItemTables.containsKey(bse.lootTable + 1)) { - //GenerateHotzoneLootDrop(mob, bse, multiplier); - hotzoneTable = bse.lootTable + 1; - } + if (fromDeath) { + DropEquipment(mob, multiplier); + return; + } + Boolean hasRolledForGlass = false; + Boolean hasExtraRolled = false; + int hotzoneTable = 0; + for (BootySetEntry bse : entries) { + switch (bse.bootyType) { + case "GOLD": + GenerateGoldDrop(mob, bse, multiplier); + break; + case "LOOT": + GenerateNormalLootDrop(mob, bse, multiplier, false); + if (inHotzone && mob.level < 80) { + if (generalItemTables.containsKey(bse.lootTable + 1)) { + hotzoneTable = bse.lootTable + 1; } - if(mob.level < 80){ - if (inHotzone && hasExtraRolled == false) { - RollLootTableForHotzone(mob, bse); - hasExtraRolled = true; - } + } + if (mob.level < 80) { + if (inHotzone && hasExtraRolled == false) { + RollLootTableForHotzone(mob, bse); + hasExtraRolled = true; } - break; - case "ITEM": - GenerateItemLootDrop(mob,bse,multiplier); - break; - } - } - if(inHotzone && hasRolledForGlass == false){ - RollForGlass(mob); + } + break; + case "ITEM": + GenerateItemLootDrop(mob, bse, multiplier); + break; } + } + if (inHotzone && hasRolledForGlass == false) { + RollForGlass(mob); + } if (hotzoneTable != 0) { GenerateHotzoneLootDrop(mob, hotzoneTable, multiplier); } @@ -131,11 +130,11 @@ public class LootManager { } MobLoot outItem; int genRoll; - if(isHotzone){ - genRoll = ThreadLocalRandom.current().nextInt(32) + 77; - } else { + //if(isHotzone){ + // genRoll = ThreadLocalRandom.current().nextInt(32) + 77; + //} else { genRoll = new Random().nextInt(100) + 1; - } + //} GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); if (selectedRow == null) { return null; @@ -212,7 +211,7 @@ public class LootManager { } public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, float multiplier){ int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; - if (chanceRoll > bse.dropChance) { + if (chanceRoll > bse.dropChance * multiplier) { //early exit, failed to hit minimum chance roll OR booty was generated from mob's death return; } @@ -233,7 +232,7 @@ public class LootManager { return; } //iterate the booty tables and add items to mob inventory - MobLoot toAdd = getGenTableItem(bse.lootTable, mob,inHotzone); + MobLoot toAdd = getGenTableItem(bse.lootTable, mob,false); if (toAdd != null) { if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ toAdd.setIsID(true); @@ -248,11 +247,6 @@ public class LootManager { } public static void GenerateHotzoneLootDrop(Mob mob, int tableID, float multiplier){ int lootTableID = tableID; - //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, false); if (toAdd != null) { if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { From 090d3b43728cba99cd299afdafc49069fb8d12c7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 2 Aug 2023 17:44:22 -0400 Subject: [PATCH 04/88] New config entry added for server gold rates. --- src/engine/gameManager/ConfigManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index 6cf0eeda..67d90a26 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -70,8 +70,10 @@ public enum ConfigManager { //drop rates MB_NORMAL_EXP_RATE, MB_NORMAL_DROP_RATE, + MB_NORMAL_GOLD_RATE, MB_HOTZONE_EXP_RATE, MB_HOTZONE_DROP_RATE, + MB_HOTZONE_GOLD_RATE, MB_HOTZONE_DURATION, MB_HOTZONE_MIN_LEVEL, From 5ad911244848694bb61a90fd36ea45474341bd7d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 19:45:18 -0500 Subject: [PATCH 05/88] incoroporate gold rate, method cleanup --- src/engine/loot/LootManager.java | 172 ++++++++++++------------------- 1 file changed, 64 insertions(+), 108 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index b2e184f1..50e41158 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 engine.server.MBServerStatics; import java.sql.ResultSet; import java.sql.SQLException; @@ -81,26 +82,18 @@ public class LootManager { DropEquipment(mob, multiplier); return; } - Boolean hasRolledForGlass = false; - Boolean hasExtraRolled = false; int hotzoneTable = 0; for (BootySetEntry bse : entries) { switch (bse.bootyType) { case "GOLD": - GenerateGoldDrop(mob, bse, multiplier); + GenerateGoldDrop(mob, bse, inHotzone); break; case "LOOT": - GenerateNormalLootDrop(mob, bse, multiplier, false); - if (inHotzone && mob.level < 80) { - if (generalItemTables.containsKey(bse.lootTable + 1)) { - hotzoneTable = bse.lootTable + 1; - } - } - if (mob.level < 80) { - if (inHotzone && hasExtraRolled == false) { - RollLootTableForHotzone(mob, bse); - hasExtraRolled = true; - } + if (inHotzone) { + if (generalItemTables.containsKey(bse.lootTable + 1)) + GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance,multiplier);//generate loot drop from hotzone table + else + GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop } break; case "ITEM": @@ -108,21 +101,6 @@ public class LootManager { break; } } - if (inHotzone && hasRolledForGlass == false) { - RollForGlass(mob); - } - if (hotzoneTable != 0) { - GenerateHotzoneLootDrop(mob, hotzoneTable, multiplier); - } - } - public static void RollLootTableForHotzone(Mob mob, BootySetEntry bse){ - MobLoot toAdd = getGenTableItem(bse.lootTable, mob,true); - if (toAdd != null) { - if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ - toAdd.setIsID(true); - } - mob.getCharItemManager().addItemToInventory(toAdd); - } } public static MobLoot getGenTableItem(int genTableID, Mob mob, Boolean isHotzone) { if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { @@ -133,7 +111,7 @@ public class LootManager { //if(isHotzone){ // genRoll = ThreadLocalRandom.current().nextInt(32) + 77; //} else { - genRoll = new Random().nextInt(100) + 1; + genRoll = new Random().nextInt(99) + 1; //} GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); if (selectedRow == null) { @@ -141,7 +119,7 @@ public class LootManager { } int itemTableId = selectedRow.itemTableID; //gets the 1-320 roll for this mob - int roll2 = TableRoll(mob.level,isHotzone); + int roll2 = TableRoll(mob.level); ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); if (tableRow == null) { return null; @@ -158,40 +136,49 @@ public class LootManager { Enum.ItemType outType = outItem.getItemBase().getType(); if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { - int prefixChanceRoll = ThreadLocalRandom.current().nextInt(100)+1; - double prefixChance = 2.057 * mob.level - 28.67; - if (prefixChanceRoll < prefixChance) { - ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); - - int prefixroll = ThreadLocalRandom.current().nextInt(100)+1; - if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { - ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); - ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level,isHotzone)); - if (prefixMod != null && prefixMod.action.length() > 0) { - outItem.setPrefix(prefixMod.action); - outItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); - } - } - } - int suffixChanceRoll = ThreadLocalRandom.current().nextInt(100)+1; - double suffixChance = 2.057 * mob.level - 28.67; - if (suffixChanceRoll < suffixChance) { - int suffixroll = ThreadLocalRandom.current().nextInt(100)+1; - ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); - if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { - ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); - ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level,isHotzone)); - if (suffixMod != null && suffixMod.action.length() > 0) { - outItem.setSuffix(suffixMod.action); - outItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); - } - } - } + outItem = GeneratePrefix(mob,outItem,genTableID,genRoll); + outItem = GenerateSuffix(mob,outItem,genTableID,genRoll); } } return outItem; } - private static int TableRoll(int mobLevel, Boolean isHotzone){ + private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll){ + int prefixChanceRoll = ThreadLocalRandom.current().nextInt(99)+1; + double prefixChance = 2.057 * mob.level - 28.67; + if (prefixChanceRoll < prefixChance) { + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); + int prefixroll = ThreadLocalRandom.current().nextInt(99)+1; + if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { + ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); + ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level)); + if (prefixMod != null && prefixMod.action.length() > 0) { + inItem.setPrefix(prefixMod.action); + inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); + } + } + } + return inItem; + } + private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll){ + int suffixChanceRoll = ThreadLocalRandom.current().nextInt(99)+1; + double suffixChance = 2.057 * mob.level - 28.67; + if (suffixChanceRoll < suffixChance) { + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + int suffixroll = ThreadLocalRandom.current().nextInt(99)+1; + ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); + if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { + ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); + ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level)); + if (suffixMod != null && suffixMod.action.length() > 0) { + inItem.setSuffix(suffixMod.action); + inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); + } + } + } + return inItem; + } + private static int TableRoll(int mobLevel){ if(mobLevel > 65){ mobLevel = 65; } @@ -209,30 +196,35 @@ 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 * multiplier) { + public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone){ + int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 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 high = bse.highGold; + int low = bse.lowGold; int gold = ThreadLocalRandom.current().nextInt(high - low) + low; + if(inHotzone == true){ + gold = (int)(gold * Float.parseFloat(ConfigManager.MB_HOTZONE_GOLD_RATE.getValue())); + } else{ + gold = (int)(gold * Float.parseFloat(ConfigManager.MB_NORMAL_GOLD_RATE.getValue())); + } if (gold > 0) { - MobLoot goldAmount = new MobLoot(mob, (int) (gold * multiplier)); + MobLoot goldAmount = new MobLoot(mob, gold); mob.getCharItemManager().addItemToInventory(goldAmount); } } - public static void GenerateNormalLootDrop(Mob mob, BootySetEntry bse,float multiplier, Boolean inHotzone){ + public static void GenerateLootDrop(Mob mob, int tableID, float dropChance,float multiplier){ try{ - int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; - if (chanceRoll > bse.dropChance * multiplier) { + int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; + if (chanceRoll > 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,false); + MobLoot toAdd = getGenTableItem(tableID, mob,false); if (toAdd != null) { if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ toAdd.setIsID(true); @@ -245,42 +237,6 @@ public class LootManager { int i = 0; } } - public static void GenerateHotzoneLootDrop(Mob mob, int tableID, float multiplier){ - int lootTableID = tableID; - MobLoot toAdd = getGenTableItem(lootTableID, mob, false); - 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){ - int glassRoll = ThreadLocalRandom.current().nextInt(100) + 1; - int glassChance = 99 - mob.getRank(); - if (glassRoll >= glassChance) { - //int roll2 = TableRoll(mob.level,false); - int max = (int)(4.882 * mob.level + 127.0); - if(max > 321){ - max = 321; - } - int roll2 = ThreadLocalRandom.current().nextInt(max - (int)((mob.level * 0.5) + (mob.level * 0.5))); - 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) { @@ -301,7 +257,7 @@ public class LootManager { return; } public static void GenerateItemLootDrop(Mob mob, BootySetEntry bse, float multiplier){ - int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; + int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; if (chanceRoll > bse.dropChance * multiplier) { //early exit, failed to hit minimum chance roll return; From a9af791d02ecf5cc728733a9e1221dac95ab954b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 19:48:50 -0500 Subject: [PATCH 06/88] removed unused import --- src/engine/loot/LootManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 50e41158..cb8b41b7 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -16,8 +16,6 @@ import engine.gameManager.ZoneManager; import engine.net.DispatchMessage; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; -import engine.server.MBServerStatics; - import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; From 86e8fe19d4952bfaa6e849f6a1b5d6bbb5e3244d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 19:49:34 -0500 Subject: [PATCH 07/88] removed unused method parameter --- src/engine/loot/LootManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index cb8b41b7..080373c9 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -100,7 +100,7 @@ public class LootManager { } } } - public static MobLoot getGenTableItem(int genTableID, Mob mob, Boolean isHotzone) { + public static MobLoot getGenTableItem(int genTableID, Mob mob) { if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { return null; } @@ -222,7 +222,7 @@ public class LootManager { return; } //iterate the booty tables and add items to mob inventory - MobLoot toAdd = getGenTableItem(tableID, mob,false); + MobLoot toAdd = getGenTableItem(tableID, mob); if (toAdd != null) { if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ toAdd.setIsID(true); From ae8ead825dfbfea5be92b752fe2c1b73f5028ec4 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 19:57:32 -0500 Subject: [PATCH 08/88] error catch for prefix and suffix generation --- src/engine/loot/LootManager.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 080373c9..5a7f53c6 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -16,6 +16,8 @@ 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; import java.util.ArrayList; @@ -106,11 +108,7 @@ public class LootManager { } MobLoot outItem; int genRoll; - //if(isHotzone){ - // genRoll = ThreadLocalRandom.current().nextInt(32) + 77; - //} else { - genRoll = new Random().nextInt(99) + 1; - //} + genRoll = new Random().nextInt(99) + 1; GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); if (selectedRow == null) { return null; @@ -134,8 +132,16 @@ public class LootManager { Enum.ItemType outType = outItem.getItemBase().getType(); if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { - outItem = GeneratePrefix(mob,outItem,genTableID,genRoll); + try { + outItem = GeneratePrefix(mob, outItem, genTableID, genRoll); + } catch(Exception e){ + Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); + } + try{ outItem = GenerateSuffix(mob,outItem,genTableID,genRoll); + } catch(Exception e){ + Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); + } } } return outItem; From 500763fd1148066afb44afddc2af397a6f5ee840 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 20:01:46 -0500 Subject: [PATCH 09/88] cleanup --- src/engine/loot/LootManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 5a7f53c6..91ac00d9 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -227,7 +227,6 @@ public class LootManager { //early exit, failed to hit minimum chance roll return; } - //iterate the booty tables and add items to mob inventory MobLoot toAdd = getGenTableItem(tableID, mob); if (toAdd != null) { if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ From 75f54ae562e03ae6c795cc3d11c2a082c5566746 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 20:06:46 -0500 Subject: [PATCH 10/88] normal loot and hotzone loot test --- src/engine/loot/LootManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 91ac00d9..5e198ac5 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -89,11 +89,12 @@ public class LootManager { GenerateGoldDrop(mob, bse, inHotzone); break; case "LOOT": + GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop if (inHotzone) { if (generalItemTables.containsKey(bse.lootTable + 1)) GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance,multiplier);//generate loot drop from hotzone table - else - GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop + //else + //GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop } break; case "ITEM": From 66b047d091d6a53a4ca7669c6a22eaa2707c415a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 20:09:07 -0500 Subject: [PATCH 11/88] cleanup --- src/engine/loot/LootManager.java | 37 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 5e198ac5..9e909a19 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -80,26 +80,25 @@ public class LootManager { private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { if (fromDeath) { DropEquipment(mob, multiplier); - return; - } - int hotzoneTable = 0; - for (BootySetEntry bse : entries) { - switch (bse.bootyType) { - case "GOLD": - GenerateGoldDrop(mob, bse, inHotzone); - break; - case "LOOT": - GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop - if (inHotzone) { - if (generalItemTables.containsKey(bse.lootTable + 1)) - GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance,multiplier);//generate loot drop from hotzone table - //else + } else { + for (BootySetEntry bse : entries) { + switch (bse.bootyType) { + case "GOLD": + GenerateGoldDrop(mob, bse, inHotzone); + break; + case "LOOT": + GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop + if (inHotzone) { + if (generalItemTables.containsKey(bse.lootTable + 1)) + GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier);//generate loot drop from hotzone table + //else //GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop - } - break; - case "ITEM": - GenerateItemLootDrop(mob, bse, multiplier); - break; + } + break; + case "ITEM": + GenerateItemLootDrop(mob, bse, multiplier); + break; + } } } } From 7cdcc3d23d4684029b227be27b5233a2edd0ec85 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 2 Aug 2023 20:09:17 -0500 Subject: [PATCH 12/88] cleanup --- src/engine/loot/LootManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java index 9e909a19..bd4b0eb9 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/loot/LootManager.java @@ -91,8 +91,6 @@ public class LootManager { if (inHotzone) { if (generalItemTables.containsKey(bse.lootTable + 1)) GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier);//generate loot drop from hotzone table - //else - //GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop } break; case "ITEM": From 4e01c8e79424ad77ea47e1151210ee9f0625b56c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 3 Aug 2023 08:27:08 -0400 Subject: [PATCH 13/88] Moved manager class to manager package --- src/engine/db/handlers/dbLootTableHandler.java | 2 +- src/engine/{loot => gameManager}/LootManager.java | 6 +----- src/engine/objects/Mob.java | 3 +-- src/engine/server/world/WorldServer.java | 5 ++--- 4 files changed, 5 insertions(+), 11 deletions(-) rename src/engine/{loot => gameManager}/LootManager.java (99%) diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index 02854cb9..6d39f970 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -10,7 +10,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; -import engine.loot.LootManager; +import engine.gameManager.LootManager; import engine.objects.Item; import engine.objects.LootTable; import org.pmw.tinylog.Logger; diff --git a/src/engine/loot/LootManager.java b/src/engine/gameManager/LootManager.java similarity index 99% rename from src/engine/loot/LootManager.java rename to src/engine/gameManager/LootManager.java index bd4b0eb9..77473e6e 100644 --- a/src/engine/loot/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -6,13 +6,9 @@ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com -package engine.loot; +package engine.gameManager; import engine.Enum; -import engine.gameManager.ConfigManager; -import engine.gameManager.DbManager; -import engine.gameManager.NPCManager; -import engine.gameManager.ZoneManager; import engine.net.DispatchMessage; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 109bad24..fc3b508c 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -13,17 +13,16 @@ import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; import engine.Enum.*; import engine.InterestManagement.WorldGrid; -import engine.mobileAI.Threads.MobAIThread; import engine.exception.SerializationException; import engine.gameManager.*; import engine.job.JobScheduler; import engine.jobs.DeferredPowerJob; import engine.jobs.UpgradeNPCJob; -import engine.loot.LootManager; import engine.math.Bounds; import engine.math.Quaternion; import engine.math.Vector3f; import engine.math.Vector3fImmutable; +import engine.mobileAI.Threads.MobAIThread; import engine.net.ByteBufferWriter; import engine.net.Dispatch; import engine.net.DispatchMessage; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index b7b520e6..75b160a7 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -17,15 +17,14 @@ import engine.Enum.SupportMsgType; import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; -import engine.mobileAI.Threads.MobAIThread; -import engine.mobileAI.Threads.MobRespawnThread; import engine.db.archive.DataWarehouse; import engine.exception.MsgSendException; import engine.gameManager.*; import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.LogoutCharacterJob; -import engine.loot.LootManager; +import engine.mobileAI.Threads.MobAIThread; +import engine.mobileAI.Threads.MobRespawnThread; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.ItemProductionManager; From 95a9e4539181931576174b370bfe680c3bc19d4a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 3 Aug 2023 09:04:20 -0400 Subject: [PATCH 14/88] Caching of drop rates within LootManager --- src/engine/gameManager/ConfigManager.java | 1 - src/engine/gameManager/LootManager.java | 360 ++++++++++++++-------- src/engine/objects/Experience.java | 59 ++-- src/engine/objects/LootTable.java | 5 +- src/engine/server/world/WorldServer.java | 2 +- 5 files changed, 271 insertions(+), 156 deletions(-) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index 67d90a26..345158f8 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -109,7 +109,6 @@ public enum ConfigManager { // Called at bootstrap: ensures that all config values are loaded. - public static boolean init() { Logger.info("Loading config from environment..."); diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 77473e6e..1f02dd1a 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -24,7 +24,9 @@ import java.util.concurrent.ThreadLocalRandom; /** * Class contains static methods for data from Magicbane's loot tables */ -public class LootManager { +public enum LootManager { + + LOOTMANAGER; //new tables private static final HashMap generalItemTables = new HashMap<>(); @@ -32,37 +34,63 @@ public class LootManager { private static final HashMap modTypeTables = new HashMap<>(); private static final HashMap modTables = new HashMap<>(); - private LootManager() { - } + // Drop Rates + + public static float NORMAL_DROP_RATE; + public static float NORMAL_EXP_RATE; + public static float NORMAL_GOLD_RATE; + public static float HOTZONE_DROP_RATE; + public static float HOTZONE_EXP_RATE; + public static float HOTZONE_GOLD_RATE; + + // Bootstrap routine to initialize the Loot Manager + + public static void init() { - // Bootstrap routine to load loot data from database - public static void loadLootData() { DbManager.LootQueries.LOAD_ALL_LOOTGROUPS(); DbManager.LootQueries.LOAD_ALL_LOOTTABLES(); DbManager.LootQueries.LOAD_ALL_MODGROUPS(); DbManager.LootQueries.LOAD_ALL_MODTABLES(); + + NORMAL_DROP_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); + NORMAL_EXP_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()); + NORMAL_GOLD_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_GOLD_RATE.getValue()); + HOTZONE_DROP_RATE = Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue()); + HOTZONE_EXP_RATE = Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue()); + HOTZONE_GOLD_RATE = Float.parseFloat(ConfigManager.MB_HOTZONE_GOLD_RATE.getValue()); + } public static void GenerateMobLoot(Mob mob, boolean fromDeath) { + //determine if mob is in hotzone + boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); + //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 multiplier from the config instead - multiplier = Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue()); - } + + float multiplier = NORMAL_DROP_RATE; + + //if mob is inside hotzone, use the hotzone multiplier from the config instead + + if (inHotzone) + multiplier = HOTZONE_DROP_RATE; + //iterate the booty sets - 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 && NPCManager._bootySetMap.containsKey(mob.bootySet) == true) { + + 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 && 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 + if (!fromDeath) { for (Item it : mob.getInventory()) { + ItemBase ib = it.getItemBase(); + 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?"); chatMsg.setMessageType(10); @@ -73,21 +101,23 @@ public class LootManager { } } } + private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { - if (fromDeath) { + + if (fromDeath) DropEquipment(mob, multiplier); - } else { + else { for (BootySetEntry bse : entries) { switch (bse.bootyType) { case "GOLD": GenerateGoldDrop(mob, bse, inHotzone); break; case "LOOT": - GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier);//generate normal loot drop - if (inHotzone) { + GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier); //generate normal loot drop + + if (inHotzone) if (generalItemTables.containsKey(bse.lootTable + 1)) - GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier);//generate loot drop from hotzone table - } + GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier); //generate loot drop from hotzone table break; case "ITEM": GenerateItemLootDrop(mob, bse, multiplier); @@ -96,60 +126,79 @@ public class LootManager { } } } + public static MobLoot getGenTableItem(int genTableID, Mob mob) { - if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { - return null; - } - MobLoot outItem; - int genRoll; - genRoll = new Random().nextInt(99) + 1; - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); - if (selectedRow == null) { - return null; - } - int itemTableId = selectedRow.itemTableID; - //gets the 1-320 roll for this mob + + if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) + return null; + + MobLoot outItem; + int genRoll; + + genRoll = new Random().nextInt(99) + 1; + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + //gets the 1-320 roll for this mob + int roll2 = TableRoll(mob.level); - ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); - if (tableRow == null) { - return null; - } - int itemUUID = tableRow.cacheID; - if (itemUUID == 0) { - return null; - } - if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { - int amount = ThreadLocalRandom.current().nextInt(tableRow.maxSpawn - tableRow.minSpawn) + tableRow.minSpawn; - return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); - } - outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - Enum.ItemType outType = outItem.getItemBase().getType(); - if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { - if (outItem.getItemBase().isGlass() == false) { - try { - outItem = GeneratePrefix(mob, outItem, genTableID, genRoll); - } catch(Exception e){ - Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); - } - try{ - outItem = GenerateSuffix(mob,outItem,genTableID,genRoll); - } catch(Exception e){ - Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); - } + + ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); + + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { + int amount = ThreadLocalRandom.current().nextInt(tableRow.maxSpawn - tableRow.minSpawn) + tableRow.minSpawn; + return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); + } + + outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + Enum.ItemType outType = outItem.getItemBase().getType(); + + if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { + if (outItem.getItemBase().isGlass() == false) { + try { + outItem = GeneratePrefix(mob, outItem, genTableID, genRoll); + } catch (Exception e) { + Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); + } + try { + outItem = GenerateSuffix(mob, outItem, genTableID, genRoll); + } catch (Exception e) { + Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); } } - return outItem; + } + return outItem; } - private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll){ - int prefixChanceRoll = ThreadLocalRandom.current().nextInt(99)+1; + + private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll) { + + int prefixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; double prefixChance = 2.057 * mob.level - 28.67; + if (prefixChanceRoll < prefixChance) { + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); - int prefixroll = ThreadLocalRandom.current().nextInt(99)+1; + + int prefixroll = ThreadLocalRandom.current().nextInt(99) + 1; + if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { + ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level)); + if (prefixMod != null && prefixMod.action.length() > 0) { inItem.setPrefix(prefixMod.action); inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); @@ -158,16 +207,23 @@ public class LootManager { } return inItem; } - private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll){ - int suffixChanceRoll = ThreadLocalRandom.current().nextInt(99)+1; + + private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll) { + + int suffixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; double suffixChance = 2.057 * mob.level - 28.67; + if (suffixChanceRoll < suffixChance) { + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); - int suffixroll = ThreadLocalRandom.current().nextInt(99)+1; + int suffixroll = ThreadLocalRandom.current().nextInt(99) + 1; ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); + if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { + ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level)); + if (suffixMod != null && suffixMod.action.length() > 0) { inItem.setSuffix(suffixMod.action); inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); @@ -176,94 +232,116 @@ public class LootManager { } return inItem; } - private static int TableRoll(int mobLevel){ - if(mobLevel > 65){ + + private static int TableRoll(int mobLevel) { + + if (mobLevel > 65) mobLevel = 65; - } - int max = (int)(4.882 * mobLevel + 127.0); - if(max > 321){ - max = 321; - } - int min = (int)(4.469 * mobLevel - 3.469); - //if(isHotzone == true){ - // min += mobLevel; - // if(min > 220){ - // min = 220; - // } - //} - int roll = ThreadLocalRandom.current().nextInt(max-min) + min; + + int max = (int) (4.882 * mobLevel + 127.0); + + if (max > 319) + max = 319; + + int min = (int) (4.469 * mobLevel - 3.469); + int roll = ThreadLocalRandom.current().nextInt(max - min) + min; + return roll; } - public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone){ + + public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { + int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - if (chanceRoll > bse.dropChance) { - //early exit, failed to hit minimum chance roll OR booty was generated from mob's death + + //early exit, failed to hit minimum chance roll OR booty was generated from mob's death + + if (chanceRoll > bse.dropChance) return; - } + //determine and add gold to mob inventory + int high = bse.highGold; int low = bse.lowGold; int gold = ThreadLocalRandom.current().nextInt(high - low) + low; - if(inHotzone == true){ - gold = (int)(gold * Float.parseFloat(ConfigManager.MB_HOTZONE_GOLD_RATE.getValue())); - } else{ - gold = (int)(gold * Float.parseFloat(ConfigManager.MB_NORMAL_GOLD_RATE.getValue())); - } + + if (inHotzone == true) + gold = (int) (gold * HOTZONE_GOLD_RATE); + else + gold = (int) (NORMAL_GOLD_RATE); + if (gold > 0) { MobLoot goldAmount = new MobLoot(mob, gold); mob.getCharItemManager().addItemToInventory(goldAmount); } + } - public static void GenerateLootDrop(Mob mob, int tableID, float dropChance,float multiplier){ - try{ - int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - if (chanceRoll > dropChance * multiplier) { + + public static void GenerateLootDrop(Mob mob, int tableID, float dropChance, float multiplier) { + + try { + int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; + //early exit, failed to hit minimum chance roll - return; - } - MobLoot toAdd = getGenTableItem(tableID, mob); - if (toAdd != null) { - if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ - toAdd.setIsID(true); + + if (chanceRoll > dropChance * multiplier) + return; + + MobLoot toAdd = getGenTableItem(tableID, mob); + + if (toAdd != null) { + if (toAdd.getPrefix() == null && toAdd.getSuffix() == null) + toAdd.setIsID(true); + + mob.getCharItemManager().addItemToInventory(toAdd); } - mob.getCharItemManager().addItemToInventory(toAdd); - } - } - catch(Exception e){ + } catch (Exception e) { //TODO chase down loot generation error, affects roughly 2% of drops int i = 0; } } - public static void DropEquipment(Mob mob, float multiplier){ + + 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) { + + 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, float multiplier){ + + public static void GenerateItemLootDrop(Mob mob, BootySetEntry bse, float multiplier) { + int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - if (chanceRoll > bse.dropChance * multiplier) { - //early exit, failed to hit minimum chance roll + + //early exit, failed to hit minimum chance roll + + if (chanceRoll > bse.dropChance * multiplier) return; - } + 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 GenTable gt = new GenTable(); @@ -275,7 +353,9 @@ public class LootManager { toAdd.rows.add(row); } } + public static void AddItemTableRow(int tableID, ItemTableRow row) { + if (!itemTables.containsKey(tableID)) { //create the new table ItemTable it = new ItemTable(); @@ -287,7 +367,9 @@ public class LootManager { toAdd.rows.add(row); } } + public static void AddModTypeTableRow(int tableID, ModTypeTableRow row) { + if (!modTypeTables.containsKey(tableID)) { //create the new table ModTypeTable mtt = new ModTypeTable(); @@ -299,7 +381,9 @@ public class LootManager { toAdd.rows.add(row); } } + public static void AddModTableRow(int tableID, ModTableRow row) { + if (!modTables.containsKey(tableID)) { //create the new table ModTable mt = new ModTable(); @@ -311,64 +395,73 @@ public class LootManager { toAdd.rows.add(row); } } + public static class GenTable { public ArrayList rows = new ArrayList(); public GenTableRow getRowForRange(int roll) { + GenTableRow outRow = null; - for (GenTableRow iteration : this.rows) { - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { + + for (GenTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) outRow = iteration; - } - } + return outRow; } } + public static class ItemTable { public ArrayList rows = new ArrayList(); public ItemTableRow getRowForRange(int roll) { - if (roll > 320) { + + if (roll > 320) roll = 320; - } + ItemTableRow outRow = null; - for (ItemTableRow iteration : this.rows) { - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { + + for (ItemTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) outRow = iteration; - } - } + return outRow; } } + public static class ModTypeTable { public ArrayList rows = new ArrayList(); public ModTypeTableRow getRowForRange(int roll) { + ModTypeTableRow outRow = null; - for (ModTypeTableRow iteration : this.rows) { - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { + + for (ModTypeTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) return iteration; - } - } + return outRow; } } + public static class ModTable { public ArrayList rows = new ArrayList(); public ModTableRow getRowForRange(int roll) { - if (roll > 320) { + + if (roll > 320) roll = 320; - } + ModTableRow outRow = null; - for (ModTableRow iteration : this.rows) { - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { + + for (ModTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) outRow = iteration; - } - } + return outRow; } } + public static class GenTableRow { public int minRoll; public int maxRoll; @@ -384,6 +477,7 @@ public class LootManager { this.sModTable = rs.getInt("sModTableID"); } } + public static class ItemTableRow { public int minRoll; public int maxRoll; @@ -400,6 +494,7 @@ public class LootManager { } } + public static class ModTypeTableRow { public int minRoll; public int maxRoll; @@ -412,6 +507,7 @@ public class LootManager { } } + public static class ModTableRow { public int minRoll; public int maxRoll; diff --git a/src/engine/objects/Experience.java b/src/engine/objects/Experience.java index ad365a3d..3d33c68d 100644 --- a/src/engine/objects/Experience.java +++ b/src/engine/objects/Experience.java @@ -10,7 +10,6 @@ package engine.objects; import engine.Enum.TargetColor; -import engine.gameManager.ConfigManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.server.MBServerStatics; @@ -18,6 +17,8 @@ import engine.server.MBServerStatics; import java.util.ArrayList; import java.util.TreeMap; +import static engine.gameManager.LootManager.LOOTMANAGER; + public class Experience { private static final TreeMap ExpToLevel; @@ -238,44 +239,44 @@ public class Experience { // called to determine current level based on xp public static int getLevel(int experience) { + int expKey = ExpToLevel.floorKey(experience); int level = ExpToLevel.get(expKey); - if (level > MBServerStatics.LEVELCAP) { + + if (level > MBServerStatics.LEVELCAP) level = MBServerStatics.LEVELCAP; - } + return level; } // Get the base xp for a level public static int getBaseExperience(int level) { - if (level < LevelToExp.length) { + + if (level < LevelToExp.length) return LevelToExp[level]; - } int fLevel = level - 1; int baseXP = fLevel * fLevel * fLevel; + return (int) ((fLevel < 40) ? (baseXP * 150) : (baseXP * (150 + (7.6799998 * (level - 40))))); } - // Get XP needed for the next level - public static int getExpForNextLevel(int experience, int currentLevel) { - return (getBaseExperience(currentLevel + 1) - experience); - } - // Max XP granted for killing a blue, yellow or orange mob public static float maxXPPerKill(int level) { + if (level < 1) level = 1; + if (level > 75) level = 75; + return MaxExpPerLevel[level]; - // return (LevelToExp[level + 1] - LevelToExp[level])/(11 + level/2); - // return ((((level * level)-level)*50)+16); } // Returns a penalty modifier depending on mob color public static double getConMod(AbstractCharacter pc, AbstractCharacter mob) { + switch (TargetColor.getCon(pc, mob)) { case Red: return 1.25; @@ -299,16 +300,16 @@ public class Experience { int highestLevel) { double penalty = 0.0; - int adjustedGroupSize = 0; - int totalLevels = 0; int level = currPlayer.getLevel(); // Group Size Penalty + if (players.size() > 2) penalty = (players.size() - 2) * 1.5; // Calculate Penalty For Highest level -> Current Player difference, != // check to prevent divide by zero error + if (highestLevel != level) penalty += ((highestLevel - level) * .5); @@ -318,6 +319,7 @@ public class Experience { // penalty += ((avgLevels - level) * .5); // Extra noob penalty + if ((highestLevel - level) > 25) penalty += (highestLevel - level - 25); @@ -325,7 +327,9 @@ public class Experience { } public static void doExperience(PlayerCharacter killer, AbstractCharacter mob, Group g) { + // Check for some failure conditions + if (killer == null || mob == null) return; @@ -341,10 +345,13 @@ public class Experience { // Check if leader is within range of kill and then get leadership // skill + Vector3fImmutable killLoc = mob.getLoc(); + if (killLoc.distanceSquared2D(g.getGroupLead().getLoc()) < (MBServerStatics.EXP_RANGE * MBServerStatics.EXP_RANGE)) { CharacterSkill leaderskill = g.getGroupLead().skills .get("Leadership"); + if (leaderskill != null) leadership = leaderskill.getNumTrains(); if (leadership > 90) @@ -352,13 +359,18 @@ public class Experience { } // Check every group member for distance to see if they get xp + for (PlayerCharacter pc : g.getMembers()) { if (pc.isAlive()) { // Skip if the player is dead. // Check within range + if (killLoc.distanceSquared2D(pc.getLoc()) < (MBServerStatics.EXP_RANGE * MBServerStatics.EXP_RANGE)) { + giveEXPTo.add(pc); + // Track highest level character + if (pc.getLevel() > highestLevel) highestLevel = pc.getLevel(); } @@ -366,34 +378,41 @@ public class Experience { } // Process every player in the group getting XP + for (PlayerCharacter playerCharacter : giveEXPTo) { if (playerCharacter.getLevel() >= MBServerStatics.LEVELCAP) continue; // Sets Max XP with server exp mod taken into account. - grantedExperience = (double) Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()) * maxXPPerKill(playerCharacter.getLevel()); + + grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(playerCharacter.getLevel()); // Adjust XP for Mob Level + grantedExperience *= getConMod(playerCharacter, mob); // Process XP for this member + penalty = getGroupMemberPenalty(leadership, playerCharacter, giveEXPTo, highestLevel); // Leadership Penalty Reduction + if (leadership > 0) penalty -= ((leadership) * 0.01) * penalty; // Modify for hotzone + if (grantedExperience != 0) if (ZoneManager.inHotZone(mob.getLoc())) - grantedExperience *= Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue()); + grantedExperience *= LOOTMANAGER.HOTZONE_EXP_RATE; // Check for 0 XP due to white mob, otherwise subtract penalty // xp - if (grantedExperience == 0) { + + if (grantedExperience == 0) grantedExperience = 1; - } else { + else { grantedExperience -= (penalty * 0.01) * grantedExperience; // Errant Penalty Calculation @@ -416,12 +435,12 @@ public class Experience { return; // Get XP and adjust for Mob Level with world xp modifier taken into account - grantedExperience = (double) Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()) * maxXPPerKill(killer.getLevel()); + grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(killer.getLevel()); grantedExperience *= getConMod(killer, mob); // Modify for hotzone if (ZoneManager.inHotZone(mob.getLoc())) - grantedExperience *= Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue()); + grantedExperience *= LOOTMANAGER.HOTZONE_EXP_RATE; // Errant penalty if (grantedExperience != 1) diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index 74e86e8f..78bd3188 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -12,7 +12,6 @@ package engine.objects; import engine.Enum.ItemContainerType; import engine.Enum.ItemType; import engine.Enum.OwnerType; -import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.NPCManager; import engine.gameManager.ZoneManager; @@ -25,6 +24,8 @@ import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; +import static engine.gameManager.LootManager.LOOTMANAGER; + public class LootTable { private static final ConcurrentHashMap lootGroups = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); @@ -165,7 +166,7 @@ public class LootTable { float chance = mlb.getChance() * .01f; - chance *= Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); + chance *= LOOTMANAGER.NORMAL_DROP_RATE; calculatedLootTable = mlb.getLootTableID(); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 75b160a7..0b48926a 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -338,7 +338,7 @@ public class WorldServer { // Load new loot system Logger.info("Loading New Loot Tables"); - LootManager.loadLootData(); + LootManager.init(); //load old loot system (still needed for rolling for now) LootTable.populateLootTables(); From 0bb756521bd7e10e23e5df7693cb5c704be3c6f1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 3 Aug 2023 09:09:23 -0400 Subject: [PATCH 15/88] Update console Lootmanager bootstrap message. --- src/engine/server/world/WorldServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 0b48926a..e2cc71d5 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -337,7 +337,7 @@ public class WorldServer { NPCManager.LoadAllBootySets(); // Load new loot system - Logger.info("Loading New Loot Tables"); + Logger.info("Initializing Loot Manager"); LootManager.init(); //load old loot system (still needed for rolling for now) From fda3386e7b9d498201069cc0324b19730da89c47 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 3 Aug 2023 09:43:30 -0400 Subject: [PATCH 16/88] Multiple inner classes extracted from LootManager. --- .../db/handlers/dbLootTableHandler.java | 12 +- src/engine/gameManager/LootManager.java | 129 +----------------- src/engine/loot/GenTable.java | 18 +++ src/engine/loot/GenTableRow.java | 20 +++ src/engine/loot/ItemTable.java | 21 +++ src/engine/loot/ItemTableRow.java | 20 +++ src/engine/loot/ModTable.java | 21 +++ src/engine/loot/ModTableRow.java | 18 +++ src/engine/loot/ModTypeTable.java | 18 +++ src/engine/loot/ModTypeTableRow.java | 16 +++ 10 files changed, 161 insertions(+), 132 deletions(-) create mode 100644 src/engine/loot/GenTable.java create mode 100644 src/engine/loot/GenTableRow.java create mode 100644 src/engine/loot/ItemTable.java create mode 100644 src/engine/loot/ItemTableRow.java create mode 100644 src/engine/loot/ModTable.java create mode 100644 src/engine/loot/ModTableRow.java create mode 100644 src/engine/loot/ModTypeTable.java create mode 100644 src/engine/loot/ModTypeTableRow.java diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index 6d39f970..ec9ba9df 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -11,6 +11,10 @@ package engine.db.handlers; import engine.gameManager.DbManager; import engine.gameManager.LootManager; +import engine.loot.GenTableRow; +import engine.loot.ItemTableRow; +import engine.loot.ModTableRow; +import engine.loot.ModTypeTableRow; import engine.objects.Item; import engine.objects.LootTable; import org.pmw.tinylog.Logger; @@ -140,7 +144,7 @@ public class dbLootTableHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { - LootManager.GenTableRow row = new LootManager.GenTableRow(rs); + GenTableRow row = new GenTableRow(rs); LootManager.AddGenTableRow(rs.getInt("groupID"), row); } @@ -162,7 +166,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootManager.ItemTableRow row = new LootManager.ItemTableRow(rs); + ItemTableRow row = new ItemTableRow(rs); LootManager.AddItemTableRow(rs.getInt("lootTable"), row); } @@ -183,7 +187,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootManager.ModTypeTableRow mttr = new LootManager.ModTypeTableRow(rs); + ModTypeTableRow mttr = new ModTypeTableRow(rs); LootManager.AddModTypeTableRow(rs.getInt("modGroup"), mttr); } @@ -203,7 +207,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootManager.ModTableRow mtr = new LootManager.ModTableRow(rs); + ModTableRow mtr = new ModTableRow(rs); LootManager.AddModTableRow(rs.getInt("modTable"), mtr); } diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 1f02dd1a..dff01fdd 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -9,13 +9,12 @@ package engine.gameManager; import engine.Enum; +import engine.loot.*; 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; import java.util.ArrayList; import java.util.HashMap; import java.util.Random; @@ -396,130 +395,4 @@ public enum LootManager { } } - public static class GenTable { - public ArrayList rows = new ArrayList(); - - public GenTableRow getRowForRange(int roll) { - - GenTableRow outRow = null; - - for (GenTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - outRow = iteration; - - return outRow; - } - } - - public static class ItemTable { - public ArrayList rows = new ArrayList(); - - public ItemTableRow getRowForRange(int roll) { - - if (roll > 320) - roll = 320; - - ItemTableRow outRow = null; - - for (ItemTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - outRow = iteration; - - return outRow; - } - } - - public static class ModTypeTable { - public ArrayList rows = new ArrayList(); - - public ModTypeTableRow getRowForRange(int roll) { - - ModTypeTableRow outRow = null; - - for (ModTypeTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - return iteration; - - return outRow; - } - } - - public static class ModTable { - public ArrayList rows = new ArrayList(); - - public ModTableRow getRowForRange(int roll) { - - if (roll > 320) - roll = 320; - - ModTableRow outRow = null; - - for (ModTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - outRow = iteration; - - return outRow; - } - } - - public static class GenTableRow { - public int minRoll; - public int maxRoll; - public int itemTableID; - public int pModTable; - public int sModTable; - - public GenTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.itemTableID = rs.getInt("lootTableID"); - this.pModTable = rs.getInt("pModTableID"); - this.sModTable = rs.getInt("sModTableID"); - } - } - - public static class ItemTableRow { - public int minRoll; - public int maxRoll; - public int cacheID; - public int minSpawn; - public int maxSpawn; - - public ItemTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.cacheID = rs.getInt("itemBaseUUID"); - this.minSpawn = rs.getInt("minSpawn"); - this.maxSpawn = rs.getInt("maxSpawn"); - - } - } - - public static class ModTypeTableRow { - public int minRoll; - public int maxRoll; - public int modTableID; - - public ModTypeTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.modTableID = rs.getInt("subTableID"); - - } - } - - public static class ModTableRow { - public int minRoll; - public int maxRoll; - public String action; - public int level; - - public ModTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.action = rs.getString("action"); - this.level = rs.getInt("level"); - - } - } } \ No newline at end of file diff --git a/src/engine/loot/GenTable.java b/src/engine/loot/GenTable.java new file mode 100644 index 00000000..5b5dd997 --- /dev/null +++ b/src/engine/loot/GenTable.java @@ -0,0 +1,18 @@ +package engine.loot; + +import java.util.ArrayList; + +public class GenTable { + public ArrayList rows = new ArrayList(); + + public GenTableRow getRowForRange(int roll) { + + GenTableRow outRow = null; + + for (GenTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + outRow = iteration; + + return outRow; + } +} diff --git a/src/engine/loot/GenTableRow.java b/src/engine/loot/GenTableRow.java new file mode 100644 index 00000000..e72a4cf3 --- /dev/null +++ b/src/engine/loot/GenTableRow.java @@ -0,0 +1,20 @@ +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class GenTableRow { + public int minRoll; + public int maxRoll; + public int itemTableID; + public int pModTable; + public int sModTable; + + public GenTableRow(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.itemTableID = rs.getInt("lootTableID"); + this.pModTable = rs.getInt("pModTableID"); + this.sModTable = rs.getInt("sModTableID"); + } +} diff --git a/src/engine/loot/ItemTable.java b/src/engine/loot/ItemTable.java new file mode 100644 index 00000000..e2afc1b4 --- /dev/null +++ b/src/engine/loot/ItemTable.java @@ -0,0 +1,21 @@ +package engine.loot; + +import java.util.ArrayList; + +public class ItemTable { + public ArrayList rows = new ArrayList<>(); + + public ItemTableRow getRowForRange(int roll) { + + if (roll > 320) + roll = 320; + + ItemTableRow outRow = null; + + for (ItemTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + outRow = iteration; + + return outRow; + } +} diff --git a/src/engine/loot/ItemTableRow.java b/src/engine/loot/ItemTableRow.java new file mode 100644 index 00000000..00a20b8a --- /dev/null +++ b/src/engine/loot/ItemTableRow.java @@ -0,0 +1,20 @@ +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ItemTableRow { + public int minRoll; + public int maxRoll; + public int cacheID; + public int minSpawn; + public int maxSpawn; + + public ItemTableRow(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.cacheID = rs.getInt("itemBaseUUID"); + this.minSpawn = rs.getInt("minSpawn"); + this.maxSpawn = rs.getInt("maxSpawn"); + } +} diff --git a/src/engine/loot/ModTable.java b/src/engine/loot/ModTable.java new file mode 100644 index 00000000..06908938 --- /dev/null +++ b/src/engine/loot/ModTable.java @@ -0,0 +1,21 @@ +package engine.loot; + +import java.util.ArrayList; + +public class ModTable { + public ArrayList rows = new ArrayList(); + + public ModTableRow getRowForRange(int roll) { + + if (roll > 320) + roll = 320; + + ModTableRow outRow = null; + + for (ModTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + outRow = iteration; + + return outRow; + } +} diff --git a/src/engine/loot/ModTableRow.java b/src/engine/loot/ModTableRow.java new file mode 100644 index 00000000..94665cf6 --- /dev/null +++ b/src/engine/loot/ModTableRow.java @@ -0,0 +1,18 @@ +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ModTableRow { + public int minRoll; + public int maxRoll; + public String action; + public int level; + + public ModTableRow(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.action = rs.getString("action"); + this.level = rs.getInt("level"); + } +} diff --git a/src/engine/loot/ModTypeTable.java b/src/engine/loot/ModTypeTable.java new file mode 100644 index 00000000..b444a73b --- /dev/null +++ b/src/engine/loot/ModTypeTable.java @@ -0,0 +1,18 @@ +package engine.loot; + +import java.util.ArrayList; + +public class ModTypeTable { + public ArrayList rows = new ArrayList<>(); + + public ModTypeTableRow getRowForRange(int roll) { + + ModTypeTableRow outRow = null; + + for (ModTypeTableRow iteration : this.rows) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + return iteration; + + return outRow; + } +} diff --git a/src/engine/loot/ModTypeTableRow.java b/src/engine/loot/ModTypeTableRow.java new file mode 100644 index 00000000..13b8cef9 --- /dev/null +++ b/src/engine/loot/ModTypeTableRow.java @@ -0,0 +1,16 @@ +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ModTypeTableRow { + public int minRoll; + public int maxRoll; + public int modTableID; + + public ModTypeTableRow(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.modTableID = rs.getInt("subTableID"); + } +} From 765b837df0e55c0f5505a1393f528a447cf9dad8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 3 Aug 2023 15:20:31 -0400 Subject: [PATCH 17/88] Unused methods deleted. --- src/engine/gameManager/LootManager.java | 4 + src/engine/objects/LootTable.java | 740 ++---------------------- 2 files changed, 41 insertions(+), 703 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index dff01fdd..4661e3cc 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -46,11 +46,15 @@ public enum LootManager { public static void init() { + // Load loot tables from database. + DbManager.LootQueries.LOAD_ALL_LOOTGROUPS(); DbManager.LootQueries.LOAD_ALL_LOOTTABLES(); DbManager.LootQueries.LOAD_ALL_MODGROUPS(); DbManager.LootQueries.LOAD_ALL_MODTABLES(); + // Cache drop rate values from Config manager. + NORMAL_DROP_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); NORMAL_EXP_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()); NORMAL_GOLD_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_GOLD_RATE.getValue()); diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index 78bd3188..0ad13973 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -13,19 +13,14 @@ import engine.Enum.ItemContainerType; import engine.Enum.ItemType; import engine.Enum.OwnerType; import engine.gameManager.DbManager; -import engine.gameManager.NPCManager; -import engine.gameManager.ZoneManager; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; -import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; -import static engine.gameManager.LootManager.LOOTMANAGER; - public class LootTable { private static final ConcurrentHashMap lootGroups = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); @@ -33,10 +28,6 @@ public class LootTable { private static final ConcurrentHashMap modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap modGroups = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap statRuneChances = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final int oneDrop = 95; - private static final int twoDrop = 100; - private static final int noDropHotZone = 79; - private static final int oneDropHotZone = 98; public static boolean initialized = false; public static HashMap itemsDroppedMap = new HashMap<>(); public static HashMap resourceDroppedMap = new HashMap<>(); @@ -79,6 +70,7 @@ public class LootTable { LootTable lootTable = new LootTable(UUID); lootTables.put(UUID, lootTable); + return lootTable; } @@ -111,23 +103,30 @@ public class LootTable { } public static LootTable getModGroup(int UUID) { + if (modGroups.containsKey(UUID)) return modGroups.get(UUID); + LootTable modTable = new LootTable(UUID); modGroups.put(UUID, modTable); + return modTable; } public static LootTable getModTable(int UUID) { + if (modTables.containsKey(UUID)) return modTables.get(UUID); + LootTable modTypeTable = new LootTable(UUID); modTables.put(UUID, modTypeTable); + return modTypeTable; } //call this on server startup to populate the tables public static void populateLootTables() { + DbManager.LootQueries.populateLootGroups(); DbManager.LootQueries.populateLootTables(); DbManager.LootQueries.populateModTables(); @@ -137,580 +136,8 @@ public class LootTable { populateStatRuneChances(); } - //Returns a list of random loot for a mob based on level, lootTable and hotzone - public static ArrayList getMobLoot(Mob mobile, int mobLevel, int lootTable, boolean hotzone) { - - ArrayList mobLoot; - int calculatedLootTable; - int randomRoll; - - mobLoot = new ArrayList<>(); - - // Setup default loot table if none exists - - calculatedLootTable = lootTable; - - LootTable.rollCount++; - - if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()) { - - randomRoll = ThreadLocalRandom.current().nextInt(100); - - if (randomRoll > 90) - if (randomRoll > LootTable.oneDropHotZone) - addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true); - else - addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true); - } else { - for (MobLootBase mlb : MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())) { - - float chance = mlb.getChance() * .01f; - - chance *= LOOTMANAGER.NORMAL_DROP_RATE; - - calculatedLootTable = mlb.getLootTableID(); - - if (ThreadLocalRandom.current().nextFloat() > chance) - continue; - - addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, false); - - } - } - - //calculatedLootTable = lootTable; - - if (calculatedLootTable <= 1) - calculatedLootTable = 1300; // GENERIC WORLD - - //handle hotzone random loot - - if (hotzone) { - - LootTable.rollCount++; - - if (!MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()) - for (MobLootBase mlb : MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())) { - if (!LootTable.lootGroups.containsKey(mlb.getLootTableID() + 1)) - continue; - calculatedLootTable = mlb.getLootTableID(); - break; - } - - randomRoll = ThreadLocalRandom.current().nextInt(100); - - if (randomRoll > 90) - if (randomRoll > LootTable.oneDropHotZone) - addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true); - else - addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true); - } - - //handle mob specific special loot - - ArrayList bootyLoot = getBootyLoot(mobile); - mobLoot.addAll(bootyLoot); - - return mobLoot; - } - - public static ArrayList getMobLootDeath(Mob mobile, int mobLevel, int lootTable) { - ArrayList mobLoot = new ArrayList<>(); - - if (mobile == null) - return mobLoot; - - //handle hotzone random loot - boolean hotzone = ZoneManager.inHotZone(mobile.getLoc()); - if (hotzone) { - - if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()) { - lootTable += 1; - - if (lootTable <= 1) - lootTable = 1301; // GENERIC WORLD - int roll = ThreadLocalRandom.current().nextInt(100); - if (roll > 90) - if (roll > LootTable.oneDropHotZone) - addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true); - else - addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true); - } else { - for (MobLootBase mlb : MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())) { - lootTable = mlb.getLootTableID() + 1; - if (!LootTable.lootGroups.containsKey(lootTable)) - continue; - - int roll = ThreadLocalRandom.current().nextInt(100); - if (roll > 90) - if (roll > LootTable.oneDropHotZone) - addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true); - else - addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true); - - break; - } - } - - - if (mobLoot.isEmpty()) { - - LootTable.rollCount++; //add another rollCount here. - int resourceRoll = ThreadLocalRandom.current().nextInt(100); - if (resourceRoll <= 5) - addMobLootResources(mobile, mobLoot, mobLevel, (lootTable), 1, true); - } - - } - - - //handle mob specific booty on death - - ArrayList bootyLoot = getBootyLoot(mobile); - mobLoot.addAll(bootyLoot); - - return mobLoot; - } - - private static ArrayList getBootyLoot(Mob mob) { - - ArrayList bootySetList; - ArrayList mobLootList = new ArrayList<>(); - - if (mob.bootySet == 0) - return mobLootList; - - bootySetList = NPCManager._bootySetMap.get(mob.bootySet); - - for (BootySetEntry bootyEntry : bootySetList) - if (ThreadLocalRandom.current().nextInt(100) < bootyEntry.dropChance) { - ItemBase itemBase = ItemBase.getItemBase(bootyEntry.itemBase); - - if (itemBase != null) { - MobLoot mobLoot = new MobLoot(mob, itemBase, true); - mobLootList.add(mobLoot); - } - } - return mobLootList; - } - - //called by getMobLoot to add the actual loot - private static void addMobLoot(Mob mob, ArrayList loot, int mobLevel, int lootTableID, int cnt, boolean hotzone) { - - // Member variable declaration - float calculatedMobLevel; - int minSpawn; - int maxSpawn; - int spawnQuanity = 0; - int prefixValue = 0; - int suffixValue = 0; - int subTableID; - String modifierPrefix = ""; - String modifierSuffix = ""; - - // Lookup Table Variables - LootTable lootTable; - LootRow lootRow; - LootTable lootGroup; - LootRow groupRow = null; - LootTable modTable; - LootTable modGroup; - LootRow modRow = null; - - // Used for actual generation of items - - int itemBaseUUID; - ItemBase itemBase = null; - MobLoot mobLoot; - - if (!LootTable.lootGroups.containsKey(lootTableID)) - return; - - lootGroup = LootTable.lootGroups.get(lootTableID); - - calculatedMobLevel = mobLevel; - - if (calculatedMobLevel > 49) - calculatedMobLevel = 49; - - - int randomRoll = 0; - for (int i = 0; i < cnt; i++) { - - Random random = new Random(); - - randomRoll = random.nextInt(100) + 1; //random roll between 1 and 100 - groupRow = lootGroup.getLootRow(randomRoll); - - if (groupRow == null) - return; - - //get loot table for this group - if (!LootTable.lootTables.containsKey(groupRow.getValueOne())) - return; - - lootTable = LootTable.lootTables.get(groupRow.getValueOne()); - - int minRoll = (int) ((calculatedMobLevel - 5) * 5); - int maxRoll = (int) ((calculatedMobLevel + 15) * 5); - - if (minRoll < (int) lootTable.minRoll) - minRoll = (int) lootTable.minRoll; - - if (maxRoll < minRoll) - maxRoll = minRoll; - - if (maxRoll > lootTable.maxRoll) - maxRoll = (int) lootTable.maxRoll; - - if (maxRoll > 320) - maxRoll = 320; - - randomRoll = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? - - lootRow = lootTable.getLootRow(randomRoll); //get the item row from the bell's curve of level +-15 - - if (lootRow == null) - continue; //no item found for roll - - itemBaseUUID = lootRow.getValueOne(); - - if (lootRow.getValueOne() == 0) - continue; - - //handle quantities > 1 for resource drops - - minSpawn = lootRow.getValueTwo(); - maxSpawn = lootRow.getValueThree(); - - // spawnQuantity between min spawn (inclusive) and max spawn (inclusive) - if (maxSpawn > 1) - spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; - - //get modifierPrefix - - calculatedMobLevel = mobLevel; - - if (calculatedMobLevel < 16) - calculatedMobLevel = 16; - - if (calculatedMobLevel > 49) - calculatedMobLevel = 49; - - int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1; - - if (chanceMod < 25) { - modGroup = LootTable.modGroups.get(groupRow.getValueTwo()); - - if (modGroup != null) { - - for (int a = 0; a < 10; a++) { - randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(randomRoll); - if (modRow != null) - break; - } - - if (modRow != null) { - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - - randomRoll = gaussianLevel((int) calculatedMobLevel); - - if (randomRoll < modTable.minRoll) - randomRoll = (int) modTable.minRoll; - - if (randomRoll > modTable.maxRoll) - randomRoll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(randomRoll); - - if (modRow != null) { - prefixValue = modRow.getValueOne(); - modifierPrefix = modRow.getAction(); - } - } - } - } - } else if (chanceMod < 50) { - modGroup = LootTable.modGroups.get(groupRow.getValueThree()); - - if (modGroup != null) { - - for (int a = 0; a < 10; a++) { - randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(randomRoll); - if (modRow != null) - break; - } - - if (modRow != null) { - - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - randomRoll = gaussianLevel((int) calculatedMobLevel); - - if (randomRoll < modTable.minRoll) - randomRoll = (int) modTable.minRoll; - - if (randomRoll > modTable.maxRoll) - randomRoll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(randomRoll); - - if (modRow == null) - modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - - - if (modRow != null) { - suffixValue = modRow.getValueOne(); - modifierSuffix = modRow.getAction(); - } - } - } - } - } else { - modGroup = LootTable.modGroups.get(groupRow.getValueTwo()); - - if (modGroup != null) { - - - for (int a = 0; a < 10; a++) { - randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(randomRoll); - if (modRow != null) - break; - } - - - if (modRow != null) { - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - - randomRoll = gaussianLevel((int) calculatedMobLevel); - - if (randomRoll < modTable.minRoll) - randomRoll = (int) modTable.minRoll; - - if (randomRoll > modTable.maxRoll) - randomRoll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(randomRoll); - - if (modRow == null) - modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - - if (modRow != null) { - prefixValue = modRow.getValueOne(); - modifierPrefix = modRow.getAction(); - } - } - } - } - - //get modifierSuffix - modGroup = LootTable.modGroups.get(groupRow.getValueThree()); - - if (modGroup != null) { - - for (int a = 0; a < 10; a++) { - randomRoll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(randomRoll); - if (modRow != null) - break; - } - - if (modRow != null) { - - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - randomRoll = gaussianLevel((int) calculatedMobLevel); - - if (randomRoll < modTable.minRoll) - randomRoll = (int) modTable.minRoll; - - if (randomRoll > modTable.maxRoll) - randomRoll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(randomRoll); - - if (modRow == null) - modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - - if (modRow != null) { - suffixValue = modRow.getValueOne(); - modifierSuffix = modRow.getAction(); - } - } - } - } - } - - itemBase = ItemBase.getItemBase(itemBaseUUID); - - if (itemBase == null) - return; - - //Handle logging of drops - LootTable.HandleDropLogs(itemBase); - - if (itemBase.getType() == ItemType.OFFERING) - spawnQuanity = 1; - - if (spawnQuanity > 0) - mobLoot = new MobLoot(mob, itemBase, spawnQuanity, false); - else - mobLoot = new MobLoot(mob, itemBase, false); - - if (!modifierPrefix.isEmpty()) - mobLoot.addPermanentEnchantment(modifierPrefix, 0, prefixValue, true); - - if (!modifierSuffix.isEmpty()) - mobLoot.addPermanentEnchantment(modifierSuffix, 0, suffixValue, false); - - mobLoot.loadEnchantments(); - - loot.add(mobLoot); - - } - } - - private static void addMobLootResources(Mob mob, ArrayList loot, int mobLevel, int lootTableID, int cnt, boolean hotzone) { - - // Member variable declaration - float calculatedMobLevel; - int minSpawn; - int maxSpawn; - int spawnQuanity = 0; - - // Lookup Table Variables - LootTable lootTable; - LootRow lootRow; - LootTable lootGroup; - LootRow groupRow = null; - - // Used for actual generation of items - int itemBaseUUID; - ItemBase itemBase; - MobLoot mobLoot; - - if (!LootTable.lootGroups.containsKey(lootTableID)) - return; - - lootGroup = LootTable.lootGroups.get(lootTableID); - - calculatedMobLevel = mobLevel; - - if (calculatedMobLevel > 49) - calculatedMobLevel = 49; - - int roll = 0; - for (int i = 0; i < cnt; i++) { - - if (lootTableID == 1901) - groupRow = lootGroup.getLootRow(66); - else if (lootTableID == 1501) - groupRow = lootGroup.getLootRow(98); - else - groupRow = lootGroup.getLootRow(80); - - if (groupRow == null) - return; - - //get loot table for this group - - if (!LootTable.lootTables.containsKey(groupRow.getValueOne())) - return; - - lootTable = LootTable.lootTables.get(groupRow.getValueOne()); - - int minRoll = (int) ((calculatedMobLevel - 5) * 5); - int maxRoll = (int) ((calculatedMobLevel + 15) * 5); - - if (minRoll < (int) lootTable.minRoll) - minRoll = (int) lootTable.minRoll; - - if (maxRoll < minRoll) - maxRoll = minRoll; - - if (maxRoll > 320) - maxRoll = 320; - - roll = ThreadLocalRandom.current().nextInt(minRoll, maxRoll + 1); //Does not return Max, but does return min? - lootRow = lootTable.getLootRow(roll); //get the item row from the bell's curve of level +-15 - - if (lootRow == null) - continue; //no item found for roll - - itemBaseUUID = lootRow.getValueOne(); - - if (lootRow.getValueOne() == 0) - continue; - - //handle quantities > 1 for resource drops - - minSpawn = lootRow.getValueTwo(); - maxSpawn = lootRow.getValueThree(); - - // spawnQuanity between minspawn (inclusive) and maxspawn (inclusive) - - if (maxSpawn > 1) - spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; - - itemBase = ItemBase.getItemBase(itemBaseUUID); - - if (itemBase == null) - return; - - LootTable.HandleDropLogs(itemBase); - - switch (itemBase.getUUID()) { - case 19290: - continue; - case 19291: - continue; - case 19292: - continue; - case 27530: - continue; - case 973000: - continue; - case 973200: - continue; - - case 26360: - continue; - } - - // Handle drop rates of resources/runes/contracts. - // We intentionally drop them in half - - if (itemBase.getType() == ItemType.OFFERING) - spawnQuanity = 1; - - if (spawnQuanity > 0) - mobLoot = new MobLoot(mob, itemBase, spawnQuanity, false); - else - mobLoot = new MobLoot(mob, itemBase, false); - - loot.add(mobLoot); - - } - } - public static int gaussianLevel(int level) { + int ret = -76; while (ret < -75 || ret > 75) { @@ -723,6 +150,7 @@ public class LootTable { //This set's the drop chances for stat runes. public static void populateStatRuneChances() { + //+3, Increased statRuneChances.put(250018, 60); statRuneChances.put(250009, 60); @@ -787,74 +215,6 @@ public class LootTable { statRuneChances.put(250008, 60); } - private static void HandleDropLogs(ItemBase itemBase) { - - if (itemBase == null) - return; - - LootTable.dropCount++; //item dropped, add to all item count. - - - if (LootTable.itemsDroppedMap.get(itemBase) == null) { - LootTable.itemsDroppedMap.put(itemBase, 1); //First time dropping, make count 1. - } else { - int dropCount = LootTable.itemsDroppedMap.get(itemBase); - dropCount++; - LootTable.itemsDroppedMap.put(itemBase, dropCount); - } - - switch (itemBase.getType()) { - case RESOURCE: - LootTable.resourceCount++; - - if (LootTable.resourceDroppedMap.get(itemBase) == null) { - LootTable.resourceDroppedMap.put(itemBase, 1); //First time dropping, make count 1. - } else { - int dropCount = LootTable.resourceDroppedMap.get(itemBase); - dropCount++; - LootTable.resourceDroppedMap.put(itemBase, dropCount); - } - break; - case RUNE: - LootTable.runeCount++; - if (LootTable.runeDroppedMap.get(itemBase) == null) { - LootTable.runeDroppedMap.put(itemBase, 1); //First time dropping, make count 1. - } else { - int dropCount = LootTable.runeDroppedMap.get(itemBase); - dropCount++; - LootTable.runeDroppedMap.put(itemBase, dropCount); - } - break; - case CONTRACT: - LootTable.contractCount++; - - if (LootTable.contractDroppedMap.get(itemBase) == null) { - LootTable.contractDroppedMap.put(itemBase, 1); //First time dropping, make count 1. - } else { - int dropCount = LootTable.contractDroppedMap.get(itemBase); - dropCount++; - LootTable.contractDroppedMap.put(itemBase, dropCount); - } - - break; - case WEAPON: //Glass Drop - - if (itemBase.isGlass()) { - LootTable.glassCount++; - if (LootTable.glassDroppedMap.get(itemBase) == null) { - LootTable.glassDroppedMap.put(itemBase, 1); //First time dropping, make count 1. - } else { - int dropCount = LootTable.glassDroppedMap.get(itemBase); - dropCount++; - LootTable.glassDroppedMap.put(itemBase, dropCount); - } - } - - break; - } - - } - public static Item CreateGamblerItem(Item item, PlayerCharacter gambler) { if (item == null) @@ -931,25 +291,25 @@ public class LootTable { break; } //couldnt find group + if (groupID == 0) return null; - LootTable lootGroup = LootTable.lootGroups.get(groupID); if (lootGroup == null) return null; + float calculatedMobLevel; int minSpawn; int maxSpawn; int spawnQuanity = 0; - int prefixValue = 0; - int suffixValue = 0; int subTableID; String modifierPrefix = ""; String modifierSuffix = ""; // Lookup Table Variables + LootTable lootTable; LootRow lootRow; LootRow groupRow = null; @@ -958,10 +318,9 @@ public class LootTable { LootRow modRow = null; // Used for actual generation of items + int itemBaseUUID; ItemBase itemBase = null; - MobLoot mobLoot; - int roll = ThreadLocalRandom.current().nextInt(100) + 1; //Does not return Max, but does return min? @@ -976,24 +335,23 @@ public class LootTable { itemBaseUUID = lootRow.getValueOne(); - if (lootRow.getValueOne() == 0) return null; //handle quantities > 1 for resource drops + minSpawn = lootRow.getValueTwo(); maxSpawn = lootRow.getValueThree(); // spawnQuanity between minspawn (inclusive) and maxspawn (inclusive) + if (maxSpawn > 1) spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; - //get modifierPrefix calculatedMobLevel = 49; - int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1; if (chanceMod < 25) { @@ -1001,7 +359,6 @@ public class LootTable { if (modGroup != null) { - for (int a = 0; a < 10; a++) { roll = ThreadLocalRandom.current().nextInt(100) + 1; modRow = modGroup.getLootRow(roll); @@ -1009,7 +366,6 @@ public class LootTable { break; } - if (modRow != null) { subTableID = modRow.getValueOne(); @@ -1025,13 +381,10 @@ public class LootTable { if (roll > modTable.maxRoll) roll = (int) modTable.maxRoll; - modRow = modTable.getLootRow(roll); - if (modRow != null) { - prefixValue = modRow.getValueOne(); + if (modRow != null) modifierPrefix = modRow.getAction(); - } } } } @@ -1064,14 +417,11 @@ public class LootTable { modRow = modTable.getLootRow(roll); - if (modRow == null) { + if (modRow == null) modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - } - if (modRow != null) { - suffixValue = modRow.getValueOne(); + if (modRow != null) modifierSuffix = modRow.getAction(); - } } } } @@ -1080,7 +430,6 @@ public class LootTable { if (modGroup != null) { - for (int a = 0; a < 10; a++) { roll = ThreadLocalRandom.current().nextInt(100) + 1; modRow = modGroup.getLootRow(roll); @@ -1088,14 +437,13 @@ public class LootTable { break; } - if (modRow != null) { + subTableID = modRow.getValueOne(); if (LootTable.modTables.containsKey(subTableID)) { modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int) calculatedMobLevel); if (roll < modTable.minRoll) @@ -1104,17 +452,13 @@ public class LootTable { if (roll > modTable.maxRoll) roll = (int) modTable.maxRoll; - modRow = modTable.getLootRow(roll); - if (modRow == null) { + if (modRow == null) modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - } - if (modRow != null) { - prefixValue = modRow.getValueOne(); + if (modRow != null) modifierPrefix = modRow.getAction(); - } } } } @@ -1148,30 +492,24 @@ public class LootTable { modRow = modTable.getLootRow(roll); - if (modRow == null) { + if (modRow == null) modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - } - if (modRow != null) { - suffixValue = modRow.getValueOne(); + if (modRow != null) modifierSuffix = modRow.getAction(); - } } } } } - itemBase = ItemBase.getItemBase(itemBaseUUID); byte charges = (byte) itemBase.getNumCharges(); short dur = (short) itemBase.getDurability(); - short weight = itemBase.getWeight(); - if (!gambler.getCharItemManager().hasRoomInventory(weight)) { - return null; - } + if (!gambler.getCharItemManager().hasRoomInventory(weight)) + return null; Item gambledItem = new Item(itemBase, gambler.getObjectUUID(), OwnerType.PlayerCharacter, charges, charges, dur, dur, @@ -1186,25 +524,22 @@ public class LootTable { try { gambledItem = DbManager.ItemQueries.ADD_ITEM(gambledItem); - } catch (Exception e) { Logger.error(e); } - if (gambledItem == null) { - + if (gambledItem == null) return null; - } + if (!modifierPrefix.isEmpty()) gambledItem.addPermanentEnchantment(modifierPrefix, 0); if (!modifierSuffix.isEmpty()) gambledItem.addPermanentEnchantment(modifierSuffix, 0); - //add item to inventory - gambler.getCharItemManager().addItemToInventory(gambledItem); + gambler.getCharItemManager().addItemToInventory(gambledItem); gambler.getCharItemManager().updateInventory(); return gambledItem; @@ -1213,6 +548,7 @@ public class LootTable { public void addRow(float min, float max, int valueOne, int valueTwo, int valueThree, String action) { //hackey way to set the minimum roll for SHIAT! + if (min < this.minRoll) this.minRoll = min; @@ -1223,29 +559,27 @@ public class LootTable { int maxInt = (int) max; //Round up min - if (minInt != min) { + + if (minInt != min) min = minInt + 1; - } //Round down max; + if (maxInt != max) max = maxInt; - LootRow lootRow = new LootRow(valueOne, valueTwo, valueThree, action); - for (int i = (int) min; i <= max; i++) { + + for (int i = (int) min; i <= max; i++) lootTable.put(i, lootRow); - } } public LootRow getLootRow(int probability) { + if (lootTable.containsKey(probability)) return lootTable.get(probability); - return null; - } - public ConcurrentHashMap getLootTable() { - return lootTable; + return null; } } From a09ce6b4fc3de417767d544b7ce27a733c89a411 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 19:18:05 -0500 Subject: [PATCH 18/88] cleanup and lots of null checks --- src/engine/gameManager/LootManager.java | 65 ++++++++++++++++--------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 4661e3cc..18d94f13 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -100,7 +100,8 @@ public enum LootManager { chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); } - + if (it.getEnchants().isEmpty() == true) + it.setIsID(true); } } } @@ -116,9 +117,11 @@ public enum LootManager { GenerateGoldDrop(mob, bse, inHotzone); break; case "LOOT": + //always run base table loot drop GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier); //generate normal loot drop if (inHotzone) + //run another iteration for the hotzone table if in hotzone if (generalItemTables.containsKey(bse.lootTable + 1)) GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier); //generate loot drop from hotzone table break; @@ -132,20 +135,22 @@ public enum LootManager { public static MobLoot getGenTableItem(int genTableID, Mob mob) { - if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) + if (mob == null || generalItemTables.containsKey(genTableID) == false) return null; MobLoot outItem; - int genRoll; - genRoll = new Random().nextInt(99) + 1; - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + int genRoll = new Random().nextInt(99) + 1; + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); if (selectedRow == null) return null; int itemTableId = selectedRow.itemTableID; + if(itemTables.containsKey(itemTableId) == false) + return null; + //gets the 1-320 roll for this mob int roll2 = TableRoll(mob.level); @@ -193,14 +198,24 @@ public enum LootManager { if (prefixChanceRoll < prefixChance) { GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + if(selectedRow == null) + return inItem; + ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); + if(prefixTable == null) + return inItem; int prefixroll = ThreadLocalRandom.current().nextInt(99) + 1; if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); + if(prefixModTable == null) + return inItem; + ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level)); + if(prefixMod == null) + return inItem; if (prefixMod != null && prefixMod.action.length() > 0) { inItem.setPrefix(prefixMod.action); @@ -219,13 +234,24 @@ public enum LootManager { if (suffixChanceRoll < suffixChance) { GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + if(selectedRow == null) + return inItem; + int suffixroll = ThreadLocalRandom.current().nextInt(99) + 1; + ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); + if(suffixTable == null) + return inItem; if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); + if(suffixModTable == null) + return inItem; + ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level)); + if(suffixMod == null) + return inItem; if (suffixMod != null && suffixMod.action.length() > 0) { inItem.setSuffix(suffixMod.action); @@ -246,7 +272,8 @@ public enum LootManager { if (max > 319) max = 319; - int min = (int) (4.469 * mobLevel - 3.469); + int min = (int) (2.089 * mobLevel + 22.14); + int roll = ThreadLocalRandom.current().nextInt(max - min) + min; return roll; @@ -256,7 +283,7 @@ public enum LootManager { int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - //early exit, failed to hit minimum chance roll OR booty was generated from mob's death + //early exit, failed to hit minimum chance roll if (chanceRoll > bse.dropChance) return; @@ -270,7 +297,7 @@ public enum LootManager { if (inHotzone == true) gold = (int) (gold * HOTZONE_GOLD_RATE); else - gold = (int) (NORMAL_GOLD_RATE); + gold = (int) (gold * NORMAL_GOLD_RATE); if (gold > 0) { MobLoot goldAmount = new MobLoot(mob, gold); @@ -292,9 +319,6 @@ public enum LootManager { MobLoot toAdd = getGenTableItem(tableID, mob); if (toAdd != null) { - if (toAdd.getPrefix() == null && toAdd.getSuffix() == null) - toAdd.setIsID(true); - mob.getCharItemManager().addItemToInventory(toAdd); } } catch (Exception e) { @@ -313,17 +337,14 @@ public enum LootManager { if (me.getDropChance() == 0) continue; - float equipmentRoll = ThreadLocalRandom.current().nextInt(101); + float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1; 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); - + if (equipmentRoll > (dropChance * multiplier)) + continue; + MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + if (ml != null) mob.getCharItemManager().addItemToInventory(ml); - } } } } @@ -337,10 +358,10 @@ public enum LootManager { if (chanceRoll > bse.dropChance * multiplier) return; - MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); + MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); - if (disc != null) - mob.getCharItemManager().addItemToInventory(disc); + if (lootItem != null) + mob.getCharItemManager().addItemToInventory(lootItem); } public static void AddGenTableRow(int tableID, GenTableRow row) { From 0e35eea03664231bf82576326f273367bae69de6 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 19:21:35 -0500 Subject: [PATCH 19/88] hotzone slightly increase mob min roll --- src/engine/gameManager/LootManager.java | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 18d94f13..4d4ad929 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -118,12 +118,12 @@ public enum LootManager { break; case "LOOT": //always run base table loot drop - GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier); //generate normal loot drop + GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier, false); //generate normal loot drop if (inHotzone) //run another iteration for the hotzone table if in hotzone if (generalItemTables.containsKey(bse.lootTable + 1)) - GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier); //generate loot drop from hotzone table + GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier, true); //generate loot drop from hotzone table break; case "ITEM": GenerateItemLootDrop(mob, bse, multiplier); @@ -133,7 +133,7 @@ public enum LootManager { } } - public static MobLoot getGenTableItem(int genTableID, Mob mob) { + public static MobLoot getGenTableItem(int genTableID, Mob mob, Boolean inHotzone) { if (mob == null || generalItemTables.containsKey(genTableID) == false) return null; @@ -153,7 +153,7 @@ public enum LootManager { //gets the 1-320 roll for this mob - int roll2 = TableRoll(mob.level); + int roll2 = TableRoll(mob.level,inHotzone); ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); @@ -176,12 +176,12 @@ public enum LootManager { if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { try { - outItem = GeneratePrefix(mob, outItem, genTableID, genRoll); + outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); } catch (Exception e) { Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); } try { - outItem = GenerateSuffix(mob, outItem, genTableID, genRoll); + outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); } catch (Exception e) { Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); } @@ -190,7 +190,7 @@ public enum LootManager { return outItem; } - private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll) { + private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { int prefixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; double prefixChance = 2.057 * mob.level - 28.67; @@ -213,7 +213,7 @@ public enum LootManager { if(prefixModTable == null) return inItem; - ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level)); + ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); if(prefixMod == null) return inItem; @@ -226,7 +226,7 @@ public enum LootManager { return inItem; } - private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll) { + private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { int suffixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; double suffixChance = 2.057 * mob.level - 28.67; @@ -249,7 +249,7 @@ public enum LootManager { if(suffixModTable == null) return inItem; - ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level)); + ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); if(suffixMod == null) return inItem; @@ -262,7 +262,7 @@ public enum LootManager { return inItem; } - private static int TableRoll(int mobLevel) { + private static int TableRoll(int mobLevel, Boolean inHotzone) { if (mobLevel > 65) mobLevel = 65; @@ -273,6 +273,9 @@ public enum LootManager { max = 319; int min = (int) (2.089 * mobLevel + 22.14); + if(inHotzone){ + min += mobLevel; + } int roll = ThreadLocalRandom.current().nextInt(max - min) + min; @@ -306,7 +309,7 @@ public enum LootManager { } - public static void GenerateLootDrop(Mob mob, int tableID, float dropChance, float multiplier) { + public static void GenerateLootDrop(Mob mob, int tableID, float dropChance, float multiplier, Boolean inHotzone) { try { int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; @@ -316,7 +319,7 @@ public enum LootManager { if (chanceRoll > dropChance * multiplier) return; - MobLoot toAdd = getGenTableItem(tableID, mob); + MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); if (toAdd != null) { mob.getCharItemManager().addItemToInventory(toAdd); From 9a03dc36c634f1007a9bbd878319afca030d2a1c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 19:24:35 -0500 Subject: [PATCH 20/88] add goldTally to simulateBooty command --- src/engine/devcmd/cmds/simulateBootyCmd.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/engine/devcmd/cmds/simulateBootyCmd.java b/src/engine/devcmd/cmds/simulateBootyCmd.java index ac51788e..76830acf 100644 --- a/src/engine/devcmd/cmds/simulateBootyCmd.java +++ b/src/engine/devcmd/cmds/simulateBootyCmd.java @@ -90,6 +90,7 @@ public class simulateBootyCmd extends AbstractDevCmd { ArrayList Offerings = new ArrayList(); ArrayList OtherDrops = new ArrayList(); int failures = 0; + int goldAmount = 0; for (int i = 0; i < 100; ++i) { try { @@ -109,20 +110,16 @@ public class simulateBootyCmd extends AbstractDevCmd { Runes.add(lootItem); break; case WEAPON: //WEAPON - if (lootItem.getItemBase().isGlass()) { + if (lootItem.getItemBase().isGlass()) GlassItems.add(lootItem); - } else { + else OtherDrops.add(lootItem); - if (lootItem.getName().toLowerCase().contains("crimson") || lootItem.getName().toLowerCase().contains("vorgrim") || lootItem.getName().toLowerCase().contains("bell")) { - output += lootItem.getName() + newline; - } - } + break; + case GOLD: + goldAmount += lootItem.getNumOfItems(); break; default: OtherDrops.add(lootItem); - if (lootItem.getName().toLowerCase().contains("crimson") || lootItem.getName().toLowerCase().contains("vorgrim") || lootItem.getName().toLowerCase().contains("bell")) { - output += lootItem.getName() + newline; - } break; } } From 32653216e90327ad6757c5d87de23d0fd569e94f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 19:27:48 -0500 Subject: [PATCH 21/88] added hotzone tables to simulate booty command --- src/engine/devcmd/cmds/simulateBootyCmd.java | 10 +++++++++- src/engine/gameManager/LootManager.java | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/engine/devcmd/cmds/simulateBootyCmd.java b/src/engine/devcmd/cmds/simulateBootyCmd.java index 76830acf..2f6a520c 100644 --- a/src/engine/devcmd/cmds/simulateBootyCmd.java +++ b/src/engine/devcmd/cmds/simulateBootyCmd.java @@ -3,7 +3,9 @@ package engine.devcmd.cmds; import engine.Enum; import engine.devcmd.AbstractDevCmd; import engine.gameManager.BuildingManager; +import engine.gameManager.LootManager; import engine.gameManager.NPCManager; +import engine.gameManager.ZoneManager; import engine.objects.*; import java.util.ArrayList; @@ -135,7 +137,13 @@ public class simulateBootyCmd extends AbstractDevCmd { output += "Mob BootySet: " + mob.bootySet + newline; output += "Tables Rolled On: " + newline; for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { - output += "[" + entry.bootyType + "] " + entry.lootTable + newline; + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + newline; + } + if(ZoneManager.inHotZone(mob.getLoc())){ + for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { + if(LootManager.generalItemTables.containsKey(entry.lootTable + 1) == true) + output += "HOTZONE TABLE [" + entry.bootyType + "] " + entry.lootTable + 1 + newline; + } } output += "Time Required To Gain Simulated Booty: " + respawnTime * 100 + " Seconds" + newline; output += "GLASS DROPS: " + GlassItems.size() + newline; diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 4d4ad929..872568d2 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -28,10 +28,10 @@ public enum LootManager { LOOTMANAGER; //new tables - private static final HashMap generalItemTables = new HashMap<>(); - private static final HashMap itemTables = new HashMap<>(); - private static final HashMap modTypeTables = new HashMap<>(); - private static final HashMap modTables = new HashMap<>(); + public static final HashMap generalItemTables = new HashMap<>(); + public static final HashMap itemTables = new HashMap<>(); + public static final HashMap modTypeTables = new HashMap<>(); + public static final HashMap modTables = new HashMap<>(); // Drop Rates From 92cb7418223e71b472847092174c40d683c7ff95 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 19:34:42 -0500 Subject: [PATCH 22/88] equipment drops added to simulate booty command --- src/engine/devcmd/cmds/simulateBootyCmd.java | 50 +++++++++----------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/engine/devcmd/cmds/simulateBootyCmd.java b/src/engine/devcmd/cmds/simulateBootyCmd.java index 2f6a520c..9c84322c 100644 --- a/src/engine/devcmd/cmds/simulateBootyCmd.java +++ b/src/engine/devcmd/cmds/simulateBootyCmd.java @@ -9,6 +9,7 @@ import engine.gameManager.ZoneManager; import engine.objects.*; import java.util.ArrayList; +import java.util.concurrent.ThreadLocalRandom; public class simulateBootyCmd extends AbstractDevCmd { public simulateBootyCmd() { @@ -50,32 +51,14 @@ public class simulateBootyCmd extends AbstractDevCmd { Enum.GameObjectType objType = target.getObjectType(); - int objectUUID = target.getObjectUUID(); String output; output = "Booty Simulation:" + newline; switch (objType) { - case Building: - - break; - case PlayerCharacter: - - break; - - case NPC: - - break; - case Mob: Mob mob = (Mob) target; output += "Name: " + mob.getName() + 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)) { @@ -91,6 +74,7 @@ public class simulateBootyCmd extends AbstractDevCmd { ArrayList Contracts = new ArrayList(); ArrayList Offerings = new ArrayList(); ArrayList OtherDrops = new ArrayList(); + ArrayList EquipmentDrops = new ArrayList(); int failures = 0; int goldAmount = 0; for (int i = 0; i < 100; ++i) { @@ -128,10 +112,22 @@ public class simulateBootyCmd extends AbstractDevCmd { } catch (Exception ex) { failures++; } - } - int respawnTime = mob.getMobBase().getSpawnTime(); - if (mob.spawnTime > 0) { - respawnTime = mob.spawnTime; + if (mob.getEquip() != null) { + for (MobEquipment me : mob.getEquip().values()) { + + if (me.getDropChance() == 0) + continue; + + float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1; + float dropChance = me.getDropChance() * 100; + + if (equipmentRoll > (dropChance)) + continue; + MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + if (ml != null) + EquipmentDrops.add(ml); + } + } } output += "MobBase BootySet: " + mob.getMobBase().bootySet + newline; output += "Mob BootySet: " + mob.bootySet + newline; @@ -145,18 +141,18 @@ public class simulateBootyCmd extends AbstractDevCmd { output += "HOTZONE TABLE [" + entry.bootyType + "] " + entry.lootTable + 1 + newline; } } - output += "Time Required To Gain Simulated Booty: " + respawnTime * 100 + " Seconds" + newline; 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; + output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline; + output += "TOTAL GOLD DROPPED: " + goldAmount + newline; + output += "EQUIPMENT DROPPED: " + EquipmentDrops.size() + newline; output += "FAILED ROLLS: " + failures + newline; break; + default: + break; } throwbackInfo(pc, output); } From 42967693d0dba6d35e81e7ebbb6cedf7cbdf99b2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 19:56:32 -0500 Subject: [PATCH 23/88] autoID if value = baseValue --- src/engine/gameManager/LootManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 872568d2..cc5df328 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -100,7 +100,7 @@ public enum LootManager { chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); } - if (it.getEnchants().isEmpty() == true) + if(it.getBaseValue() == it.getItemBase().getBaseValue()) it.setIsID(true); } } From d903bc767c878dd9047d611da9fc555065497892 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 19:59:20 -0500 Subject: [PATCH 24/88] fix wrong display for hotzone lot table in simulatebooty --- src/engine/devcmd/cmds/simulateBootyCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/simulateBootyCmd.java b/src/engine/devcmd/cmds/simulateBootyCmd.java index 9c84322c..a27d248b 100644 --- a/src/engine/devcmd/cmds/simulateBootyCmd.java +++ b/src/engine/devcmd/cmds/simulateBootyCmd.java @@ -138,7 +138,7 @@ public class simulateBootyCmd extends AbstractDevCmd { if(ZoneManager.inHotZone(mob.getLoc())){ for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { if(LootManager.generalItemTables.containsKey(entry.lootTable + 1) == true) - output += "HOTZONE TABLE [" + entry.bootyType + "] " + entry.lootTable + 1 + newline; + output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + newline; } } output += "GLASS DROPS: " + GlassItems.size() + newline; From 060e9f330c2d18fe3f102bf4041f5d92b3425eaa Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 20:06:47 -0500 Subject: [PATCH 25/88] fix for base value check --- src/engine/gameManager/LootManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index cc5df328..05bf8368 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -100,7 +100,7 @@ public enum LootManager { chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); } - if(it.getBaseValue() == it.getItemBase().getBaseValue()) + if(it.getValue() == it.getItemBase().getBaseValue()) it.setIsID(true); } } From b9f939c8b2b8c4574235ac5ee1f80fad61d4182c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 20:26:44 -0500 Subject: [PATCH 26/88] identify loot without prefix or suffix --- src/engine/gameManager/LootManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 05bf8368..b64d9922 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -100,8 +100,6 @@ public enum LootManager { chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); } - if(it.getValue() == it.getItemBase().getBaseValue()) - it.setIsID(true); } } } @@ -322,6 +320,8 @@ public enum LootManager { MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); if (toAdd != null) { + if(toAdd.getPrefix() != null || toAdd.getSuffix() != null) + toAdd.setIsID(true); mob.getCharItemManager().addItemToInventory(toAdd); } } catch (Exception e) { @@ -347,6 +347,8 @@ public enum LootManager { continue; MobLoot ml = new MobLoot(mob, me.getItemBase(), false); if (ml != null) + if(ml.getPrefix() != null || ml.getSuffix() != null) + ml.setIsID(true); mob.getCharItemManager().addItemToInventory(ml); } } @@ -364,6 +366,8 @@ public enum LootManager { MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); if (lootItem != null) + if(lootItem.getPrefix() != null || lootItem.getSuffix() != null) + lootItem.setIsID(true); mob.getCharItemManager().addItemToInventory(lootItem); } From f79ac6f8367405741125e315384b0c40528398a1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 20:29:13 -0500 Subject: [PATCH 27/88] revert min roll change --- src/engine/gameManager/LootManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index b64d9922..085110ee 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -270,7 +270,7 @@ public enum LootManager { if (max > 319) max = 319; - int min = (int) (2.089 * mobLevel + 22.14); + int min = (int)(4.469 * mobLevel - 3.469); if(inHotzone){ min += mobLevel; } From c514cad1d9d5df6da96effca6ca11a90d2eefec1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 20:44:25 -0500 Subject: [PATCH 28/88] no enchant item identification --- src/engine/gameManager/LootManager.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 085110ee..eead7c38 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -170,7 +170,8 @@ public enum LootManager { outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); Enum.ItemType outType = outItem.getItemBase().getType(); - + outItem.setIsID(true); + outItem.setIsID(true); if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { try { @@ -218,6 +219,8 @@ public enum LootManager { if (prefixMod != null && prefixMod.action.length() > 0) { inItem.setPrefix(prefixMod.action); inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); + inItem.setIsID(false); + inItem.setIsID(false); } } } @@ -254,6 +257,8 @@ public enum LootManager { if (suffixMod != null && suffixMod.action.length() > 0) { inItem.setSuffix(suffixMod.action); inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); + inItem.setIsID(false); + inItem.setIsID(false); } } } @@ -320,8 +325,6 @@ public enum LootManager { MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); if (toAdd != null) { - if(toAdd.getPrefix() != null || toAdd.getSuffix() != null) - toAdd.setIsID(true); mob.getCharItemManager().addItemToInventory(toAdd); } } catch (Exception e) { @@ -347,8 +350,6 @@ public enum LootManager { continue; MobLoot ml = new MobLoot(mob, me.getItemBase(), false); if (ml != null) - if(ml.getPrefix() != null || ml.getSuffix() != null) - ml.setIsID(true); mob.getCharItemManager().addItemToInventory(ml); } } @@ -366,8 +367,6 @@ public enum LootManager { MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); if (lootItem != null) - if(lootItem.getPrefix() != null || lootItem.getSuffix() != null) - lootItem.setIsID(true); mob.getCharItemManager().addItemToInventory(lootItem); } From ef7d75ba9be6eedce510d3ca4d22a5f6e0e287a9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 3 Aug 2023 21:07:07 -0500 Subject: [PATCH 29/88] min roll increased to 70 --- src/engine/gameManager/LootManager.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index eead7c38..c5baf509 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -171,7 +171,6 @@ public enum LootManager { outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); Enum.ItemType outType = outItem.getItemBase().getType(); outItem.setIsID(true); - outItem.setIsID(true); if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { try { @@ -220,7 +219,6 @@ public enum LootManager { inItem.setPrefix(prefixMod.action); inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); inItem.setIsID(false); - inItem.setIsID(false); } } } @@ -258,7 +256,6 @@ public enum LootManager { inItem.setSuffix(suffixMod.action); inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); inItem.setIsID(false); - inItem.setIsID(false); } } } @@ -276,6 +273,8 @@ public enum LootManager { max = 319; int min = (int)(4.469 * mobLevel - 3.469); + if(min < 70) + min = 70; if(inHotzone){ min += mobLevel; } @@ -349,8 +348,11 @@ public enum LootManager { if (equipmentRoll > (dropChance * multiplier)) continue; MobLoot ml = new MobLoot(mob, me.getItemBase(), false); - if (ml != null) + if (ml != null) { + ml.setIsID(true); + ml.setIsID(true); mob.getCharItemManager().addItemToInventory(ml); + } } } } From 31e32cfcf47f5895a8285e7d4d0173bb421d2bbd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 10:10:19 -0400 Subject: [PATCH 30/88] Removed initial bootySet roll. --- src/engine/gameManager/LootManager.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 4661e3cc..ecf48e90 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -254,13 +254,6 @@ public enum LootManager { public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { - int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - - //early exit, failed to hit minimum chance roll OR booty was generated from mob's death - - if (chanceRoll > bse.dropChance) - return; - //determine and add gold to mob inventory int high = bse.highGold; From 5e01fe97ac1767866bd1d067b342d5977f0ebf7b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 10:14:45 -0400 Subject: [PATCH 31/88] Removed pre-Booty roll from Loot Drops. Renamed methods for clarity. --- src/engine/gameManager/LootManager.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index c5baf509..3d04d757 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -107,7 +107,7 @@ public enum LootManager { private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { if (fromDeath) - DropEquipment(mob, multiplier); + GenerateEquipmentDrop(mob, multiplier); else { for (BootySetEntry bse : entries) { switch (bse.bootyType) { @@ -118,13 +118,13 @@ public enum LootManager { //always run base table loot drop GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier, false); //generate normal loot drop + //run another iteration for the hotzone table if in hotzone if (inHotzone) - //run another iteration for the hotzone table if in hotzone if (generalItemTables.containsKey(bse.lootTable + 1)) GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier, true); //generate loot drop from hotzone table break; case "ITEM": - GenerateItemLootDrop(mob, bse, multiplier); + GenerateInventoryDrop(mob, bse, multiplier); break; } } @@ -314,12 +314,6 @@ public enum LootManager { public static void GenerateLootDrop(Mob mob, int tableID, float dropChance, float multiplier, Boolean inHotzone) { try { - int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - - //early exit, failed to hit minimum chance roll - - if (chanceRoll > dropChance * multiplier) - return; MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); @@ -332,7 +326,7 @@ public enum LootManager { } } - public static void DropEquipment(Mob mob, float multiplier) { + public static void GenerateEquipmentDrop(Mob mob, float multiplier) { //do equipment here @@ -357,7 +351,7 @@ public enum LootManager { } } - public static void GenerateItemLootDrop(Mob mob, BootySetEntry bse, float multiplier) { + public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse, float multiplier) { int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; From 7ac78df9131d0f587aad88ac66bddb23f0272512 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 12:21:22 -0400 Subject: [PATCH 32/88] Rework of drop rate usage. --- src/engine/gameManager/LootManager.java | 46 +++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 3d04d757..1abb0a34 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -106,27 +106,37 @@ public enum LootManager { private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { - if (fromDeath) + boolean hotzoneWasRan = false; + + if (fromDeath) { GenerateEquipmentDrop(mob, multiplier); - else { - for (BootySetEntry bse : entries) { - switch (bse.bootyType) { - case "GOLD": - GenerateGoldDrop(mob, bse, inHotzone); - break; - case "LOOT": - //always run base table loot drop + return; + } + + // Iterate all entries in this bootyset and process accordingly + + for (BootySetEntry bse : entries) { + switch (bse.bootyType) { + case "GOLD": + GenerateGoldDrop(mob, bse, inHotzone); + break; + case "LOOT": + + if (ThreadLocalRandom.current().nextInt(100) > NORMAL_DROP_RATE) GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier, false); //generate normal loot drop - //run another iteration for the hotzone table if in hotzone - if (inHotzone) - if (generalItemTables.containsKey(bse.lootTable + 1)) - GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier, true); //generate loot drop from hotzone table - break; - case "ITEM": - GenerateInventoryDrop(mob, bse, multiplier); - break; - } + // Generate hotzone loot if in hotzone + + if (inHotzone == true && hotzoneWasRan == false) + if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) > HOTZONE_DROP_RATE) { + GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier, true); //generate loot drop from hotzone table + hotzoneWasRan = true; + } + + break; + case "ITEM": + GenerateInventoryDrop(mob, bse, multiplier); + break; } } } From c5c323a316f59b5401bfe49c7513063ee91303aa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 12:23:55 -0400 Subject: [PATCH 33/88] Rework of drop rate usage. --- src/engine/gameManager/LootManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 1abb0a34..796b9a02 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -122,13 +122,13 @@ public enum LootManager { break; case "LOOT": - if (ThreadLocalRandom.current().nextInt(100) > NORMAL_DROP_RATE) + if (ThreadLocalRandom.current().nextInt(100) <= NORMAL_DROP_RATE) GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier, false); //generate normal loot drop // Generate hotzone loot if in hotzone if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) > HOTZONE_DROP_RATE) { + if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) <= HOTZONE_DROP_RATE) { GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier, true); //generate loot drop from hotzone table hotzoneWasRan = true; } From 2cbb112f09e85f7ae9ddfa7f8c22a6c8cc685f30 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 13:04:57 -0400 Subject: [PATCH 34/88] Drop rate not used for equipment drops. --- src/engine/gameManager/LootManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 796b9a02..99f780a4 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -109,7 +109,7 @@ public enum LootManager { boolean hotzoneWasRan = false; if (fromDeath) { - GenerateEquipmentDrop(mob, multiplier); + GenerateEquipmentDrop(mob); return; } @@ -336,7 +336,7 @@ public enum LootManager { } } - public static void GenerateEquipmentDrop(Mob mob, float multiplier) { + public static void GenerateEquipmentDrop(Mob mob) { //do equipment here @@ -349,8 +349,9 @@ public enum LootManager { float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1; float dropChance = me.getDropChance() * 100; - if (equipmentRoll > (dropChance * multiplier)) + if (equipmentRoll > dropChance) continue; + MobLoot ml = new MobLoot(mob, me.getItemBase(), false); if (ml != null) { ml.setIsID(true); From 8b1fb98b09af583179d5c38be795969957844614 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 13:09:09 -0400 Subject: [PATCH 35/88] Drop rate not used for equipment drops. --- src/engine/gameManager/LootManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 99f780a4..ce6fc899 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -346,13 +346,14 @@ public enum LootManager { if (me.getDropChance() == 0) continue; - float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1; + float equipmentRoll = ThreadLocalRandom.current().nextInt(100); float dropChance = me.getDropChance() * 100; if (equipmentRoll > dropChance) continue; MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + if (ml != null) { ml.setIsID(true); ml.setIsID(true); From 8fad2780c1798cc9868a02cb98255df3f044c4a1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 13:16:44 -0400 Subject: [PATCH 36/88] multiplier not used for item drops. --- src/engine/gameManager/LootManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index ce6fc899..aba03d37 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -135,7 +135,7 @@ public enum LootManager { break; case "ITEM": - GenerateInventoryDrop(mob, bse, multiplier); + GenerateInventoryDrop(mob, bse); break; } } @@ -363,13 +363,13 @@ public enum LootManager { } } - public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse, float multiplier) { + public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse) { - int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; + int chanceRoll = ThreadLocalRandom.current().nextInt(100); //early exit, failed to hit minimum chance roll - if (chanceRoll > bse.dropChance * multiplier) + if (chanceRoll > bse.dropChance) return; MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); From ae8eef640b81a77021e710fd992857634a68dcbf Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 13:25:13 -0400 Subject: [PATCH 37/88] Formatting cleanup. --- src/engine/gameManager/LootManager.java | 53 +++++++++++++++---------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index aba03d37..b30e14c8 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -89,7 +89,7 @@ public enum LootManager { //lastly, check mobs inventory for godly or disc runes to send a server announcement - if (!fromDeath) { + if (!fromDeath) for (Item it : mob.getInventory()) { ItemBase ib = it.getItemBase(); @@ -101,7 +101,7 @@ public enum LootManager { DispatchMessage.dispatchMsgToAll(chatMsg); } } - } + } private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { @@ -126,6 +126,7 @@ public enum LootManager { GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier, false); //generate normal loot drop // Generate hotzone loot if in hotzone + // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) <= HOTZONE_DROP_RATE) { @@ -151,17 +152,18 @@ public enum LootManager { int genRoll = new Random().nextInt(99) + 1; GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + if (selectedRow == null) return null; int itemTableId = selectedRow.itemTableID; - if(itemTables.containsKey(itemTableId) == false) + if (itemTables.containsKey(itemTableId) == false) return null; //gets the 1-320 roll for this mob - int roll2 = TableRoll(mob.level,inHotzone); + int roll2 = TableRoll(mob.level, inHotzone); ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); @@ -181,13 +183,16 @@ public enum LootManager { outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); Enum.ItemType outType = outItem.getItemBase().getType(); outItem.setIsID(true); + if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { + try { outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); } catch (Exception e) { Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); } + try { outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); } catch (Exception e) { @@ -206,23 +211,26 @@ public enum LootManager { if (prefixChanceRoll < prefixChance) { GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); - if(selectedRow == null) + + if (selectedRow == null) return inItem; ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); - if(prefixTable == null) + + if (prefixTable == null) return inItem; int prefixroll = ThreadLocalRandom.current().nextInt(99) + 1; if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { - ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); - if(prefixModTable == null) + + if (prefixModTable == null) return inItem; ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); - if(prefixMod == null) + + if (prefixMod == null) return inItem; if (prefixMod != null && prefixMod.action.length() > 0) { @@ -243,23 +251,27 @@ public enum LootManager { if (suffixChanceRoll < suffixChance) { GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); - if(selectedRow == null) + + if (selectedRow == null) return inItem; int suffixroll = ThreadLocalRandom.current().nextInt(99) + 1; ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); - if(suffixTable == null) + + if (suffixTable == null) return inItem; if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); - if(suffixModTable == null) + + if (suffixModTable == null) return inItem; ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); - if(suffixMod == null) + + if (suffixMod == null) return inItem; if (suffixMod != null && suffixMod.action.length() > 0) { @@ -282,12 +294,13 @@ public enum LootManager { if (max > 319) max = 319; - int min = (int)(4.469 * mobLevel - 3.469); - if(min < 70) + int min = (int) (4.469 * mobLevel - 3.469); + + if (min < 70) min = 70; - if(inHotzone){ + + if (inHotzone) min += mobLevel; - } int roll = ThreadLocalRandom.current().nextInt(max - min) + min; @@ -296,7 +309,7 @@ public enum LootManager { public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { - int chanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; + int chanceRoll = ThreadLocalRandom.current().nextInt(100); //early exit, failed to hit minimum chance roll @@ -327,9 +340,9 @@ public enum LootManager { MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); - if (toAdd != null) { + if (toAdd != null) mob.getCharItemManager().addItemToInventory(toAdd); - } + } catch (Exception e) { //TODO chase down loot generation error, affects roughly 2% of drops int i = 0; From 068d9cd719fc66c19dcac58c97716aef0bd3c67f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 4 Aug 2023 14:01:12 -0400 Subject: [PATCH 38/88] Signature update in loot generation. --- src/engine/gameManager/LootManager.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index b30e14c8..4b46b932 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -113,7 +113,7 @@ public enum LootManager { return; } - // Iterate all entries in this bootyset and process accordingly + // Iterate all entries in this bootySet and process accordingly for (BootySetEntry bse : entries) { switch (bse.bootyType) { @@ -122,15 +122,15 @@ public enum LootManager { break; case "LOOT": - if (ThreadLocalRandom.current().nextInt(100) <= NORMAL_DROP_RATE) - GenerateLootDrop(mob, bse.lootTable, bse.dropChance, multiplier, false); //generate normal loot drop + if (ThreadLocalRandom.current().nextInt(100) < NORMAL_DROP_RATE) + GenerateLootDrop(mob, bse.lootTable, false); //generate normal loot drop // Generate hotzone loot if in hotzone // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) <= HOTZONE_DROP_RATE) { - GenerateLootDrop(mob, bse.lootTable + 1, bse.dropChance, multiplier, true); //generate loot drop from hotzone table + if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) < HOTZONE_DROP_RATE) { + GenerateLootDrop(mob, bse.lootTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } @@ -334,7 +334,7 @@ public enum LootManager { } - public static void GenerateLootDrop(Mob mob, int tableID, float dropChance, float multiplier, Boolean inHotzone) { + public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) { try { @@ -353,7 +353,7 @@ public enum LootManager { //do equipment here - if (mob.getEquip() != null) { + if (mob.getEquip() != null) for (MobEquipment me : mob.getEquip().values()) { if (me.getDropChance() == 0) @@ -373,7 +373,6 @@ public enum LootManager { mob.getCharItemManager().addItemToInventory(ml); } } - } } public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse) { From 4a0a00ed957baffd5d7745d6b12f76e94929984a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 4 Aug 2023 19:06:48 -0500 Subject: [PATCH 39/88] removed custom "chance" for prefix and suffix --- src/engine/gameManager/LootManager.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 4b46b932..31d1ab06 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -205,10 +205,10 @@ public enum LootManager { private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - int prefixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - double prefixChance = 2.057 * mob.level - 28.67; + //int prefixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; + //double prefixChance = 2.057 * mob.level - 28.67; - if (prefixChanceRoll < prefixChance) { + //if (prefixChanceRoll < prefixChance) { GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); @@ -239,16 +239,16 @@ public enum LootManager { inItem.setIsID(false); } } - } + //} return inItem; } private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - int suffixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - double suffixChance = 2.057 * mob.level - 28.67; + //int suffixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; + //double suffixChance = 2.057 * mob.level - 28.67; - if (suffixChanceRoll < suffixChance) { + //if (suffixChanceRoll < suffixChance) { GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); @@ -280,7 +280,7 @@ public enum LootManager { inItem.setIsID(false); } } - } + //} return inItem; } @@ -339,7 +339,7 @@ public enum LootManager { try { MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); - + toAdd.setIsID(true); if (toAdd != null) mob.getCharItemManager().addItemToInventory(toAdd); From 91842add6df6778fac362410893871cf48f0fde3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 4 Aug 2023 19:14:40 -0500 Subject: [PATCH 40/88] item identification defaults work --- src/engine/gameManager/LootManager.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 31d1ab06..a3fca82d 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -182,8 +182,6 @@ public enum LootManager { outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); Enum.ItemType outType = outItem.getItemBase().getType(); - outItem.setIsID(true); - if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { @@ -200,6 +198,8 @@ public enum LootManager { } } } + if(outItem.getPrefix() != null && outItem.getPrefix().isEmpty() == false && outItem.getSuffix() != null && outItem.getSuffix().isEmpty() == false) + outItem.setIsID(false); return outItem; } @@ -236,7 +236,6 @@ public enum LootManager { if (prefixMod != null && prefixMod.action.length() > 0) { inItem.setPrefix(prefixMod.action); inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); - inItem.setIsID(false); } } //} @@ -277,7 +276,6 @@ public enum LootManager { if (suffixMod != null && suffixMod.action.length() > 0) { inItem.setSuffix(suffixMod.action); inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); - inItem.setIsID(false); } } //} From 17f099386aa1ca59ca5ada5607e9401dd899874f Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 4 Aug 2023 19:27:49 -0500 Subject: [PATCH 41/88] enchanted and non enchanted items show up correctly as "unidentified" --- src/engine/gameManager/LootManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index a3fca82d..081aa78e 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -198,7 +198,9 @@ public enum LootManager { } } } - if(outItem.getPrefix() != null && outItem.getPrefix().isEmpty() == false && outItem.getSuffix() != null && outItem.getSuffix().isEmpty() == false) + if(outItem.getPrefix() != null && outItem.getPrefix().isEmpty() == false) + outItem.setIsID(false); + if(outItem.getSuffix() != null && outItem.getSuffix().isEmpty() == false) outItem.setIsID(false); return outItem; } @@ -337,7 +339,6 @@ public enum LootManager { try { MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); - toAdd.setIsID(true); if (toAdd != null) mob.getCharItemManager().addItemToInventory(toAdd); @@ -366,7 +367,6 @@ public enum LootManager { MobLoot ml = new MobLoot(mob, me.getItemBase(), false); if (ml != null) { - ml.setIsID(true); ml.setIsID(true); mob.getCharItemManager().addItemToInventory(ml); } From 64aef11c56480b14c134b0bab51d9db7b808d5ce Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 4 Aug 2023 19:47:21 -0500 Subject: [PATCH 42/88] mob equipment takes damage upon death --- src/engine/gameManager/LootManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 081aa78e..b28eb23f 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -368,6 +368,7 @@ public enum LootManager { if (ml != null) { ml.setIsID(true); + ml.setDurabilityCurrent((short)(ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); mob.getCharItemManager().addItemToInventory(ml); } } From 516fa59068acd884ef1ba4fa0f0357805380d935 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 4 Aug 2023 20:03:31 -0500 Subject: [PATCH 43/88] NPCs will now buy items based on how much durability is on the item --- src/engine/net/client/ClientMessagePump.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index f274f185..34e738b2 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1243,6 +1243,12 @@ public class ClientMessagePump implements NetMsgHandler { cost = sell.getBaseValue(); + + //apply damaged value reduction + float durabilityCurrent = sell.getDurabilityCurrent(); + float durabilityMax = sell.getDurabilityMax(); + float damagedModifier = durabilityCurrent / durabilityMax; + cost *= damagedModifier; float bargain = player.getBargain(); float profit = npc.getBuyPercent(player) + bargain; From 0d9ab6c6fda3533217cb2e6943e47bf283edf5ff Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 08:47:48 -0400 Subject: [PATCH 44/88] Testing pure unmodified booty entries. --- src/engine/gameManager/LootManager.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index b28eb23f..681e534d 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -70,22 +70,13 @@ public enum LootManager { boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); - //get multiplier form config manager - - float multiplier = NORMAL_DROP_RATE; - - //if mob is inside hotzone, use the hotzone multiplier from the config instead - - if (inHotzone) - multiplier = HOTZONE_DROP_RATE; - //iterate the booty sets if (mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet) == true) - RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, multiplier, inHotzone, fromDeath); + RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone, fromDeath); if (mob.bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.bootySet) == true) - RunBootySet(NPCManager._bootySetMap.get(mob.bootySet), mob, multiplier, inHotzone, fromDeath); + RunBootySet(NPCManager._bootySetMap.get(mob.bootySet), mob, inHotzone, fromDeath); //lastly, check mobs inventory for godly or disc runes to send a server announcement @@ -104,7 +95,7 @@ public enum LootManager { } - private static void RunBootySet(ArrayList entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { + private static void RunBootySet(ArrayList entries, Mob mob, boolean inHotzone, boolean fromDeath) { boolean hotzoneWasRan = false; @@ -122,14 +113,14 @@ public enum LootManager { break; case "LOOT": - if (ThreadLocalRandom.current().nextInt(100) < NORMAL_DROP_RATE) + if (ThreadLocalRandom.current().nextInt(100) < bse.dropChance) GenerateLootDrop(mob, bse.lootTable, false); //generate normal loot drop // Generate hotzone loot if in hotzone // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) < HOTZONE_DROP_RATE) { + if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) < bse.dropChance) { GenerateLootDrop(mob, bse.lootTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } From 5970d6d71656dcddb365cdce19222f5f0aef598f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 09:39:16 -0400 Subject: [PATCH 45/88] Cleanup of random usage. --- src/engine/gameManager/LootManager.java | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 681e534d..b1144fa7 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -113,14 +113,14 @@ public enum LootManager { break; case "LOOT": - if (ThreadLocalRandom.current().nextInt(100) < bse.dropChance) + if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < bse.dropChance) GenerateLootDrop(mob, bse.lootTable, false); //generate normal loot drop // Generate hotzone loot if in hotzone // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(100) < bse.dropChance) { + if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < bse.dropChance) { GenerateLootDrop(mob, bse.lootTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } @@ -198,11 +198,6 @@ public enum LootManager { private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - //int prefixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - //double prefixChance = 2.057 * mob.level - 28.67; - - //if (prefixChanceRoll < prefixChance) { - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); if (selectedRow == null) @@ -213,7 +208,7 @@ public enum LootManager { if (prefixTable == null) return inItem; - int prefixroll = ThreadLocalRandom.current().nextInt(99) + 1; + int prefixroll = ThreadLocalRandom.current().nextInt(1, 100 + 1); if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); @@ -237,17 +232,12 @@ public enum LootManager { private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - //int suffixChanceRoll = ThreadLocalRandom.current().nextInt(99) + 1; - //double suffixChance = 2.057 * mob.level - 28.67; - - //if (suffixChanceRoll < suffixChance) { - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); if (selectedRow == null) return inItem; - int suffixroll = ThreadLocalRandom.current().nextInt(99) + 1; + int suffixroll = ThreadLocalRandom.current().nextInt(1, 100 + 1); ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); @@ -300,7 +290,7 @@ public enum LootManager { public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { - int chanceRoll = ThreadLocalRandom.current().nextInt(100); + int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); //early exit, failed to hit minimum chance roll @@ -349,7 +339,7 @@ public enum LootManager { if (me.getDropChance() == 0) continue; - float equipmentRoll = ThreadLocalRandom.current().nextInt(100); + float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); float dropChance = me.getDropChance() * 100; if (equipmentRoll > dropChance) @@ -367,7 +357,7 @@ public enum LootManager { public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse) { - int chanceRoll = ThreadLocalRandom.current().nextInt(100); + int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); //early exit, failed to hit minimum chance roll From 1c5d1cef7084f96152b5620ea108d48066f64c1f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 10:11:31 -0400 Subject: [PATCH 46/88] Table refactor to conform with sb. --- src/engine/db/handlers/dbLootTableHandler.java | 6 +++--- src/engine/gameManager/LootManager.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index ec9ba9df..875b3ea5 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -35,7 +35,7 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_lootgroups`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_gentable`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -134,12 +134,12 @@ public class dbLootTableHandler extends dbHandlerBase { } } - public void LOAD_ALL_LOOTGROUPS() { + public void LOAD_ALL_GENTABLES() { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_lootgroups")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_gentable")) { ResultSet rs = preparedStatement.executeQuery(); diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index b1144fa7..1b1c7d32 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -48,7 +48,7 @@ public enum LootManager { // Load loot tables from database. - DbManager.LootQueries.LOAD_ALL_LOOTGROUPS(); + DbManager.LootQueries.LOAD_ALL_GENTABLES(); DbManager.LootQueries.LOAD_ALL_LOOTTABLES(); DbManager.LootQueries.LOAD_ALL_MODGROUPS(); DbManager.LootQueries.LOAD_ALL_MODTABLES(); From 0568dc077195adf5ddc415a62f5e84c2f180eaa0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 10:17:37 -0400 Subject: [PATCH 47/88] Table refactor to conform with sb. --- src/engine/db/handlers/dbLootTableHandler.java | 10 +++++----- src/engine/gameManager/LootManager.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index 875b3ea5..32a2114a 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -35,7 +35,7 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_gentable`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_gentables`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -57,7 +57,7 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `lootTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_loottables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `lootTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_itemtables`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -139,7 +139,7 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_gentable")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_gentables")) { ResultSet rs = preparedStatement.executeQuery(); @@ -155,12 +155,12 @@ public class dbLootTableHandler extends dbHandlerBase { Logger.info("read: " + recordsRead); } - public void LOAD_ALL_LOOTTABLES() { + public void LOAD_ALL_ITEMTABLES() { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_loottables")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itemtables")) { ResultSet rs = preparedStatement.executeQuery(); diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 1b1c7d32..c7b41c0a 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -49,7 +49,7 @@ public enum LootManager { // Load loot tables from database. DbManager.LootQueries.LOAD_ALL_GENTABLES(); - DbManager.LootQueries.LOAD_ALL_LOOTTABLES(); + DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); DbManager.LootQueries.LOAD_ALL_MODGROUPS(); DbManager.LootQueries.LOAD_ALL_MODTABLES(); From a7abe6c4c50ec6e16382062e1f560242238cb758 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 10:28:32 -0400 Subject: [PATCH 48/88] Table refactor to conform with sb. --- src/engine/db/handlers/dbLootTableHandler.java | 12 ++++++------ src/engine/gameManager/LootManager.java | 2 +- src/engine/loot/GenTableRow.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index 32a2114a..6ea5d74f 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -101,7 +101,7 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modGroup`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modgroups`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modGroup`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modtypetables`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -145,7 +145,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { GenTableRow row = new GenTableRow(rs); - LootManager.AddGenTableRow(rs.getInt("groupID"), row); + LootManager.AddGenTableRow(rs.getInt("gentable"), row); } } catch (SQLException e) { @@ -167,7 +167,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; ItemTableRow row = new ItemTableRow(rs); - LootManager.AddItemTableRow(rs.getInt("lootTable"), row); + LootManager.AddItemTableRow(rs.getInt("itemTable"), row); } } catch (SQLException e) { @@ -177,18 +177,18 @@ public class dbLootTableHandler extends dbHandlerBase { Logger.info("read: " + recordsRead); } - public void LOAD_ALL_MODGROUPS() { + public void LOAD_ALL_MODTYPES() { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_modgroups")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_modtypetables")) { ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { recordsRead++; ModTypeTableRow mttr = new ModTypeTableRow(rs); - LootManager.AddModTypeTableRow(rs.getInt("modGroup"), mttr); + LootManager.AddModTypeTableRow(rs.getInt("modType"), mttr); } } catch (SQLException e) { diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index c7b41c0a..1e846dcd 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -50,7 +50,7 @@ public enum LootManager { DbManager.LootQueries.LOAD_ALL_GENTABLES(); DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); - DbManager.LootQueries.LOAD_ALL_MODGROUPS(); + DbManager.LootQueries.LOAD_ALL_MODTYPES(); DbManager.LootQueries.LOAD_ALL_MODTABLES(); // Cache drop rate values from Config manager. diff --git a/src/engine/loot/GenTableRow.java b/src/engine/loot/GenTableRow.java index e72a4cf3..4ce81a32 100644 --- a/src/engine/loot/GenTableRow.java +++ b/src/engine/loot/GenTableRow.java @@ -13,7 +13,7 @@ public class GenTableRow { public GenTableRow(ResultSet rs) throws SQLException { this.minRoll = rs.getInt("minRoll"); this.maxRoll = rs.getInt("maxRoll"); - this.itemTableID = rs.getInt("lootTableID"); + this.itemTableID = rs.getInt("itemTableID"); this.pModTable = rs.getInt("pModTableID"); this.sModTable = rs.getInt("sModTableID"); } From 42069fe17002d59c070056cd5dda4df990c8b828 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 10:38:21 -0400 Subject: [PATCH 49/88] Table refactor to conform with sb. --- src/engine/db/handlers/dbLootTableHandler.java | 12 ++++++------ src/engine/objects/LootTable.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index 6ea5d74f..af53a28a 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -30,7 +30,7 @@ public class dbLootTableHandler extends dbHandlerBase { } - public void populateLootGroups() { + public void populateGenTables() { int recordsRead = 0; @@ -41,7 +41,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootTable lootTable = LootTable.getLootGroup(rs.getInt("groupID")); + LootTable lootTable = LootTable.getLootGroup(rs.getInt("genTable")); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("lootTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), ""); } @@ -52,7 +52,7 @@ public class dbLootTableHandler extends dbHandlerBase { Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootGroups().size()); } - public void populateLootTables() { + public void populateItemTables() { int recordsRead = 0; @@ -63,7 +63,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootTable lootTable = LootTable.getLootTable(rs.getInt("lootTable")); + LootTable lootTable = LootTable.getLootTable(rs.getInt("itemTable")); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemBaseUUID"), rs.getInt("minSpawn"), rs.getInt("maxSpawn"), ""); } @@ -96,7 +96,7 @@ public class dbLootTableHandler extends dbHandlerBase { Logger.info("read: " + recordsRead + " cached: " + LootTable.getModTables().size()); } - public void populateModGroups() { + public void populateModTypeTables() { int recordsRead = 0; @@ -107,7 +107,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootTable lootTable = LootTable.getModGroup(rs.getInt("modGroup")); + LootTable lootTable = LootTable.getModGroup(rs.getInt("modType")); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("subTableID"), 0, 0, ""); } diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index 0ad13973..2ab7a4e4 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -127,10 +127,10 @@ public class LootTable { //call this on server startup to populate the tables public static void populateLootTables() { - DbManager.LootQueries.populateLootGroups(); - DbManager.LootQueries.populateLootTables(); + DbManager.LootQueries.populateGenTables(); + DbManager.LootQueries.populateItemTables(); DbManager.LootQueries.populateModTables(); - DbManager.LootQueries.populateModGroups(); + DbManager.LootQueries.populateModTypeTables(); //preset chances for rune drops populateStatRuneChances(); From a2c6b919d44fca0a28464fc1318a2f15ef5e7676 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 10:48:21 -0400 Subject: [PATCH 50/88] Table refactor to conform with sb. --- src/engine/db/handlers/dbLootTableHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index af53a28a..e05df915 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -35,14 +35,14 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_gentables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `genTable`, `minRoll`, `maxRoll`, `itemTableID`, `pModTableID`, `sModTableID` FROM `static_gentables`")) { ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { recordsRead++; LootTable lootTable = LootTable.getLootGroup(rs.getInt("genTable")); - lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("lootTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), ""); + lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), ""); } } catch (SQLException e) { @@ -57,7 +57,7 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `lootTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_itemtables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `itemTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_itemtables`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -101,7 +101,7 @@ public class dbLootTableHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modGroup`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modtypetables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modType`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modtypetables`")) { ResultSet rs = preparedStatement.executeQuery(); From 15a167905cb5dad4bb1e67fc20ec25d36bb090b2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 17:46:34 -0400 Subject: [PATCH 51/88] Config drop rates modify chance. --- src/engine/gameManager/LootManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 1e846dcd..119960bc 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -113,14 +113,14 @@ public enum LootManager { break; case "LOOT": - if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < bse.dropChance) + if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * NORMAL_DROP_RATE)) GenerateLootDrop(mob, bse.lootTable, false); //generate normal loot drop // Generate hotzone loot if in hotzone // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < bse.dropChance) { + if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * HOTZONE_DROP_RATE)) { GenerateLootDrop(mob, bse.lootTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } From 258bda22dab74ca4fd02f812f1629061ba337612 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 18:39:17 -0400 Subject: [PATCH 52/88] Bootysim displays chance. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 166 ++++++++++++++++++ src/engine/devcmd/cmds/simulateBootyCmd.java | 169 ------------------- src/engine/gameManager/DevCmdManager.java | 2 +- 3 files changed, 167 insertions(+), 170 deletions(-) create mode 100644 src/engine/devcmd/cmds/SimulateBootyCmd.java delete mode 100644 src/engine/devcmd/cmds/simulateBootyCmd.java diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java new file mode 100644 index 00000000..f988a519 --- /dev/null +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -0,0 +1,166 @@ +package engine.devcmd.cmds; + +import engine.devcmd.AbstractDevCmd; +import engine.gameManager.LootManager; +import engine.gameManager.NPCManager; +import engine.gameManager.ZoneManager; +import engine.objects.*; + +import java.util.ArrayList; +import java.util.concurrent.ThreadLocalRandom; + +public class SimulateBootyCmd extends AbstractDevCmd { + public SimulateBootyCmd() { + super("bootysim"); + } + + @Override + protected void _doCmd(PlayerCharacter pc, String[] words, + AbstractGameObject target) { + + // Arg Count Check + + if (words.length != 1) { + this.sendUsage(pc); + return; + } + + if (pc == null) + return; + + String newline = "\r\n "; + + int targetID = Integer.parseInt(words[0]); + Mob mobile = Mob.getMob(targetID); + + if (mobile == null) + throwbackError(pc, "Mobile with ID " + targetID + + " not found"); + else + target = mobile; + + + if (target == null) { + throwbackError(pc, "Target is unknown or of an invalid type." + + newline + "Type ID: 0x" + + pc.getLastTargetType().toString() + + " Table ID: " + pc.getLastTargetID()); + return; + } + + String output; + + output = "Booty Simulation:" + newline; + + Mob mob = (Mob) target; + output += "Name: " + mob.getName() + newline; + output += "Special Loot:" + newline; + + if (mob.bootySet != 0) { + for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.bootySet)) { + ItemBase item = ItemBase.getItemBase(entry.itemBase); + if (item != null) { + output += "[" + entry.bootyType + "] " + item.getName() + " [Chance] " + entry.dropChance + newline; + } + } + } + + ArrayList GlassItems = new ArrayList(); + ArrayList Resources = new ArrayList(); + ArrayList Runes = new ArrayList(); + ArrayList Contracts = new ArrayList(); + ArrayList Offerings = new ArrayList(); + ArrayList OtherDrops = new ArrayList(); + ArrayList EquipmentDrops = new ArrayList(); + int failures = 0; + int goldAmount = 0; + + for (int i = 0; i < 100; ++i) { + + try { + mob.loadInventory(); + for (Item lootItem : mob.getCharItemManager().getInventory()) { + switch (lootItem.getItemBase().getType()) { + case CONTRACT: //CONTRACT + Contracts.add(lootItem); + break; + case OFFERING: //OFFERING + Offerings.add(lootItem); + break; + case RESOURCE: //RESOURCE + Resources.add(lootItem); + break; + case RUNE: //RUNE + Runes.add(lootItem); + break; + case WEAPON: //WEAPON + if (lootItem.getItemBase().isGlass()) + GlassItems.add(lootItem); + else + OtherDrops.add(lootItem); + break; + case GOLD: + goldAmount += lootItem.getNumOfItems(); + break; + default: + OtherDrops.add(lootItem); + break; + } + } + } catch (Exception ex) { + failures++; + } + if (mob.getEquip() != null) { + for (MobEquipment me : mob.getEquip().values()) { + + if (me.getDropChance() == 0) + continue; + + float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1; + float dropChance = me.getDropChance() * 100; + + if (equipmentRoll > (dropChance)) + continue; + + MobLoot ml = new MobLoot(mob, me.getItemBase(), false); + + if (ml != null) + EquipmentDrops.add(ml); + } + } + } + output += "MobBase BootySet: " + mob.getMobBase().bootySet + newline; + output += "Mob BootySet: " + mob.bootySet + newline; + output += "Tables Rolled On: " + newline; + + for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance * LootManager.NORMAL_DROP_RATE + newline; + + if (ZoneManager.inHotZone(mob.getLoc())) + for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) + if (LootManager.generalItemTables.containsKey(entry.lootTable + 1) == true) + output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + ": " + entry.dropChance * LootManager.HOTZONE_DROP_RATE + newline; + + output += "GLASS DROPS: " + GlassItems.size() + newline; + output += "RUNE DROPS: " + Runes.size() + newline; + output += "CONTRACTS DROPS: " + Contracts.size() + newline; + output += "RESOURCE DROPS: " + Resources.size() + newline; + output += "OFFERINGS DROPPED: " + Offerings.size() + newline; + output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline; + output += "TOTAL GOLD DROPPED: " + goldAmount + newline; + output += "EQUIPMENT DROPPED: " + EquipmentDrops.size() + newline; + output += "FAILED ROLLS: " + failures + newline; + + throwbackInfo(pc, output); + } + + @Override + protected String _getHelpString() { + return "Simulates loot drops"; + } + + @Override + protected String _getUsageString() { + return "'/bootysim targetID'"; + } +} diff --git a/src/engine/devcmd/cmds/simulateBootyCmd.java b/src/engine/devcmd/cmds/simulateBootyCmd.java deleted file mode 100644 index a27d248b..00000000 --- a/src/engine/devcmd/cmds/simulateBootyCmd.java +++ /dev/null @@ -1,169 +0,0 @@ -package engine.devcmd.cmds; - -import engine.Enum; -import engine.devcmd.AbstractDevCmd; -import engine.gameManager.BuildingManager; -import engine.gameManager.LootManager; -import engine.gameManager.NPCManager; -import engine.gameManager.ZoneManager; -import engine.objects.*; - -import java.util.ArrayList; -import java.util.concurrent.ThreadLocalRandom; - -public class simulateBootyCmd extends AbstractDevCmd { - public simulateBootyCmd() { - super("simulatebooty"); - } - - @Override - protected void _doCmd(PlayerCharacter pc, String[] words, - AbstractGameObject target) { - // Arg Count Check - if (words.length != 1) { - this.sendUsage(pc); - return; - } - if (pc == null) { - return; - } - - String newline = "\r\n "; - - try { - int targetID = Integer.parseInt(words[0]); - Building b = BuildingManager.getBuilding(targetID); - if (b == null) - throwbackError(pc, "Building with ID " + targetID - + " not found"); - else - target = b; - } catch (Exception e) { - } - - if (target == null) { - throwbackError(pc, "Target is unknown or of an invalid type." - + newline + "Type ID: 0x" - + pc.getLastTargetType().toString() - + " Table ID: " + pc.getLastTargetID()); - return; - } - - - Enum.GameObjectType objType = target.getObjectType(); - String output; - - output = "Booty Simulation:" + newline; - - switch (objType) { - case Mob: - Mob mob = (Mob) target; - output += "Name: " + mob.getName() + newline; - output += "Special Loot:" + newline; - if (mob.bootySet != 0) { - for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.bootySet)) { - ItemBase item = ItemBase.getItemBase(entry.itemBase); - if (item != null) { - output += "[" + entry.bootyType + "] " + item.getName() + " [Chance] " + entry.dropChance + newline; - } - } - } - ArrayList GlassItems = new ArrayList(); - ArrayList Resources = new ArrayList(); - ArrayList Runes = new ArrayList(); - ArrayList Contracts = new ArrayList(); - ArrayList Offerings = new ArrayList(); - ArrayList OtherDrops = new ArrayList(); - ArrayList EquipmentDrops = new ArrayList(); - int failures = 0; - int goldAmount = 0; - for (int i = 0; i < 100; ++i) { - - try { - mob.loadInventory(); - for (Item lootItem : mob.getCharItemManager().getInventory()) { - switch (lootItem.getItemBase().getType()) { - case CONTRACT: //CONTRACT - Contracts.add(lootItem); - break; - case OFFERING: //OFFERING - Offerings.add(lootItem); - break; - case RESOURCE: //RESOURCE - Resources.add(lootItem); - break; - case RUNE: //RUNE - Runes.add(lootItem); - break; - case WEAPON: //WEAPON - if (lootItem.getItemBase().isGlass()) - GlassItems.add(lootItem); - else - OtherDrops.add(lootItem); - break; - case GOLD: - goldAmount += lootItem.getNumOfItems(); - break; - default: - OtherDrops.add(lootItem); - break; - } - } - } catch (Exception ex) { - failures++; - } - if (mob.getEquip() != null) { - for (MobEquipment me : mob.getEquip().values()) { - - if (me.getDropChance() == 0) - continue; - - float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1; - float dropChance = me.getDropChance() * 100; - - if (equipmentRoll > (dropChance)) - continue; - MobLoot ml = new MobLoot(mob, me.getItemBase(), false); - if (ml != null) - EquipmentDrops.add(ml); - } - } - } - output += "MobBase BootySet: " + mob.getMobBase().bootySet + newline; - output += "Mob BootySet: " + mob.bootySet + newline; - output += "Tables Rolled On: " + newline; - for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { - output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + newline; - } - if(ZoneManager.inHotZone(mob.getLoc())){ - for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { - if(LootManager.generalItemTables.containsKey(entry.lootTable + 1) == true) - output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + newline; - } - } - output += "GLASS DROPS: " + GlassItems.size() + newline; - output += "RUNE DROPS: " + Runes.size() + newline; - output += "CONTRACTS DROPS: " + Contracts.size() + newline; - output += "RESOURCE DROPS: " + Resources.size() + newline; - output += "OFFERINGS DROPPED: " + Offerings.size() + newline; - output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline; - output += "TOTAL GOLD DROPPED: " + goldAmount + newline; - output += "EQUIPMENT DROPPED: " + EquipmentDrops.size() + newline; - output += "FAILED ROLLS: " + failures + newline; - break; - default: - break; - } - throwbackInfo(pc, output); - } - - @Override - protected String _getHelpString() { - return "Gets information on an Object."; - } - - @Override - protected String _getUsageString() { - return "' /info targetID'"; - } -} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index d9a37b29..d7d5cb49 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -57,7 +57,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new PrintLocationCmd()); DevCmdManager.registerDevCmd(new InfoCmd()); DevCmdManager.registerDevCmd(new aiInfoCmd()); - DevCmdManager.registerDevCmd(new simulateBootyCmd()); + DevCmdManager.registerDevCmd(new SimulateBootyCmd()); DevCmdManager.registerDevCmd(new GetHeightCmd()); // Tester From 820eeaee72d78a67fad01dd5a19beaa2082bd82e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 18:42:43 -0400 Subject: [PATCH 53/88] Bootysim displays chance. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index f988a519..d9eb2341 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -15,17 +15,17 @@ public class SimulateBootyCmd extends AbstractDevCmd { } @Override - protected void _doCmd(PlayerCharacter pc, String[] words, + protected void _doCmd(PlayerCharacter playerCharacter, String[] words, AbstractGameObject target) { // Arg Count Check if (words.length != 1) { - this.sendUsage(pc); + this.sendUsage(playerCharacter); return; } - if (pc == null) + if (playerCharacter == null) return; String newline = "\r\n "; @@ -34,17 +34,14 @@ public class SimulateBootyCmd extends AbstractDevCmd { Mob mobile = Mob.getMob(targetID); if (mobile == null) - throwbackError(pc, "Mobile with ID " + targetID + throwbackError(playerCharacter, "Mobile with ID " + targetID + " not found"); else target = mobile; if (target == null) { - throwbackError(pc, "Target is unknown or of an invalid type." - + newline + "Type ID: 0x" - + pc.getLastTargetType().toString() - + " Table ID: " + pc.getLastTargetID()); + throwbackError(playerCharacter, "Select or supply valid mobile uuid"); return; } @@ -72,6 +69,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { ArrayList Offerings = new ArrayList(); ArrayList OtherDrops = new ArrayList(); ArrayList EquipmentDrops = new ArrayList(); + int failures = 0; int goldAmount = 0; @@ -151,7 +149,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { output += "EQUIPMENT DROPPED: " + EquipmentDrops.size() + newline; output += "FAILED ROLLS: " + failures + newline; - throwbackInfo(pc, output); + throwbackInfo(playerCharacter, output); } @Override From 98b956730295e1197b1db1fba2661a613b300e3a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 18:49:48 -0400 Subject: [PATCH 54/88] Hotzone table only ran once. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index d9eb2341..479834e5 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -131,13 +131,17 @@ public class SimulateBootyCmd extends AbstractDevCmd { output += "Mob BootySet: " + mob.bootySet + newline; output += "Tables Rolled On: " + newline; - for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) + boolean hotZoneRan = false; + + for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance * LootManager.NORMAL_DROP_RATE + newline; - if (ZoneManager.inHotZone(mob.getLoc())) - for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) - if (LootManager.generalItemTables.containsKey(entry.lootTable + 1) == true) - output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + ": " + entry.dropChance * LootManager.HOTZONE_DROP_RATE + newline; + if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.lootTable + 1)) { + output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + ": " + entry.dropChance * LootManager.HOTZONE_DROP_RATE + newline; + hotZoneRan = true; + } + } output += "GLASS DROPS: " + GlassItems.size() + newline; output += "RUNE DROPS: " + Runes.size() + newline; From 51dfc3a56b09674549e397824333820bac2cbdbd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 19:23:58 -0400 Subject: [PATCH 55/88] Hotzone affects base rate. --- src/engine/gameManager/LootManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 119960bc..bc0d9af3 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -98,6 +98,7 @@ public enum LootManager { private static void RunBootySet(ArrayList entries, Mob mob, boolean inHotzone, boolean fromDeath) { boolean hotzoneWasRan = false; + float dropRate = LootManager.NORMAL_DROP_RATE; if (fromDeath) { GenerateEquipmentDrop(mob); @@ -113,14 +114,19 @@ public enum LootManager { break; case "LOOT": - if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * NORMAL_DROP_RATE)) + if (inHotzone == true) + dropRate = LootManager.HOTZONE_DROP_RATE; + else + dropRate = LootManager.NORMAL_DROP_RATE; + + if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.lootTable, false); //generate normal loot drop // Generate hotzone loot if in hotzone // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * HOTZONE_DROP_RATE)) { + if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { GenerateLootDrop(mob, bse.lootTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } From cc9b5a93ee1b6ab76434747d425243449f4e1807 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 19:28:53 -0400 Subject: [PATCH 56/88] Header added to new files. --- src/engine/gameManager/LootManager.java | 80 +++++++++++++------------ src/engine/loot/GenTable.java | 8 +++ src/engine/loot/GenTableRow.java | 8 +++ src/engine/loot/ItemTable.java | 8 +++ src/engine/loot/ItemTableRow.java | 8 +++ src/engine/loot/ModTable.java | 8 +++ src/engine/loot/ModTableRow.java | 8 +++ src/engine/loot/ModTypeTable.java | 8 +++ src/engine/loot/ModTypeTableRow.java | 8 +++ 9 files changed, 106 insertions(+), 38 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index bc0d9af3..d5a3c3a7 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -179,6 +179,7 @@ public enum LootManager { outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); Enum.ItemType outType = outItem.getItemBase().getType(); + if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outItem.getItemBase().isGlass() == false) { @@ -195,79 +196,81 @@ public enum LootManager { } } } - if(outItem.getPrefix() != null && outItem.getPrefix().isEmpty() == false) + + if (outItem.getPrefix() != null && outItem.getPrefix().isEmpty() == false) outItem.setIsID(false); - if(outItem.getSuffix() != null && outItem.getSuffix().isEmpty() == false) + + if (outItem.getSuffix() != null && outItem.getSuffix().isEmpty() == false) outItem.setIsID(false); + return outItem; } private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); - if (selectedRow == null) - return inItem; + if (selectedRow == null) + return inItem; - ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); + ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); - if (prefixTable == null) - return inItem; + if (prefixTable == null) + return inItem; int prefixroll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { - ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); + if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { + ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); - if (prefixModTable == null) - return inItem; + if (prefixModTable == null) + return inItem; - ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); + ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); - if (prefixMod == null) - return inItem; + if (prefixMod == null) + return inItem; - if (prefixMod != null && prefixMod.action.length() > 0) { - inItem.setPrefix(prefixMod.action); - inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); - } + if (prefixMod != null && prefixMod.action.length() > 0) { + inItem.setPrefix(prefixMod.action); + inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); } + } //} return inItem; } private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); - if (selectedRow == null) - return inItem; + if (selectedRow == null) + return inItem; int suffixroll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); + ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); - if (suffixTable == null) - return inItem; + if (suffixTable == null) + return inItem; - if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { + if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { - ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); + ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); - if (suffixModTable == null) - return inItem; + if (suffixModTable == null) + return inItem; - ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); + ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); - if (suffixMod == null) - return inItem; + if (suffixMod == null) + return inItem; - if (suffixMod != null && suffixMod.action.length() > 0) { - inItem.setSuffix(suffixMod.action); - inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); - } + if (suffixMod != null && suffixMod.action.length() > 0) { + inItem.setSuffix(suffixMod.action); + inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); } - //} + } return inItem; } @@ -326,6 +329,7 @@ public enum LootManager { try { MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); + if (toAdd != null) mob.getCharItemManager().addItemToInventory(toAdd); @@ -355,7 +359,7 @@ public enum LootManager { if (ml != null) { ml.setIsID(true); - ml.setDurabilityCurrent((short)(ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); + ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); mob.getCharItemManager().addItemToInventory(ml); } } diff --git a/src/engine/loot/GenTable.java b/src/engine/loot/GenTable.java index 5b5dd997..af2a97e4 100644 --- a/src/engine/loot/GenTable.java +++ b/src/engine/loot/GenTable.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.util.ArrayList; diff --git a/src/engine/loot/GenTableRow.java b/src/engine/loot/GenTableRow.java index 4ce81a32..85443caa 100644 --- a/src/engine/loot/GenTableRow.java +++ b/src/engine/loot/GenTableRow.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.sql.ResultSet; diff --git a/src/engine/loot/ItemTable.java b/src/engine/loot/ItemTable.java index e2afc1b4..b3a248f2 100644 --- a/src/engine/loot/ItemTable.java +++ b/src/engine/loot/ItemTable.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.util.ArrayList; diff --git a/src/engine/loot/ItemTableRow.java b/src/engine/loot/ItemTableRow.java index 00a20b8a..9655e287 100644 --- a/src/engine/loot/ItemTableRow.java +++ b/src/engine/loot/ItemTableRow.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.sql.ResultSet; diff --git a/src/engine/loot/ModTable.java b/src/engine/loot/ModTable.java index 06908938..2dee3c86 100644 --- a/src/engine/loot/ModTable.java +++ b/src/engine/loot/ModTable.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.util.ArrayList; diff --git a/src/engine/loot/ModTableRow.java b/src/engine/loot/ModTableRow.java index 94665cf6..0c3927a4 100644 --- a/src/engine/loot/ModTableRow.java +++ b/src/engine/loot/ModTableRow.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.sql.ResultSet; diff --git a/src/engine/loot/ModTypeTable.java b/src/engine/loot/ModTypeTable.java index b444a73b..0e40e395 100644 --- a/src/engine/loot/ModTypeTable.java +++ b/src/engine/loot/ModTypeTable.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.util.ArrayList; diff --git a/src/engine/loot/ModTypeTableRow.java b/src/engine/loot/ModTypeTableRow.java index 13b8cef9..7c395ed0 100644 --- a/src/engine/loot/ModTypeTableRow.java +++ b/src/engine/loot/ModTypeTableRow.java @@ -1,3 +1,11 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + package engine.loot; import java.sql.ResultSet; From 81fe6c4e2afe7d522a5be7629650c449fd615652 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 19:42:26 -0400 Subject: [PATCH 57/88] Removed integer input. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 22 -------------------- 1 file changed, 22 deletions(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index 479834e5..37c3e398 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -18,33 +18,11 @@ public class SimulateBootyCmd extends AbstractDevCmd { protected void _doCmd(PlayerCharacter playerCharacter, String[] words, AbstractGameObject target) { - // Arg Count Check - - if (words.length != 1) { - this.sendUsage(playerCharacter); - return; - } - if (playerCharacter == null) return; String newline = "\r\n "; - int targetID = Integer.parseInt(words[0]); - Mob mobile = Mob.getMob(targetID); - - if (mobile == null) - throwbackError(playerCharacter, "Mobile with ID " + targetID - + " not found"); - else - target = mobile; - - - if (target == null) { - throwbackError(playerCharacter, "Select or supply valid mobile uuid"); - return; - } - String output; output = "Booty Simulation:" + newline; From e1f96a009beb11741f8ab043859ccba4ef2e7f5e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 19:46:29 -0400 Subject: [PATCH 58/88] Display effective drop rate. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index 37c3e398..bd17dea2 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -110,13 +110,19 @@ public class SimulateBootyCmd extends AbstractDevCmd { output += "Tables Rolled On: " + newline; boolean hotZoneRan = false; + float dropRate = 1.0f; + + if (ZoneManager.inHotZone(mob.getLoc())) + dropRate = LootManager.HOTZONE_DROP_RATE; + else + dropRate = LootManager.NORMAL_DROP_RATE; for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { - output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance * LootManager.NORMAL_DROP_RATE + newline; + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance * dropRate + newline; if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.lootTable + 1)) { - output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + ": " + entry.dropChance * LootManager.HOTZONE_DROP_RATE + newline; + output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + ": " + entry.dropChance * dropRate + newline; hotZoneRan = true; } } From 0337ac7758090c4dd27b96bb5b46ce2a207cc635 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 5 Aug 2023 20:11:07 -0400 Subject: [PATCH 59/88] Gold drop rate display fix. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index bd17dea2..2638e60a 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -119,7 +119,10 @@ public class SimulateBootyCmd extends AbstractDevCmd { for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { - output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance * dropRate + newline; + if (entry.bootyType.equals("GOLD")) + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance + newline; + else + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance * dropRate + newline; if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.lootTable + 1)) { output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + ": " + entry.dropChance * dropRate + newline; From 2b4b79e339c82df30ef6ddcff620c81535bdb23a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 5 Aug 2023 22:38:33 -0500 Subject: [PATCH 60/88] updated naming convention of variables to conform to client data --- src/engine/gameManager/LootManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index d5a3c3a7..26ba7853 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -160,9 +160,9 @@ public enum LootManager { //gets the 1-320 roll for this mob - int roll2 = TableRoll(mob.level, inHotzone); + int itemTableRoll = TableRoll(mob.level, inHotzone); - ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); + ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(itemTableRoll); if (tableRow == null) return null; From 67bcb9aeea7007103af0d8af22940fdcd0d877fd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 07:21:49 -0400 Subject: [PATCH 61/88] Refactor lootTable/itemtable for client alignment. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 8 ++++---- src/engine/gameManager/LootManager.java | 6 +++--- src/engine/objects/BootySetEntry.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index 2638e60a..23f07547 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -120,12 +120,12 @@ public class SimulateBootyCmd extends AbstractDevCmd { for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { if (entry.bootyType.equals("GOLD")) - output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance + newline; + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.itemTable + ": " + entry.dropChance + newline; else - output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.lootTable + ": " + entry.dropChance * dropRate + newline; + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.itemTable + ": " + entry.dropChance * dropRate + newline; - if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.lootTable + 1)) { - output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.lootTable + 1) + ": " + entry.dropChance * dropRate + newline; + if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.itemTable + 1)) { + output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.itemTable + 1) + ": " + entry.dropChance * dropRate + newline; hotZoneRan = true; } } diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 26ba7853..0cff9f05 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -120,14 +120,14 @@ public enum LootManager { dropRate = LootManager.NORMAL_DROP_RATE; if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) - GenerateLootDrop(mob, bse.lootTable, false); //generate normal loot drop + GenerateLootDrop(mob, bse.itemTable, false); //generate normal loot drop // Generate hotzone loot if in hotzone // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.lootTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { - GenerateLootDrop(mob, bse.lootTable + 1, true); //generate loot drop from hotzone table + if (generalItemTables.containsKey(bse.itemTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { + GenerateLootDrop(mob, bse.itemTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } diff --git a/src/engine/objects/BootySetEntry.java b/src/engine/objects/BootySetEntry.java index ff22bbaf..90b04d14 100644 --- a/src/engine/objects/BootySetEntry.java +++ b/src/engine/objects/BootySetEntry.java @@ -18,7 +18,7 @@ public class BootySetEntry { public int lowGold; public int highGold; public int itemBase; - public int lootTable; + public int itemTable; public float dropChance; /** @@ -30,7 +30,7 @@ public class BootySetEntry { this.lowGold = (rs.getInt("lowGold")); this.highGold = (rs.getInt("highGold")); this.itemBase = (rs.getInt("itemBase")); - this.lootTable = (rs.getInt("lootTable")); + this.itemTable = (rs.getInt("itemTable")); this.dropChance = (rs.getFloat("dropChance")); } From e424441380a57c13ebbcf92d2c60ed8ed6e000f7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 07:53:33 -0400 Subject: [PATCH 62/88] Booty loot table is a gentable entry. --- src/engine/devcmd/cmds/SimulateBootyCmd.java | 8 ++++---- src/engine/gameManager/LootManager.java | 6 +++--- src/engine/objects/BootySetEntry.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index 23f07547..eca63e54 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -120,12 +120,12 @@ public class SimulateBootyCmd extends AbstractDevCmd { for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { if (entry.bootyType.equals("GOLD")) - output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.itemTable + ": " + entry.dropChance + newline; + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.genTable + ": " + entry.dropChance + newline; else - output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.itemTable + ": " + entry.dropChance * dropRate + newline; + output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.genTable + ": " + entry.dropChance * dropRate + newline; - if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.itemTable + 1)) { - output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.itemTable + 1) + ": " + entry.dropChance * dropRate + newline; + if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.genTable + 1)) { + output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.genTable + 1) + ": " + entry.dropChance * dropRate + newline; hotZoneRan = true; } } diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 0cff9f05..2011d080 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -120,14 +120,14 @@ public enum LootManager { dropRate = LootManager.NORMAL_DROP_RATE; if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) - GenerateLootDrop(mob, bse.itemTable, false); //generate normal loot drop + GenerateLootDrop(mob, bse.genTable, false); //generate normal loot drop // Generate hotzone loot if in hotzone // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.itemTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { - GenerateLootDrop(mob, bse.itemTable + 1, true); //generate loot drop from hotzone table + if (generalItemTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { + GenerateLootDrop(mob, bse.genTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } diff --git a/src/engine/objects/BootySetEntry.java b/src/engine/objects/BootySetEntry.java index 90b04d14..4f62a5a7 100644 --- a/src/engine/objects/BootySetEntry.java +++ b/src/engine/objects/BootySetEntry.java @@ -18,7 +18,7 @@ public class BootySetEntry { public int lowGold; public int highGold; public int itemBase; - public int itemTable; + public int genTable; public float dropChance; /** @@ -30,7 +30,7 @@ public class BootySetEntry { this.lowGold = (rs.getInt("lowGold")); this.highGold = (rs.getInt("highGold")); this.itemBase = (rs.getInt("itemBase")); - this.itemTable = (rs.getInt("itemTable")); + this.genTable = (rs.getInt("genTable")); this.dropChance = (rs.getFloat("dropChance")); } From ff7e1ae8c178c5a6451f62d6e103773dd830ce99 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 07:59:27 -0400 Subject: [PATCH 63/88] Junk code removal. --- .../db/handlers/dbLootTableHandler.java | 2 +- src/engine/devcmd/cmds/GetMobBaseLoot.java | 58 ------------------ src/engine/gameManager/DevCmdManager.java | 1 - src/engine/objects/LootTable.java | 2 +- src/engine/objects/MobLootBase.java | 59 ------------------- 5 files changed, 2 insertions(+), 120 deletions(-) delete mode 100644 src/engine/devcmd/cmds/GetMobBaseLoot.java delete mode 100644 src/engine/objects/MobLootBase.java diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index e05df915..55d81177 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -41,7 +41,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootTable lootTable = LootTable.getLootGroup(rs.getInt("genTable")); + LootTable lootTable = LootTable.getGenTable(rs.getInt("genTable")); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), ""); } diff --git a/src/engine/devcmd/cmds/GetMobBaseLoot.java b/src/engine/devcmd/cmds/GetMobBaseLoot.java deleted file mode 100644 index edd450a6..00000000 --- a/src/engine/devcmd/cmds/GetMobBaseLoot.java +++ /dev/null @@ -1,58 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.Enum.GameObjectType; -import engine.devcmd.AbstractDevCmd; -import engine.objects.AbstractGameObject; -import engine.objects.Mob; -import engine.objects.MobLootBase; -import engine.objects.PlayerCharacter; - -/** - * @author Eighty - */ -public class GetMobBaseLoot extends AbstractDevCmd { - - public GetMobBaseLoot() { - super("mobbaseloot"); - } - - @Override - protected void _doCmd(PlayerCharacter pc, String[] words, - AbstractGameObject target) { - if (target.getObjectType() != GameObjectType.Mob) { - this.throwbackError(pc, "Must be targeting a Valid Mob For this Command."); - return; - } - - - Mob mob = (Mob) target; - for (MobLootBase mlb : MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())) { - - this.throwbackInfo(pc, "LootTable11 = " + mlb.getLootTableID() + "\rn "); - this.throwbackInfo(pc, "Chance = " + mlb.getChance() + "\rn "); - - } - - - } - - @Override - protected String _getHelpString() { - return "Copies a Mob of type 'mobID' with optional new name"; - } - - @Override - protected String _getUsageString() { - return "' /mob mobID [name]'"; - } - -} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index d7d5cb49..e1163ccf 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -128,7 +128,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new SetForceRenameCityCmd()); DevCmdManager.registerDevCmd(new GotoObj()); DevCmdManager.registerDevCmd(new convertLoc()); - DevCmdManager.registerDevCmd(new GetMobBaseLoot()); DevCmdManager.registerDevCmd(new MBDropCmd()); DevCmdManager.registerDevCmd(new AuditHeightMapCmd()); DevCmdManager.registerDevCmd(new UnloadFurnitureCmd()); diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index 2ab7a4e4..3c66db39 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -53,7 +53,7 @@ public class LootTable { this.lootTableID = lootTableID; } - public static LootTable getLootGroup(int UUID) { + public static LootTable getGenTable(int UUID) { if (lootGroups.containsKey(UUID)) return lootGroups.get(UUID); diff --git a/src/engine/objects/MobLootBase.java b/src/engine/objects/MobLootBase.java deleted file mode 100644 index e7a64b28..00000000 --- a/src/engine/objects/MobLootBase.java +++ /dev/null @@ -1,59 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; - -public class MobLootBase { - - public static HashMap> MobLootSet = new HashMap<>(); - private int mobBaseID; - private int lootTableID; - private float chance; - - - /** - * ResultSet Constructor - */ - - public MobLootBase(ResultSet rs) throws SQLException { - this.mobBaseID = rs.getInt("mobBaseID"); - this.lootTableID = rs.getInt("lootTable"); - this.chance = rs.getFloat("chance"); - } - - public MobLootBase(int mobBaseID, int lootTableID, int chance) { - super(); - this.mobBaseID = mobBaseID; - this.lootTableID = lootTableID; - this.chance = chance; - - } - - public int getMobBaseID() { - return mobBaseID; - } - - public float getChance() { - return chance; - } - - public int getLootTableID() { - return lootTableID; - } - - public void setLootTableID(int lootTableID) { - this.lootTableID = lootTableID; - } - -} From f0503aa63b6b5de3f2bb0de28fc18fbdb09333dc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 08:17:15 -0400 Subject: [PATCH 64/88] Junk code removal. --- .../db/handlers/dbLootTableHandler.java | 10 +- src/engine/objects/ItemFactory.java | 4 +- src/engine/objects/LootTable.java | 121 ++++-------------- 3 files changed, 33 insertions(+), 102 deletions(-) diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootTableHandler.java index 55d81177..40024d64 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootTableHandler.java @@ -49,7 +49,7 @@ public class dbLootTableHandler extends dbHandlerBase { Logger.error(e); } - Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootGroups().size()); + Logger.info("read: " + recordsRead + " cached: " + LootTable.getGenTables().size()); } public void populateItemTables() { @@ -63,7 +63,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootTable lootTable = LootTable.getLootTable(rs.getInt("itemTable")); + LootTable lootTable = LootTable.getItemTable(rs.getInt("itemTable")); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemBaseUUID"), rs.getInt("minSpawn"), rs.getInt("maxSpawn"), ""); } @@ -71,7 +71,7 @@ public class dbLootTableHandler extends dbHandlerBase { Logger.error(e); } - Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootTables().size()); + Logger.info("read: " + recordsRead + " cached: " + LootTable.getItemTables().size()); } public void populateModTables() { @@ -107,7 +107,7 @@ public class dbLootTableHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; - LootTable lootTable = LootTable.getModGroup(rs.getInt("modType")); + LootTable lootTable = LootTable.getModTypeTable(rs.getInt("modType")); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("subTableID"), 0, 0, ""); } @@ -115,7 +115,7 @@ public class dbLootTableHandler extends dbHandlerBase { Logger.error(e); } - Logger.info("read: " + recordsRead + " cached: " + LootTable.getModGroups().size()); + Logger.info("read: " + recordsRead + " cached: " + LootTable.getModTypeTables().size()); } public void LOAD_ENCHANT_VALUES() { diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 4e0cc8dd..a6ca94d5 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -694,8 +694,8 @@ public class ItemFactory { return null; } - prefixLootTable = LootTable.getModGroup(prefixMod); - suffixLootTable = LootTable.getModGroup(suffixMod); + prefixLootTable = LootTable.getModTypeTable(prefixMod); + suffixLootTable = LootTable.getModTypeTable(suffixMod); if (prefixLootTable == null || suffixLootTable == null) return null; diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index 3c66db39..950b9867 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -23,10 +23,10 @@ import java.util.concurrent.ThreadLocalRandom; public class LootTable { - private static final ConcurrentHashMap lootGroups = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap lootTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + private static final ConcurrentHashMap genTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + private static final ConcurrentHashMap itemTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap modGroups = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + private static final ConcurrentHashMap modTypeTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap statRuneChances = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public static boolean initialized = false; public static HashMap itemsDroppedMap = new HashMap<>(); @@ -55,21 +55,21 @@ public class LootTable { public static LootTable getGenTable(int UUID) { - if (lootGroups.containsKey(UUID)) - return lootGroups.get(UUID); + if (genTables.containsKey(UUID)) + return genTables.get(UUID); LootTable lootGroup = new LootTable(UUID); - lootGroups.put(UUID, lootGroup); + genTables.put(UUID, lootGroup); return lootGroup; } - public static LootTable getLootTable(int UUID) { + public static LootTable getItemTable(int UUID) { - if (lootTables.containsKey(UUID)) - return lootTables.get(UUID); + if (itemTables.containsKey(UUID)) + return itemTables.get(UUID); LootTable lootTable = new LootTable(UUID); - lootTables.put(UUID, lootTable); + itemTables.put(UUID, lootTable); return lootTable; } @@ -77,15 +77,15 @@ public class LootTable { /** * @return the lootGroups */ - public static ConcurrentHashMap getLootGroups() { - return lootGroups; + public static ConcurrentHashMap getGenTables() { + return genTables; } /** * @return the lootTables */ - public static ConcurrentHashMap getLootTables() { - return lootTables; + public static ConcurrentHashMap getItemTables() { + return itemTables; } /** @@ -98,17 +98,17 @@ public class LootTable { /** * @return the modGroups */ - public static ConcurrentHashMap getModGroups() { - return modGroups; + public static ConcurrentHashMap getModTypeTables() { + return modTypeTables; } - public static LootTable getModGroup(int UUID) { + public static LootTable getModTypeTable(int UUID) { - if (modGroups.containsKey(UUID)) - return modGroups.get(UUID); + if (modTypeTables.containsKey(UUID)) + return modTypeTables.get(UUID); LootTable modTable = new LootTable(UUID); - modGroups.put(UUID, modTable); + modTypeTables.put(UUID, modTable); return modTable; } @@ -132,8 +132,6 @@ public class LootTable { DbManager.LootQueries.populateModTables(); DbManager.LootQueries.populateModTypeTables(); - //preset chances for rune drops - populateStatRuneChances(); } public static int gaussianLevel(int level) { @@ -148,73 +146,6 @@ public class LootTable { } - //This set's the drop chances for stat runes. - public static void populateStatRuneChances() { - - //+3, Increased - statRuneChances.put(250018, 60); - statRuneChances.put(250009, 60); - statRuneChances.put(250027, 60); - statRuneChances.put(250036, 60); - statRuneChances.put(250000, 60); - - //+5, Enhanced - statRuneChances.put(250019, 60); - statRuneChances.put(250010, 60); - statRuneChances.put(250028, 60); - statRuneChances.put(250037, 60); - statRuneChances.put(250001, 60); - - //+10 Exceptional - statRuneChances.put(250020, 60); - statRuneChances.put(250011, 60); - statRuneChances.put(250029, 60); - statRuneChances.put(250038, 60); - statRuneChances.put(250002, 60); - - //+15, Amazing - statRuneChances.put(250021, 60); - statRuneChances.put(250012, 60); - statRuneChances.put(250030, 60); - statRuneChances.put(250039, 60); - statRuneChances.put(250003, 60); - - //+20, Incredible - statRuneChances.put(250022, 60); - statRuneChances.put(250013, 60); - statRuneChances.put(250031, 60); - statRuneChances.put(250040, 60); - statRuneChances.put(250004, 60); - - //+25, Great - statRuneChances.put(250023, 60); - statRuneChances.put(250014, 60); - statRuneChances.put(250032, 60); - statRuneChances.put(250041, 60); - statRuneChances.put(250005, 60); - - //+30, Heroic - statRuneChances.put(250024, 60); - statRuneChances.put(250015, 60); - statRuneChances.put(250033, 60); - statRuneChances.put(250042, 60); - statRuneChances.put(250006, 60); - - //+35, Legendary - statRuneChances.put(250025, 60); - statRuneChances.put(250016, 60); - statRuneChances.put(250034, 60); - statRuneChances.put(250043, 60); - statRuneChances.put(250007, 60); - - //+40, of the Gods - statRuneChances.put(250026, 60); - statRuneChances.put(250017, 60); - statRuneChances.put(250035, 60); - statRuneChances.put(250044, 60); - statRuneChances.put(250008, 60); - } - public static Item CreateGamblerItem(Item item, PlayerCharacter gambler) { if (item == null) @@ -295,7 +226,7 @@ public class LootTable { if (groupID == 0) return null; - LootTable lootGroup = LootTable.lootGroups.get(groupID); + LootTable lootGroup = LootTable.genTables.get(groupID); if (lootGroup == null) return null; @@ -326,7 +257,7 @@ public class LootTable { groupRow = lootGroup.getLootRow(roll); - lootTable = LootTable.lootTables.get(groupRow.getValueOne()); + lootTable = LootTable.itemTables.get(groupRow.getValueOne()); roll = ThreadLocalRandom.current().nextInt(100) + 1; lootRow = lootTable.getLootRow(roll + 220); //get the item row from the bell's curve of level +-15 @@ -355,7 +286,7 @@ public class LootTable { int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1; if (chanceMod < 25) { - modGroup = LootTable.modGroups.get(groupRow.getValueTwo()); + modGroup = LootTable.modTypeTables.get(groupRow.getValueTwo()); if (modGroup != null) { @@ -389,7 +320,7 @@ public class LootTable { } } } else if (chanceMod < 50) { - modGroup = LootTable.modGroups.get(groupRow.getValueThree()); + modGroup = LootTable.modTypeTables.get(groupRow.getValueThree()); if (modGroup != null) { @@ -426,7 +357,7 @@ public class LootTable { } } } else { - modGroup = LootTable.modGroups.get(groupRow.getValueTwo()); + modGroup = LootTable.modTypeTables.get(groupRow.getValueTwo()); if (modGroup != null) { @@ -464,7 +395,7 @@ public class LootTable { } //get modifierSuffix - modGroup = LootTable.modGroups.get(groupRow.getValueThree()); + modGroup = LootTable.modTypeTables.get(groupRow.getValueThree()); if (modGroup != null) { From a3a2b01ec4fbda4fbac26e0f4a6c521498f672aa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 08:36:16 -0400 Subject: [PATCH 65/88] Method moved to manager class. --- src/engine/gameManager/LootManager.java | 9 +++++++++ src/engine/objects/LootTable.java | 10 ---------- src/engine/server/world/WorldServer.java | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 2011d080..7f76f629 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -436,4 +436,13 @@ public enum LootManager { } } + //call this on server startup to populate the tables + public static void populateLootTables() { + + DbManager.LootQueries.populateGenTables(); + DbManager.LootQueries.populateItemTables(); + DbManager.LootQueries.populateModTables(); + DbManager.LootQueries.populateModTypeTables(); + + } } \ No newline at end of file diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index 950b9867..eb738554 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -124,16 +124,6 @@ public class LootTable { return modTypeTable; } - //call this on server startup to populate the tables - public static void populateLootTables() { - - DbManager.LootQueries.populateGenTables(); - DbManager.LootQueries.populateItemTables(); - DbManager.LootQueries.populateModTables(); - DbManager.LootQueries.populateModTypeTables(); - - } - public static int gaussianLevel(int level) { int ret = -76; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index e2cc71d5..15e1da65 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -341,7 +341,7 @@ public class WorldServer { LootManager.init(); //load old loot system (still needed for rolling for now) - LootTable.populateLootTables(); + LootManager.populateLootTables(); RuneBaseAttribute.LoadAllAttributes(); RuneBase.LoadAllRuneBases(); BaseClass.LoadAllBaseClasses(); From f8b09b5f3350585c7d2e8b203857a7520c0c27e9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 14:04:06 -0400 Subject: [PATCH 66/88] Class moved to loot package. --- src/engine/db/handlers/dbItemBaseHandler.java | 2 +- src/engine/devcmd/cmds/SimulateBootyCmd.java | 1 + src/engine/gameManager/NPCManager.java | 1 + src/engine/{objects => loot}/BootySetEntry.java | 2 +- src/engine/objects/MobBase.java | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) rename src/engine/{objects => loot}/BootySetEntry.java (98%) diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 62e249d8..804b8587 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -10,7 +10,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; -import engine.objects.BootySetEntry; +import engine.loot.BootySetEntry; import engine.objects.ItemBase; import org.pmw.tinylog.Logger; diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index eca63e54..adcf47e4 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -4,6 +4,7 @@ import engine.devcmd.AbstractDevCmd; import engine.gameManager.LootManager; import engine.gameManager.NPCManager; import engine.gameManager.ZoneManager; +import engine.loot.BootySetEntry; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 448aa587..1e91ba5f 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -2,6 +2,7 @@ package engine.gameManager; import engine.Enum; import engine.InterestManagement.WorldGrid; +import engine.loot.BootySetEntry; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; diff --git a/src/engine/objects/BootySetEntry.java b/src/engine/loot/BootySetEntry.java similarity index 98% rename from src/engine/objects/BootySetEntry.java rename to src/engine/loot/BootySetEntry.java index 4f62a5a7..d909a413 100644 --- a/src/engine/objects/BootySetEntry.java +++ b/src/engine/loot/BootySetEntry.java @@ -7,7 +7,7 @@ // www.magicbane.com -package engine.objects; +package engine.loot; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index 1c8fa548..66620a25 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -13,6 +13,7 @@ import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; import engine.gameManager.DbManager; import engine.gameManager.NPCManager; +import engine.loot.BootySetEntry; import engine.server.MBServerStatics; import java.sql.ResultSet; From 14e7b0395c4c1a9a4ae160c893ca695949592418 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 17:44:30 -0400 Subject: [PATCH 67/88] New _genTables collection defined. --- src/engine/gameManager/LootManager.java | 4 ++++ src/engine/loot/GenTableEntry.java | 28 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/engine/loot/GenTableEntry.java diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 7f76f629..ab162c23 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -27,6 +27,10 @@ public enum LootManager { LOOTMANAGER; + // Newer tables + + public static final HashMap> _genTables = new HashMap<>(); + //new tables public static final HashMap generalItemTables = new HashMap<>(); public static final HashMap itemTables = new HashMap<>(); diff --git a/src/engine/loot/GenTableEntry.java b/src/engine/loot/GenTableEntry.java new file mode 100644 index 00000000..b615121e --- /dev/null +++ b/src/engine/loot/GenTableEntry.java @@ -0,0 +1,28 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class GenTableEntry { + public int minRoll; + public int maxRoll; + public int itemTableID; + public int pModTable; + public int sModTable; + + public GenTableEntry(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.itemTableID = rs.getInt("itemTableID"); + this.pModTable = rs.getInt("pModTableID"); + this.sModTable = rs.getInt("sModTableID"); + } +} From 0013020bfa3b7d8770bba5e93f96cf5c18c43229 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 17:47:49 -0400 Subject: [PATCH 68/88] New consolidated loot db handler. Booty loading moved into new handler. --- src/engine/db/handlers/dbItemBaseHandler.java | 38 -------------- ...otTableHandler.java => dbLootHandler.java} | 49 ++++++++++++++++--- src/engine/gameManager/DbManager.java | 2 +- src/engine/gameManager/NPCManager.java | 2 +- 4 files changed, 45 insertions(+), 46 deletions(-) rename src/engine/db/handlers/{dbLootTableHandler.java => dbLootHandler.java} (83%) diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 804b8587..bf12b434 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -10,7 +10,6 @@ package engine.db.handlers; import engine.gameManager.DbManager; -import engine.loot.BootySetEntry; import engine.objects.ItemBase; import org.pmw.tinylog.Logger; @@ -136,41 +135,4 @@ public class dbItemBaseHandler extends dbHandlerBase { return runeSets; } - public HashMap> LOAD_BOOTY_FOR_MOBS() { - - HashMap> bootySets = new HashMap<>(); - BootySetEntry bootySetEntry; - int bootySetID; - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - - recordsRead++; - - bootySetID = rs.getInt("bootySet"); - bootySetEntry = new BootySetEntry(rs); - - if (bootySets.get(bootySetID) == null) { - ArrayList bootyList = new ArrayList<>(); - bootyList.add(bootySetEntry); - bootySets.put(bootySetID, bootyList); - } else { - ArrayList bootyList = bootySets.get(bootySetID); - bootyList.add(bootySetEntry); - bootySets.put(bootySetID, bootyList); - } - } - } catch (SQLException e) { - Logger.error(e); - return bootySets; - } - - Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); - return bootySets; - } } diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootHandler.java similarity index 83% rename from src/engine/db/handlers/dbLootTableHandler.java rename to src/engine/db/handlers/dbLootHandler.java index 40024d64..15b5289d 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -11,10 +11,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; import engine.gameManager.LootManager; -import engine.loot.GenTableRow; -import engine.loot.ItemTableRow; -import engine.loot.ModTableRow; -import engine.loot.ModTypeTableRow; +import engine.loot.*; import engine.objects.Item; import engine.objects.LootTable; import org.pmw.tinylog.Logger; @@ -23,13 +20,53 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; -public class dbLootTableHandler extends dbHandlerBase { +public class dbLootHandler extends dbHandlerBase { - public dbLootTableHandler() { + public dbLootHandler() { } + public HashMap> LOAD_BOOTY_FOR_MOBS() { + + HashMap> bootySets = new HashMap<>(); + BootySetEntry bootySetEntry; + int bootySetID; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + bootySetID = rs.getInt("bootySet"); + bootySetEntry = new BootySetEntry(rs); + + if (bootySets.get(bootySetID) == null) { + ArrayList bootyList = new ArrayList<>(); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } else { + ArrayList bootyList = bootySets.get(bootySetID); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } + } + } catch (SQLException e) { + Logger.error(e); + return bootySets; + } + + Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); + return bootySets; + } + public void populateGenTables() { int recordsRead = 0; diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index a2e2522f..25792846 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -49,7 +49,7 @@ public enum DbManager { public static final dbItemHandler ItemQueries = new dbItemHandler(); public static final dbItemBaseHandler ItemBaseQueries = new dbItemBaseHandler(); public static final dbKitHandler KitQueries = new dbKitHandler(); - public static final dbLootTableHandler LootQueries = new dbLootTableHandler(); + public static final dbLootHandler LootQueries = new dbLootHandler(); public static final dbMenuHandler MenuQueries = new dbMenuHandler(); public static final dbMineHandler MineQueries = new dbMineHandler(); public static final dbMobHandler MobQueries = new dbMobHandler(); diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 1e91ba5f..31e54704 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -25,7 +25,7 @@ public enum NPCManager { } public static void LoadAllBootySets() { - _bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS(); + _bootySetMap = DbManager.LootQueries.LOAD_BOOTY_FOR_MOBS(); } public static void applyRuneSetEffects(Mob mob) { From dd756d4c00beadd69f9257405efe7283152263f1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 18:00:45 -0400 Subject: [PATCH 69/88] _genTables populated. --- src/engine/db/handlers/dbLootHandler.java | 41 ++++++++++++++++++++++- src/engine/gameManager/NPCManager.java | 2 +- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/engine/db/handlers/dbLootHandler.java b/src/engine/db/handlers/dbLootHandler.java index 15b5289d..5f267701 100644 --- a/src/engine/db/handlers/dbLootHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -29,7 +29,46 @@ public class dbLootHandler extends dbHandlerBase { } - public HashMap> LOAD_BOOTY_FOR_MOBS() { + public HashMap> LOAD_GEN_ITEM_TABLES() { + + HashMap> genTables = new HashMap<>(); + GenTableEntry genTableEntry; + + int genTableID; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `genTable`, `minRoll`, `maxRoll`, `itemTableID`, `pModTableID`, `sModTableID` FROM `static_gentables`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + genTableID = rs.getInt("bootySet"); + genTableEntry = new GenTableEntry(rs); + + if (genTables.get(genTableID) == null) { + ArrayList genItemList = new ArrayList<>(); + genItemList.add(genTableEntry); + genTables.put(genTableID, genItemList); + } else { + ArrayList genItemList = genTables.get(genTableID); + genItemList.add(genTableEntry); + genTables.put(genTableID, genItemList); + } + } + } catch (SQLException e) { + Logger.error(e); + return genTables; + } + + Logger.info("read: " + recordsRead + " cached: " + genTables.size()); + return genTables; + } + + public HashMap> LOAD_BOOTY_TABLES() { HashMap> bootySets = new HashMap<>(); BootySetEntry bootySetEntry; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 31e54704..176e4278 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -25,7 +25,7 @@ public enum NPCManager { } public static void LoadAllBootySets() { - _bootySetMap = DbManager.LootQueries.LOAD_BOOTY_FOR_MOBS(); + _bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); } public static void applyRuneSetEffects(Mob mob) { From 6acc42234557f0a097f52fde735cb82e97e47064 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 18:08:31 -0400 Subject: [PATCH 70/88] _genTables populated. --- src/engine/gameManager/LootManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index ab162c23..e525386c 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -443,6 +443,8 @@ public enum LootManager { //call this on server startup to populate the tables public static void populateLootTables() { + DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); + DbManager.LootQueries.populateGenTables(); DbManager.LootQueries.populateItemTables(); DbManager.LootQueries.populateModTables(); From 8f71c8af01790e6ba22947e6fa1750b90cec8913 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 6 Aug 2023 18:09:34 -0400 Subject: [PATCH 71/88] _genTables populated. --- src/engine/gameManager/LootManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index e525386c..730eb269 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -29,7 +29,7 @@ public enum LootManager { // Newer tables - public static final HashMap> _genTables = new HashMap<>(); + public static HashMap> _genTables = new HashMap<>(); //new tables public static final HashMap generalItemTables = new HashMap<>(); @@ -443,7 +443,7 @@ public enum LootManager { //call this on server startup to populate the tables public static void populateLootTables() { - DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); + _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); DbManager.LootQueries.populateGenTables(); DbManager.LootQueries.populateItemTables(); From efe7784a3f7401ebc72e36109fa8bb3080d70201 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 08:22:37 -0400 Subject: [PATCH 72/88] _itemTableEntry created. Class init cleaned up. --- src/engine/gameManager/LootManager.java | 22 ++++++------------- src/engine/loot/ItemTableEntry.java | 28 ++++++++++++++++++++++++ src/engine/server/world/WorldServer.java | 2 -- 3 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 src/engine/loot/ItemTableEntry.java diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 730eb269..918ccb29 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -30,12 +30,13 @@ public enum LootManager { // Newer tables public static HashMap> _genTables = new HashMap<>(); + public static HashMap> _itemTable = new HashMap<>(); //new tables - public static final HashMap generalItemTables = new HashMap<>(); - public static final HashMap itemTables = new HashMap<>(); - public static final HashMap modTypeTables = new HashMap<>(); - public static final HashMap modTables = new HashMap<>(); + public static final HashMap generalItemTables = null; + public static final HashMap itemTables = null; + public static final HashMap modTypeTables = null; + public static final HashMap modTables = null; // Drop Rates @@ -52,6 +53,8 @@ public enum LootManager { // Load loot tables from database. + _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); + DbManager.LootQueries.LOAD_ALL_GENTABLES(); DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); DbManager.LootQueries.LOAD_ALL_MODTYPES(); @@ -440,15 +443,4 @@ public enum LootManager { } } - //call this on server startup to populate the tables - public static void populateLootTables() { - - _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); - - DbManager.LootQueries.populateGenTables(); - DbManager.LootQueries.populateItemTables(); - DbManager.LootQueries.populateModTables(); - DbManager.LootQueries.populateModTypeTables(); - - } } \ No newline at end of file diff --git a/src/engine/loot/ItemTableEntry.java b/src/engine/loot/ItemTableEntry.java new file mode 100644 index 00000000..ef652842 --- /dev/null +++ b/src/engine/loot/ItemTableEntry.java @@ -0,0 +1,28 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ItemTableEntry { + public int minRoll; + public int maxRoll; + public int cacheID; + public int minSpawn; + public int maxSpawn; + + public ItemTableEntry(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.cacheID = rs.getInt("itemBaseUUID"); + this.minSpawn = rs.getInt("minSpawn"); + this.maxSpawn = rs.getInt("maxSpawn"); + } +} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 15e1da65..9ac027e6 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -340,8 +340,6 @@ public class WorldServer { Logger.info("Initializing Loot Manager"); LootManager.init(); - //load old loot system (still needed for rolling for now) - LootManager.populateLootTables(); RuneBaseAttribute.LoadAllAttributes(); RuneBase.LoadAllRuneBases(); BaseClass.LoadAllBaseClasses(); From 32d71df8373bad6b08a0fea7dff0251c41164547 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 08:39:08 -0400 Subject: [PATCH 73/88] _itemTables populated at startup. --- src/engine/db/handlers/dbLootHandler.java | 126 +++++++--------------- src/engine/gameManager/LootManager.java | 4 +- 2 files changed, 41 insertions(+), 89 deletions(-) diff --git a/src/engine/db/handlers/dbLootHandler.java b/src/engine/db/handlers/dbLootHandler.java index 5f267701..94ebaff5 100644 --- a/src/engine/db/handlers/dbLootHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -13,7 +13,6 @@ import engine.gameManager.DbManager; import engine.gameManager.LootManager; import engine.loot.*; import engine.objects.Item; -import engine.objects.LootTable; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -38,7 +37,7 @@ public class dbLootHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `genTable`, `minRoll`, `maxRoll`, `itemTableID`, `pModTableID`, `sModTableID` FROM `static_gentables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_gentables`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -68,15 +67,16 @@ public class dbLootHandler extends dbHandlerBase { return genTables; } - public HashMap> LOAD_BOOTY_TABLES() { + public HashMap> LOAD_ITEM_TABLES() { - HashMap> bootySets = new HashMap<>(); - BootySetEntry bootySetEntry; - int bootySetID; + HashMap> itemTables = new HashMap<>(); + ItemTableEntry itemTableEntry; + + int itemTableID; int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itemTables`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -84,114 +84,64 @@ public class dbLootHandler extends dbHandlerBase { recordsRead++; - bootySetID = rs.getInt("bootySet"); - bootySetEntry = new BootySetEntry(rs); + itemTableID = rs.getInt("itemTable"); + itemTableEntry = new ItemTableEntry(rs); - if (bootySets.get(bootySetID) == null) { - ArrayList bootyList = new ArrayList<>(); - bootyList.add(bootySetEntry); - bootySets.put(bootySetID, bootyList); + if (itemTables.get(itemTableID) == null) { + ArrayList itemTableList = new ArrayList<>(); + itemTableList.add(itemTableEntry); + itemTables.put(itemTableID, itemTableList); } else { - ArrayList bootyList = bootySets.get(bootySetID); - bootyList.add(bootySetEntry); - bootySets.put(bootySetID, bootyList); + ArrayList itemTableList = itemTables.get(itemTableID); + itemTableList.add(itemTableEntry); + itemTables.put(itemTableID, itemTableList); } } } catch (SQLException e) { Logger.error(e); - return bootySets; + return itemTables; } - Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); - return bootySets; + Logger.info("read: " + recordsRead + " cached: " + itemTables.size()); + return itemTables; } - public void populateGenTables() { - - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `genTable`, `minRoll`, `maxRoll`, `itemTableID`, `pModTableID`, `sModTableID` FROM `static_gentables`")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - recordsRead++; - LootTable lootTable = LootTable.getGenTable(rs.getInt("genTable")); - lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), ""); - } - - } catch (SQLException e) { - Logger.error(e); - } - - Logger.info("read: " + recordsRead + " cached: " + LootTable.getGenTables().size()); - } - - public void populateItemTables() { + public HashMap> LOAD_BOOTY_TABLES() { + HashMap> bootySets = new HashMap<>(); + BootySetEntry bootySetEntry; + int bootySetID; int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `itemTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_itemtables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { - recordsRead++; - LootTable lootTable = LootTable.getItemTable(rs.getInt("itemTable")); - lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemBaseUUID"), rs.getInt("minSpawn"), rs.getInt("maxSpawn"), ""); - } - - } catch (SQLException e) { - Logger.error(e); - } - - Logger.info("read: " + recordsRead + " cached: " + LootTable.getItemTables().size()); - } - - public void populateModTables() { - - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modTable`,`minRoll`,`maxRoll`,`value`,`action` FROM `static_modtables`")) { - - ResultSet rs = preparedStatement.executeQuery(); - while (rs.next()) { recordsRead++; - LootTable lootTable = LootTable.getModTable(rs.getInt("modTable")); - lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("value"), 0, 0, rs.getString("action")); - } - } catch (SQLException e) { - Logger.error(e); - } - - Logger.info("read: " + recordsRead + " cached: " + LootTable.getModTables().size()); - } - - public void populateModTypeTables() { - - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modType`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modtypetables`")) { - - ResultSet rs = preparedStatement.executeQuery(); + bootySetID = rs.getInt("bootySet"); + bootySetEntry = new BootySetEntry(rs); - while (rs.next()) { - recordsRead++; - LootTable lootTable = LootTable.getModTypeTable(rs.getInt("modType")); - lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("subTableID"), 0, 0, ""); + if (bootySets.get(bootySetID) == null) { + ArrayList bootyList = new ArrayList<>(); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } else { + ArrayList bootyList = bootySets.get(bootySetID); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } } - } catch (SQLException e) { Logger.error(e); + return bootySets; } - Logger.info("read: " + recordsRead + " cached: " + LootTable.getModTypeTables().size()); + Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); + return bootySets; } public void LOAD_ENCHANT_VALUES() { diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 918ccb29..7558c024 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -30,7 +30,7 @@ public enum LootManager { // Newer tables public static HashMap> _genTables = new HashMap<>(); - public static HashMap> _itemTable = new HashMap<>(); + public static HashMap> _itemTables = new HashMap<>(); //new tables public static final HashMap generalItemTables = null; @@ -54,6 +54,8 @@ public enum LootManager { // Load loot tables from database. _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); + _itemTables = DbManager.LootQueries.LOAD_ITEM_TABLES(); + DbManager.LootQueries.LOAD_ALL_GENTABLES(); DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); From 8c4d9b66ef127f1479180459d2235fe49ab2bd79 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 08:49:43 -0400 Subject: [PATCH 74/88] _modTables populated at startup. --- src/engine/db/handlers/dbLootHandler.java | 39 +++++++++++++++++++++++ src/engine/gameManager/LootManager.java | 3 +- src/engine/loot/ModTableEntry.java | 26 +++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/engine/loot/ModTableEntry.java diff --git a/src/engine/db/handlers/dbLootHandler.java b/src/engine/db/handlers/dbLootHandler.java index 94ebaff5..75fe1454 100644 --- a/src/engine/db/handlers/dbLootHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -106,6 +106,45 @@ public class dbLootHandler extends dbHandlerBase { return itemTables; } + public HashMap> LOAD_MOD_TABLES() { + + HashMap> modTables = new HashMap<>(); + ModTableEntry modTableEntry; + + int modTableID; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_modTables`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + modTableID = rs.getInt("itemTable"); + modTableEntry = new ModTableEntry(rs); + + if (modTables.get(modTableID) == null) { + ArrayList modTableList = new ArrayList<>(); + modTableList.add(modTableEntry); + modTables.put(modTableID, modTableList); + } else { + ArrayList modTableList = modTables.get(modTableID); + modTableList.add(modTableEntry); + modTables.put(modTableID, modTableList); + } + } + } catch (SQLException e) { + Logger.error(e); + return modTables; + } + + Logger.info("read: " + recordsRead + " cached: " + modTables.size()); + return modTables; + } + public HashMap> LOAD_BOOTY_TABLES() { HashMap> bootySets = new HashMap<>(); diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 7558c024..479cc8cf 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -31,6 +31,7 @@ public enum LootManager { public static HashMap> _genTables = new HashMap<>(); public static HashMap> _itemTables = new HashMap<>(); + public static HashMap> _modTables = new HashMap<>(); //new tables public static final HashMap generalItemTables = null; @@ -55,7 +56,7 @@ public enum LootManager { _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); _itemTables = DbManager.LootQueries.LOAD_ITEM_TABLES(); - + _modTables = DbManager.LootQueries.LOAD_MOD_TABLES(); DbManager.LootQueries.LOAD_ALL_GENTABLES(); DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); diff --git a/src/engine/loot/ModTableEntry.java b/src/engine/loot/ModTableEntry.java new file mode 100644 index 00000000..2572910a --- /dev/null +++ b/src/engine/loot/ModTableEntry.java @@ -0,0 +1,26 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ModTableEntry { + public int minRoll; + public int maxRoll; + public String action; + public int level; + + public ModTableEntry(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.action = rs.getString("action"); + this.level = rs.getInt("level"); + } +} From f7fd544a00841289c9738958b0d552745d92a1df Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 08:58:44 -0400 Subject: [PATCH 75/88] _modtypeTables populated at startup. --- src/engine/db/handlers/dbLootHandler.java | 39 +++++++++++++++++++++++ src/engine/gameManager/LootManager.java | 3 ++ src/engine/loot/ModTypeTableEntry.java | 24 ++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 src/engine/loot/ModTypeTableEntry.java diff --git a/src/engine/db/handlers/dbLootHandler.java b/src/engine/db/handlers/dbLootHandler.java index 75fe1454..36763a58 100644 --- a/src/engine/db/handlers/dbLootHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -145,6 +145,45 @@ public class dbLootHandler extends dbHandlerBase { return modTables; } + public HashMap> LOAD_MOD_TYPE_TABLES() { + + HashMap> modTypeTables = new HashMap<>(); + ModTypeTableEntry modTypeTableEntry; + + int modTableID; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_modtypeTables`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + modTableID = rs.getInt("modType"); + modTypeTableEntry = new ModTypeTableEntry(rs); + + if (modTypeTables.get(modTableID) == null) { + ArrayList modTypeTableList = new ArrayList<>(); + modTypeTableList.add(modTypeTableEntry); + modTypeTables.put(modTableID, modTypeTableList); + } else { + ArrayList modTypeTableList = modTypeTables.get(modTableID); + modTypeTableList.add(modTypeTableEntry); + modTypeTables.put(modTableID, modTypeTableList); + } + } + } catch (SQLException e) { + Logger.error(e); + return modTypeTables; + } + + Logger.info("read: " + recordsRead + " cached: " + modTypeTables.size()); + return modTypeTables; + } + public HashMap> LOAD_BOOTY_TABLES() { HashMap> bootySets = new HashMap<>(); diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 479cc8cf..0c0acdb6 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -32,6 +32,7 @@ public enum LootManager { public static HashMap> _genTables = new HashMap<>(); public static HashMap> _itemTables = new HashMap<>(); public static HashMap> _modTables = new HashMap<>(); + public static HashMap> _modTypeTables = new HashMap<>(); //new tables public static final HashMap generalItemTables = null; @@ -57,6 +58,8 @@ public enum LootManager { _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); _itemTables = DbManager.LootQueries.LOAD_ITEM_TABLES(); _modTables = DbManager.LootQueries.LOAD_MOD_TABLES(); + _modTypeTables = DbManager.LootQueries.LOAD_MOD_TYPE_TABLES(); + DbManager.LootQueries.LOAD_ALL_GENTABLES(); DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); diff --git a/src/engine/loot/ModTypeTableEntry.java b/src/engine/loot/ModTypeTableEntry.java new file mode 100644 index 00000000..b8cd13bd --- /dev/null +++ b/src/engine/loot/ModTypeTableEntry.java @@ -0,0 +1,24 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.loot; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ModTypeTableEntry { + public int minRoll; + public int maxRoll; + public int modTableID; + + public ModTypeTableEntry(ResultSet rs) throws SQLException { + this.minRoll = rs.getInt("minRoll"); + this.maxRoll = rs.getInt("maxRoll"); + this.modTableID = rs.getInt("subTableID"); + } +} From 2e59f7f01c34b386e26ec70ddb9b1689c85bc58f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 09:03:38 -0400 Subject: [PATCH 76/88] Garbage Peddler method removed. --- .../handlers/ObjectActionMsgHandler.java | 5 +- src/engine/objects/LootTable.java | 378 ------------------ 2 files changed, 2 insertions(+), 381 deletions(-) diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 0137b24d..510c6bd8 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -440,9 +440,8 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { } break; } - - LootTable.CreateGamblerItem(item, player); - + // Garbage method removed until rewritten. + // LootTable.CreateGamblerItem(item, player); break; diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index eb738554..c9c3ebb4 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -9,17 +9,10 @@ package engine.objects; -import engine.Enum.ItemContainerType; -import engine.Enum.ItemType; -import engine.Enum.OwnerType; -import engine.gameManager.DbManager; import engine.server.MBServerStatics; -import org.pmw.tinylog.Logger; -import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; public class LootTable { @@ -124,377 +117,6 @@ public class LootTable { return modTypeTable; } - public static int gaussianLevel(int level) { - - int ret = -76; - - while (ret < -75 || ret > 75) { - ret = (int) (ThreadLocalRandom.current().nextGaussian() * 75); - } - - return (level * 5) + ret; - - } - - public static Item CreateGamblerItem(Item item, PlayerCharacter gambler) { - - if (item == null) - return null; - - int groupID = 0; - - switch (item.getItemBase().getUUID()) { - case 971050: //Wrapped Axe - groupID = 3000; - break; - case 971051://Wrapped Great Axe - groupID = 3005; - break; - case 971052://Wrapped Throwing Axe - groupID = 3010; - break; - case 971053:// Wrapped Bow - groupID = 3015; - break; - case 971054://Wrapped Crossbow - groupID = 3020; - break; - case 971055: //Wrapped Dagger - groupID = 3025; - break; - case 971056: // Wrapped Throwing Dagger - groupID = 3030; - break; - case 971057: // Wrapped Hammer - groupID = 3035; - break; - case 971058:// Wrapped Great Hammer - groupID = 3040; - break; - case 971059:// Wrapped Throwing Hammer - groupID = 3045; - break; - case 971060:// Wrapped Polearm - groupID = 3050; - break; - case 971061:// Wrapped Spear - groupID = 3055; - break; - case 971062:// Wrapped Staff - groupID = 3060; - break; - case 971063:// Wrapped Sword - groupID = 3065; - break; - case 971064:// Wrapped Great Sword - groupID = 3070; - break; - case 971065:// Wrapped Unarmed Weapon - groupID = 3075; - break; - case 971066:// Wrapped Cloth Armor - groupID = 3100; - break; - case 971067:// Wrapped Light Armor - groupID = 3105; - break; - case 971068:// Wrapped Medium Armor - groupID = 3110; - break; - case 971069:// Wrapped Heavy Armor - groupID = 3115; - break; - case 971070:// Wrapped Rune - groupID = 3200; - break; - case 971071:// Wrapped City Improvement - groupID = 3210; - break; - } - //couldnt find group - - if (groupID == 0) - return null; - - LootTable lootGroup = LootTable.genTables.get(groupID); - - if (lootGroup == null) - return null; - - float calculatedMobLevel; - int minSpawn; - int maxSpawn; - int spawnQuanity = 0; - int subTableID; - String modifierPrefix = ""; - String modifierSuffix = ""; - - // Lookup Table Variables - - LootTable lootTable; - LootRow lootRow; - LootRow groupRow = null; - LootTable modTable; - LootTable modGroup; - LootRow modRow = null; - - // Used for actual generation of items - - int itemBaseUUID; - ItemBase itemBase = null; - - int roll = ThreadLocalRandom.current().nextInt(100) + 1; //Does not return Max, but does return min? - - groupRow = lootGroup.getLootRow(roll); - - lootTable = LootTable.itemTables.get(groupRow.getValueOne()); - roll = ThreadLocalRandom.current().nextInt(100) + 1; - lootRow = lootTable.getLootRow(roll + 220); //get the item row from the bell's curve of level +-15 - - if (lootRow == null) - return null; //no item found for roll - - itemBaseUUID = lootRow.getValueOne(); - - if (lootRow.getValueOne() == 0) - return null; - - //handle quantities > 1 for resource drops - - minSpawn = lootRow.getValueTwo(); - maxSpawn = lootRow.getValueThree(); - - // spawnQuanity between minspawn (inclusive) and maxspawn (inclusive) - - if (maxSpawn > 1) - spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; - - //get modifierPrefix - - calculatedMobLevel = 49; - - int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1; - - if (chanceMod < 25) { - modGroup = LootTable.modTypeTables.get(groupRow.getValueTwo()); - - if (modGroup != null) { - - for (int a = 0; a < 10; a++) { - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); - if (modRow != null) - break; - } - - if (modRow != null) { - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - - roll = gaussianLevel((int) calculatedMobLevel); - - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; - - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(roll); - - if (modRow != null) - modifierPrefix = modRow.getAction(); - } - } - } - } else if (chanceMod < 50) { - modGroup = LootTable.modTypeTables.get(groupRow.getValueThree()); - - if (modGroup != null) { - - for (int a = 0; a < 10; a++) { - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); - if (modRow != null) - break; - } - - if (modRow != null) { - - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int) calculatedMobLevel); - - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; - - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(roll); - - if (modRow == null) - modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - - if (modRow != null) - modifierSuffix = modRow.getAction(); - } - } - } - } else { - modGroup = LootTable.modTypeTables.get(groupRow.getValueTwo()); - - if (modGroup != null) { - - for (int a = 0; a < 10; a++) { - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); - if (modRow != null) - break; - } - - if (modRow != null) { - - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int) calculatedMobLevel); - - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; - - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(roll); - - if (modRow == null) - modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - - if (modRow != null) - modifierPrefix = modRow.getAction(); - } - } - } - - //get modifierSuffix - modGroup = LootTable.modTypeTables.get(groupRow.getValueThree()); - - if (modGroup != null) { - - for (int a = 0; a < 10; a++) { - roll = ThreadLocalRandom.current().nextInt(100) + 1; - modRow = modGroup.getLootRow(roll); - if (modRow != null) - break; - } - - if (modRow != null) { - - subTableID = modRow.getValueOne(); - - if (LootTable.modTables.containsKey(subTableID)) { - - modTable = LootTable.modTables.get(subTableID); - roll = gaussianLevel((int) calculatedMobLevel); - - if (roll < modTable.minRoll) - roll = (int) modTable.minRoll; - - if (roll > modTable.maxRoll) - roll = (int) modTable.maxRoll; - - modRow = modTable.getLootRow(roll); - - if (modRow == null) - modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) * .05f)); - - if (modRow != null) - modifierSuffix = modRow.getAction(); - } - } - } - } - - itemBase = ItemBase.getItemBase(itemBaseUUID); - byte charges = (byte) itemBase.getNumCharges(); - short dur = (short) itemBase.getDurability(); - - short weight = itemBase.getWeight(); - - if (!gambler.getCharItemManager().hasRoomInventory(weight)) - return null; - - Item gambledItem = new Item(itemBase, gambler.getObjectUUID(), - OwnerType.PlayerCharacter, charges, charges, dur, dur, - true, false, ItemContainerType.INVENTORY, (byte) 0, - new ArrayList<>(), ""); - - if (spawnQuanity == 0 && itemBase.getType().equals(ItemType.RESOURCE)) - spawnQuanity = 1; - - if (spawnQuanity > 0) - item.setNumOfItems(spawnQuanity); - - try { - gambledItem = DbManager.ItemQueries.ADD_ITEM(gambledItem); - } catch (Exception e) { - Logger.error(e); - } - - if (gambledItem == null) - return null; - - if (!modifierPrefix.isEmpty()) - gambledItem.addPermanentEnchantment(modifierPrefix, 0); - - if (!modifierSuffix.isEmpty()) - gambledItem.addPermanentEnchantment(modifierSuffix, 0); - - //add item to inventory - - gambler.getCharItemManager().addItemToInventory(gambledItem); - gambler.getCharItemManager().updateInventory(); - - return gambledItem; - } - - public void addRow(float min, float max, int valueOne, int valueTwo, int valueThree, String action) { - - //hackey way to set the minimum roll for SHIAT! - - if (min < this.minRoll) - this.minRoll = min; - - if (max > this.maxRoll) - this.maxRoll = max; - - int minInt = (int) min; - int maxInt = (int) max; - - //Round up min - - if (minInt != min) - min = minInt + 1; - - //Round down max; - - if (maxInt != max) - max = maxInt; - - LootRow lootRow = new LootRow(valueOne, valueTwo, valueThree, action); - - for (int i = (int) min; i <= max; i++) - lootTable.put(i, lootRow); - } - public LootRow getLootRow(int probability) { if (lootTable.containsKey(probability)) From 8a5924eeee4a629825afc7622442cd718e69b46c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 09:42:40 -0400 Subject: [PATCH 77/88] rollTable() method added to loot classes. --- src/engine/loot/GenTableEntry.java | 17 +++++++++ src/engine/loot/ItemTableEntry.java | 17 +++++++++ src/engine/loot/ModTableEntry.java | 17 +++++++++ src/engine/loot/ModTypeTableEntry.java | 17 +++++++++ src/engine/objects/LootTable.java | 53 +------------------------- 5 files changed, 69 insertions(+), 52 deletions(-) diff --git a/src/engine/loot/GenTableEntry.java b/src/engine/loot/GenTableEntry.java index b615121e..b7b3c625 100644 --- a/src/engine/loot/GenTableEntry.java +++ b/src/engine/loot/GenTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class GenTableEntry { public int minRoll; @@ -25,4 +28,18 @@ public class GenTableEntry { this.pModTable = rs.getInt("pModTableID"); this.sModTable = rs.getInt("sModTableID"); } + + public static GenTableEntry rollTable(int genTable, int roll) { + + GenTableEntry genTableEntry = null; + List genTableEntryList; + + genTableEntryList = LootManager._genTables.get(genTable); + + for (GenTableEntry iteration : genTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + genTableEntry = iteration; + + return genTableEntry; + } } diff --git a/src/engine/loot/ItemTableEntry.java b/src/engine/loot/ItemTableEntry.java index ef652842..9147f217 100644 --- a/src/engine/loot/ItemTableEntry.java +++ b/src/engine/loot/ItemTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class ItemTableEntry { public int minRoll; @@ -25,4 +28,18 @@ public class ItemTableEntry { this.minSpawn = rs.getInt("minSpawn"); this.maxSpawn = rs.getInt("maxSpawn"); } + + public static ItemTableEntry rollTable(int itemTable, int roll) { + + ItemTableEntry itemTableEntry = null; + List itemTableEntryList; + + itemTableEntryList = LootManager._itemTables.get(itemTable); + + for (ItemTableEntry iteration : itemTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + itemTableEntry = iteration; + + return itemTableEntry; + } } diff --git a/src/engine/loot/ModTableEntry.java b/src/engine/loot/ModTableEntry.java index 2572910a..86697880 100644 --- a/src/engine/loot/ModTableEntry.java +++ b/src/engine/loot/ModTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class ModTableEntry { public int minRoll; @@ -23,4 +26,18 @@ public class ModTableEntry { this.action = rs.getString("action"); this.level = rs.getInt("level"); } + + public static ModTableEntry rollTable(int modTablwe, int roll) { + + ModTableEntry modTableEntry = null; + List itemTableEntryList; + + itemTableEntryList = LootManager._modTables.get(modTablwe); + + for (ModTableEntry iteration : itemTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + modTableEntry = iteration; + + return modTableEntry; + } } diff --git a/src/engine/loot/ModTypeTableEntry.java b/src/engine/loot/ModTypeTableEntry.java index b8cd13bd..8ed23ace 100644 --- a/src/engine/loot/ModTypeTableEntry.java +++ b/src/engine/loot/ModTypeTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class ModTypeTableEntry { public int minRoll; @@ -21,4 +24,18 @@ public class ModTypeTableEntry { this.maxRoll = rs.getInt("maxRoll"); this.modTableID = rs.getInt("subTableID"); } + + public static ModTypeTableEntry rollTable(int modTablwe, int roll) { + + ModTypeTableEntry modTypeTableEntry = null; + List modTypeTableEntryList; + + modTypeTableEntryList = LootManager._modTypeTables.get(modTablwe); + + for (ModTypeTableEntry iteration : modTypeTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + modTypeTableEntry = iteration; + + return modTypeTableEntry; + } } diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index c9c3ebb4..47dbd4ed 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -15,10 +15,7 @@ import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; public class LootTable { - - private static final ConcurrentHashMap genTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap itemTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); +private static final ConcurrentHashMap modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap modTypeTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap statRuneChances = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public static boolean initialized = false; @@ -46,54 +43,6 @@ public class LootTable { this.lootTableID = lootTableID; } - public static LootTable getGenTable(int UUID) { - - if (genTables.containsKey(UUID)) - return genTables.get(UUID); - - LootTable lootGroup = new LootTable(UUID); - genTables.put(UUID, lootGroup); - return lootGroup; - } - - public static LootTable getItemTable(int UUID) { - - if (itemTables.containsKey(UUID)) - return itemTables.get(UUID); - - LootTable lootTable = new LootTable(UUID); - itemTables.put(UUID, lootTable); - - return lootTable; - } - - /** - * @return the lootGroups - */ - public static ConcurrentHashMap getGenTables() { - return genTables; - } - - /** - * @return the lootTables - */ - public static ConcurrentHashMap getItemTables() { - return itemTables; - } - - /** - * @return the modTables - */ - public static ConcurrentHashMap getModTables() { - return modTables; - } - - /** - * @return the modGroups - */ - public static ConcurrentHashMap getModTypeTables() { - return modTypeTables; - } public static LootTable getModTypeTable(int UUID) { From 985b327b69c52dc9464c41c20ede5e55880b80b3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 10:16:30 -0400 Subject: [PATCH 78/88] Refactor to install new loot tables. --- src/engine/db/handlers/dbLootHandler.java | 83 ----------- src/engine/devcmd/cmds/SimulateBootyCmd.java | 2 +- src/engine/gameManager/LootManager.java | 136 ++++--------------- 3 files changed, 28 insertions(+), 193 deletions(-) diff --git a/src/engine/db/handlers/dbLootHandler.java b/src/engine/db/handlers/dbLootHandler.java index 36763a58..e34b0a33 100644 --- a/src/engine/db/handlers/dbLootHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -10,7 +10,6 @@ package engine.db.handlers; import engine.gameManager.DbManager; -import engine.gameManager.LootManager; import engine.loot.*; import engine.objects.Item; import org.pmw.tinylog.Logger; @@ -238,86 +237,4 @@ public class dbLootHandler extends dbHandlerBase { } } - public void LOAD_ALL_GENTABLES() { - - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_gentables")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - GenTableRow row = new GenTableRow(rs); - LootManager.AddGenTableRow(rs.getInt("gentable"), row); - } - - } catch (SQLException e) { - Logger.error(e); - } - - Logger.info("read: " + recordsRead); - } - - public void LOAD_ALL_ITEMTABLES() { - - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itemtables")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - recordsRead++; - ItemTableRow row = new ItemTableRow(rs); - LootManager.AddItemTableRow(rs.getInt("itemTable"), row); - } - - } catch (SQLException e) { - Logger.error(e); - } - - Logger.info("read: " + recordsRead); - } - - public void LOAD_ALL_MODTYPES() { - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_modtypetables")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - recordsRead++; - ModTypeTableRow mttr = new ModTypeTableRow(rs); - LootManager.AddModTypeTableRow(rs.getInt("modType"), mttr); - } - - } catch (SQLException e) { - Logger.error(e); - } - Logger.info("read: " + recordsRead); - } - - public void LOAD_ALL_MODTABLES() { - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_modtables")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - recordsRead++; - ModTableRow mtr = new ModTableRow(rs); - LootManager.AddModTableRow(rs.getInt("modTable"), mtr); - } - - } catch (SQLException e) { - Logger.error(e); - } - Logger.info("read: " + recordsRead); - } } diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index adcf47e4..a6696881 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -125,7 +125,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { else output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.genTable + ": " + entry.dropChance * dropRate + newline; - if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager.generalItemTables.containsKey(entry.genTable + 1)) { + if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager._genTables.containsKey(entry.genTable + 1)) { output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.genTable + 1) + ": " + entry.dropChance * dropRate + newline; hotZoneRan = true; } diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 0c0acdb6..b19e5bf6 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -34,12 +34,6 @@ public enum LootManager { public static HashMap> _modTables = new HashMap<>(); public static HashMap> _modTypeTables = new HashMap<>(); - //new tables - public static final HashMap generalItemTables = null; - public static final HashMap itemTables = null; - public static final HashMap modTypeTables = null; - public static final HashMap modTables = null; - // Drop Rates public static float NORMAL_DROP_RATE; @@ -60,12 +54,6 @@ public enum LootManager { _modTables = DbManager.LootQueries.LOAD_MOD_TABLES(); _modTypeTables = DbManager.LootQueries.LOAD_MOD_TYPE_TABLES(); - - DbManager.LootQueries.LOAD_ALL_GENTABLES(); - DbManager.LootQueries.LOAD_ALL_ITEMTABLES(); - DbManager.LootQueries.LOAD_ALL_MODTYPES(); - DbManager.LootQueries.LOAD_ALL_MODTABLES(); - // Cache drop rate values from Config manager. NORMAL_DROP_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); @@ -139,7 +127,7 @@ public enum LootManager { // Only one bite at the hotzone apple per bootyset. if (inHotzone == true && hotzoneWasRan == false) - if (generalItemTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { + if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { GenerateLootDrop(mob, bse.genTable + 1, true); //generate loot drop from hotzone table hotzoneWasRan = true; } @@ -154,28 +142,28 @@ public enum LootManager { public static MobLoot getGenTableItem(int genTableID, Mob mob, Boolean inHotzone) { - if (mob == null || generalItemTables.containsKey(genTableID) == false) + if (mob == null || _genTables.containsKey(genTableID) == false) return null; MobLoot outItem; int genRoll = new Random().nextInt(99) + 1; - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); if (selectedRow == null) return null; int itemTableId = selectedRow.itemTableID; - if (itemTables.containsKey(itemTableId) == false) + if (_itemTables.containsKey(itemTableId) == false) return null; //gets the 1-320 roll for this mob int itemTableRoll = TableRoll(mob.level, inHotzone); - ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(itemTableRoll); + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); if (tableRow == null) return null; @@ -221,69 +209,55 @@ public enum LootManager { private static MobLoot GeneratePrefix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); if (selectedRow == null) return inItem; - ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); - - if (prefixTable == null) - return inItem; - int prefixroll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { - ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); + ModTypeTableEntry prefixTable = ModTypeTableEntry.rollTable(selectedRow.pModTable, prefixroll); - if (prefixModTable == null) - return inItem; + if (prefixTable == null) + return inItem; - ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); + ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, TableRoll(mob.level, inHotzone)); - if (prefixMod == null) - return inItem; + if (prefixMod == null) + return inItem; - if (prefixMod != null && prefixMod.action.length() > 0) { - inItem.setPrefix(prefixMod.action); - inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); - } + if (prefixMod.action.length() > 0) { + inItem.setPrefix(prefixMod.action); + inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); } - //} + return inItem; } private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { - GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); + GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); if (selectedRow == null) return inItem; - int suffixroll = ThreadLocalRandom.current().nextInt(1, 100 + 1); + int suffixRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); + ModTypeTableEntry suffixTable = ModTypeTableEntry.rollTable(selectedRow.sModTable, suffixRoll); if (suffixTable == null) return inItem; - if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { - - ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); - - if (suffixModTable == null) - return inItem; - - ModTableRow suffixMod = suffixModTable.getRowForRange(TableRoll(mob.level, inHotzone)); + ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, TableRoll(mob.level, inHotzone)); - if (suffixMod == null) - return inItem; + if (suffixMod == null) + return inItem; - if (suffixMod != null && suffixMod.action.length() > 0) { - inItem.setSuffix(suffixMod.action); - inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); - } + if (suffixMod.action.length() > 0) { + inItem.setPrefix(suffixMod.action); + inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, true); } + return inItem; } @@ -393,60 +367,4 @@ public enum LootManager { mob.getCharItemManager().addItemToInventory(lootItem); } - public static void AddGenTableRow(int tableID, GenTableRow row) { - - if (!generalItemTables.containsKey(tableID)) { - //create the new table - GenTable gt = new GenTable(); - gt.rows.add(row); - generalItemTables.put(tableID, gt); - } else { - //add row to existing table - GenTable toAdd = generalItemTables.get(tableID); - toAdd.rows.add(row); - } - } - - public static void AddItemTableRow(int tableID, ItemTableRow row) { - - if (!itemTables.containsKey(tableID)) { - //create the new table - ItemTable it = new ItemTable(); - it.rows.add(row); - itemTables.put(tableID, it); - } else { - //add row to existing table - ItemTable toAdd = itemTables.get(tableID); - toAdd.rows.add(row); - } - } - - public static void AddModTypeTableRow(int tableID, ModTypeTableRow row) { - - if (!modTypeTables.containsKey(tableID)) { - //create the new table - ModTypeTable mtt = new ModTypeTable(); - mtt.rows.add(row); - modTypeTables.put(tableID, mtt); - } else { - //add row to existing table - ModTypeTable toAdd = modTypeTables.get(tableID); - toAdd.rows.add(row); - } - } - - public static void AddModTableRow(int tableID, ModTableRow row) { - - if (!modTables.containsKey(tableID)) { - //create the new table - ModTable mt = new ModTable(); - mt.rows.add(row); - modTables.put(tableID, mt); - } else { - //add row to existing table - ModTable toAdd = modTables.get(tableID); - toAdd.rows.add(row); - } - } - -} \ No newline at end of file +} From 6e814c1dcd96b1ccc8e97351a4648f3198c849c7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 10:17:50 -0400 Subject: [PATCH 79/88] Refactor to install new loot tables. --- src/engine/loot/GenTable.java | 26 ------------------------- src/engine/loot/GenTableRow.java | 28 --------------------------- src/engine/loot/ItemTable.java | 29 ---------------------------- src/engine/loot/ItemTableRow.java | 28 --------------------------- src/engine/loot/ModTable.java | 29 ---------------------------- src/engine/loot/ModTableRow.java | 26 ------------------------- src/engine/loot/ModTypeTable.java | 26 ------------------------- src/engine/loot/ModTypeTableRow.java | 24 ----------------------- 8 files changed, 216 deletions(-) delete mode 100644 src/engine/loot/GenTable.java delete mode 100644 src/engine/loot/GenTableRow.java delete mode 100644 src/engine/loot/ItemTable.java delete mode 100644 src/engine/loot/ItemTableRow.java delete mode 100644 src/engine/loot/ModTable.java delete mode 100644 src/engine/loot/ModTableRow.java delete mode 100644 src/engine/loot/ModTypeTable.java delete mode 100644 src/engine/loot/ModTypeTableRow.java diff --git a/src/engine/loot/GenTable.java b/src/engine/loot/GenTable.java deleted file mode 100644 index af2a97e4..00000000 --- a/src/engine/loot/GenTable.java +++ /dev/null @@ -1,26 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.util.ArrayList; - -public class GenTable { - public ArrayList rows = new ArrayList(); - - public GenTableRow getRowForRange(int roll) { - - GenTableRow outRow = null; - - for (GenTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - outRow = iteration; - - return outRow; - } -} diff --git a/src/engine/loot/GenTableRow.java b/src/engine/loot/GenTableRow.java deleted file mode 100644 index 85443caa..00000000 --- a/src/engine/loot/GenTableRow.java +++ /dev/null @@ -1,28 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class GenTableRow { - public int minRoll; - public int maxRoll; - public int itemTableID; - public int pModTable; - public int sModTable; - - public GenTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.itemTableID = rs.getInt("itemTableID"); - this.pModTable = rs.getInt("pModTableID"); - this.sModTable = rs.getInt("sModTableID"); - } -} diff --git a/src/engine/loot/ItemTable.java b/src/engine/loot/ItemTable.java deleted file mode 100644 index b3a248f2..00000000 --- a/src/engine/loot/ItemTable.java +++ /dev/null @@ -1,29 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.util.ArrayList; - -public class ItemTable { - public ArrayList rows = new ArrayList<>(); - - public ItemTableRow getRowForRange(int roll) { - - if (roll > 320) - roll = 320; - - ItemTableRow outRow = null; - - for (ItemTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - outRow = iteration; - - return outRow; - } -} diff --git a/src/engine/loot/ItemTableRow.java b/src/engine/loot/ItemTableRow.java deleted file mode 100644 index 9655e287..00000000 --- a/src/engine/loot/ItemTableRow.java +++ /dev/null @@ -1,28 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class ItemTableRow { - public int minRoll; - public int maxRoll; - public int cacheID; - public int minSpawn; - public int maxSpawn; - - public ItemTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.cacheID = rs.getInt("itemBaseUUID"); - this.minSpawn = rs.getInt("minSpawn"); - this.maxSpawn = rs.getInt("maxSpawn"); - } -} diff --git a/src/engine/loot/ModTable.java b/src/engine/loot/ModTable.java deleted file mode 100644 index 2dee3c86..00000000 --- a/src/engine/loot/ModTable.java +++ /dev/null @@ -1,29 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.util.ArrayList; - -public class ModTable { - public ArrayList rows = new ArrayList(); - - public ModTableRow getRowForRange(int roll) { - - if (roll > 320) - roll = 320; - - ModTableRow outRow = null; - - for (ModTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - outRow = iteration; - - return outRow; - } -} diff --git a/src/engine/loot/ModTableRow.java b/src/engine/loot/ModTableRow.java deleted file mode 100644 index 0c3927a4..00000000 --- a/src/engine/loot/ModTableRow.java +++ /dev/null @@ -1,26 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class ModTableRow { - public int minRoll; - public int maxRoll; - public String action; - public int level; - - public ModTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.action = rs.getString("action"); - this.level = rs.getInt("level"); - } -} diff --git a/src/engine/loot/ModTypeTable.java b/src/engine/loot/ModTypeTable.java deleted file mode 100644 index 0e40e395..00000000 --- a/src/engine/loot/ModTypeTable.java +++ /dev/null @@ -1,26 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.util.ArrayList; - -public class ModTypeTable { - public ArrayList rows = new ArrayList<>(); - - public ModTypeTableRow getRowForRange(int roll) { - - ModTypeTableRow outRow = null; - - for (ModTypeTableRow iteration : this.rows) - if (roll >= iteration.minRoll && roll <= iteration.maxRoll) - return iteration; - - return outRow; - } -} diff --git a/src/engine/loot/ModTypeTableRow.java b/src/engine/loot/ModTypeTableRow.java deleted file mode 100644 index 7c395ed0..00000000 --- a/src/engine/loot/ModTypeTableRow.java +++ /dev/null @@ -1,24 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - -package engine.loot; - -import java.sql.ResultSet; -import java.sql.SQLException; - -public class ModTypeTableRow { - public int minRoll; - public int maxRoll; - public int modTableID; - - public ModTypeTableRow(ResultSet rs) throws SQLException { - this.minRoll = rs.getInt("minRoll"); - this.maxRoll = rs.getInt("maxRoll"); - this.modTableID = rs.getInt("subTableID"); - } -} From 71875059b651d302cc47632520edf4f96e66eaa9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 10:52:37 -0400 Subject: [PATCH 80/88] Update table names for new convention. --- src/engine/db/handlers/dbLootHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/db/handlers/dbLootHandler.java b/src/engine/db/handlers/dbLootHandler.java index e34b0a33..f44dfb3e 100644 --- a/src/engine/db/handlers/dbLootHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -36,7 +36,7 @@ public class dbLootHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_gentables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_gen`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -44,7 +44,7 @@ public class dbLootHandler extends dbHandlerBase { recordsRead++; - genTableID = rs.getInt("bootySet"); + genTableID = rs.getInt("genTable"); genTableEntry = new GenTableEntry(rs); if (genTables.get(genTableID) == null) { @@ -75,7 +75,7 @@ public class dbLootHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itemTables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_item`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -114,7 +114,7 @@ public class dbLootHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_modTables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_mod`")) { ResultSet rs = preparedStatement.executeQuery(); @@ -122,7 +122,7 @@ public class dbLootHandler extends dbHandlerBase { recordsRead++; - modTableID = rs.getInt("itemTable"); + modTableID = rs.getInt("modTable"); modTableEntry = new ModTableEntry(rs); if (modTables.get(modTableID) == null) { @@ -153,7 +153,7 @@ public class dbLootHandler extends dbHandlerBase { int recordsRead = 0; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_modtypeTables`")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_modtype`")) { ResultSet rs = preparedStatement.executeQuery(); From b84be6eea8527326ef5b8cc5e26784f56f681c05 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 12:12:52 -0400 Subject: [PATCH 81/88] Last vestiges of old loot system removed. --- src/engine/devcmd/cmds/MBDropCmd.java | 132 --------------- src/engine/gameManager/DevCmdManager.java | 1 - src/engine/objects/ItemFactory.java | 190 +++------------------- src/engine/objects/LootRow.java | 63 ------- src/engine/objects/LootTable.java | 77 --------- src/engine/server/world/WorldServer.java | 1 - 6 files changed, 19 insertions(+), 445 deletions(-) delete mode 100644 src/engine/devcmd/cmds/MBDropCmd.java delete mode 100644 src/engine/objects/LootRow.java delete mode 100644 src/engine/objects/LootTable.java diff --git a/src/engine/devcmd/cmds/MBDropCmd.java b/src/engine/devcmd/cmds/MBDropCmd.java deleted file mode 100644 index 5e5bfbe8..00000000 --- a/src/engine/devcmd/cmds/MBDropCmd.java +++ /dev/null @@ -1,132 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.devcmd.AbstractDevCmd; -import engine.objects.AbstractGameObject; -import engine.objects.ItemBase; -import engine.objects.LootTable; -import engine.objects.PlayerCharacter; - -/** - * @author Eighty - */ -public class MBDropCmd extends AbstractDevCmd { - - public MBDropCmd() { - super("mbdrop"); - } - - @Override - protected void _doCmd(PlayerCharacter pcSender, String[] args, - AbstractGameObject target) { - String newline = "\r\n "; - if (args.length != 1) { - this.sendUsage(pcSender); - this.sendHelp(pcSender); - return; - } - - String output = ""; - switch (args[0].toLowerCase()) { - case "clear": - - LootTable.contractCount = 0; - LootTable.dropCount = 0; - LootTable.glassCount = 0; - LootTable.runeCount = 0; - LootTable.rollCount = 0; - LootTable.resourceCount = 0; - - LootTable.contractDroppedMap.clear(); - LootTable.glassDroppedMap.clear(); - LootTable.itemsDroppedMap.clear(); - LootTable.resourceDroppedMap.clear(); - LootTable.runeDroppedMap.clear(); - break; - case "all": - output = LootTable.dropCount + " items - ITEM NAME : DROP COUNT" + newline; - for (ItemBase ib : LootTable.itemsDroppedMap.keySet()) { - - int dropCount = LootTable.itemsDroppedMap.get(ib); - output += ib.getName() + " : " + dropCount + newline; - - } - break; - case "resource": - output = LootTable.resourceCount + " Resources - ITEM NAME : DROP COUNT" + newline; - for (ItemBase ib : LootTable.resourceDroppedMap.keySet()) { - - int dropCount = LootTable.resourceDroppedMap.get(ib); - output += ib.getName() + " : " + dropCount + newline; - - } - - break; - case "rune": - - output = LootTable.runeCount + " Runes - ITEM NAME : DROP COUNT" + newline; - for (ItemBase ib : LootTable.runeDroppedMap.keySet()) { - - int dropCount = LootTable.runeDroppedMap.get(ib); - output += ib.getName() + " : " + dropCount + newline; - - } - break; - case "contract": - - output = LootTable.contractCount + " Contracts - ITEM NAME : DROP COUNT" + newline; - for (ItemBase ib : LootTable.contractDroppedMap.keySet()) { - - int dropCount = LootTable.contractDroppedMap.get(ib); - output += ib.getName() + " : " + dropCount + newline; - - - } - break; - - case "glass": - - output = LootTable.glassCount + " Glass - ITEM NAME : DROP COUNT" + newline; - for (ItemBase ib : LootTable.glassDroppedMap.keySet()) { - - int dropCount = LootTable.glassDroppedMap.get(ib); - output += ib.getName() + " : " + dropCount + newline; - } - break; - - case "chance": - float chance = (float) LootTable.dropCount / (float) LootTable.rollCount * 100; - output = LootTable.dropCount + " out of " + LootTable.rollCount + " items Dropped. chance = " + chance + '%'; - - break; - - default: - this.sendUsage(pcSender); - this.sendHelp(pcSender); - return; - } - - this.throwbackInfo(pcSender, output); - - - } - - @Override - protected String _getUsageString() { - return "' /mbdrop all/resource/rune/contract/glass/chance/clear"; - } - - @Override - protected String _getHelpString() { - return "Lists drops for server since a reboot. All lists all items and drops. chance is the overall chance items drop from mobs on server. (not including Equipment)"; - } - -} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index e1163ccf..47ae6cda 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -128,7 +128,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new SetForceRenameCityCmd()); DevCmdManager.registerDevCmd(new GotoObj()); DevCmdManager.registerDevCmd(new convertLoc()); - DevCmdManager.registerDevCmd(new MBDropCmd()); DevCmdManager.registerDevCmd(new AuditHeightMapCmd()); DevCmdManager.registerDevCmd(new UnloadFurnitureCmd()); DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd()); diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index a6ca94d5..c54469d8 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -14,6 +14,8 @@ import engine.Enum.ItemContainerType; import engine.Enum.ItemType; import engine.Enum.OwnerType; import engine.gameManager.*; +import engine.loot.ModTableEntry; +import engine.loot.ModTypeTableEntry; import engine.net.ItemProductionManager; import engine.net.ItemQueue; import engine.net.client.ClientConnection; @@ -648,11 +650,11 @@ public class ItemFactory { byte itemModTable; int prefixMod = 0; int suffixMod = 0; - LootTable prefixLootTable; - LootTable suffixLootTable; - String suffix = ""; String prefix = ""; - MobLoot toRoll; + String suffix = ""; + + ModTableEntry prefixEntry = null; + ModTableEntry suffixEntry = null; ItemBase ib = ItemBase.getItemBase(itemID); @@ -694,187 +696,33 @@ public class ItemFactory { return null; } - prefixLootTable = LootTable.getModTypeTable(prefixMod); - suffixLootTable = LootTable.getModTypeTable(suffixMod); - - if (prefixLootTable == null || suffixLootTable == null) - return null; + ModTypeTableEntry prefixTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + ModTypeTableEntry suffixTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - int rollPrefix = ThreadLocalRandom.current().nextInt(100); + int rollPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); if (rollPrefix < 80) { - int randomPrefix = ThreadLocalRandom.current().nextInt(100) + 1; - LootRow prefixLootRow = prefixLootTable.getLootRow(randomPrefix); - - if (prefixLootRow != null) { - LootTable prefixTypeTable = LootTable.getModTable(prefixLootRow.getValueOne()); - - int minRoll = (int) ((calculatedMobLevel - 5) * 5); - int maxRoll = (int) ((calculatedMobLevel + 15) * 5); - - if (minRoll < (int) prefixTypeTable.minRoll) - minRoll = (int) prefixTypeTable.minRoll; - - if (maxRoll < minRoll) - maxRoll = minRoll; - if (maxRoll > prefixTypeTable.maxRoll) - maxRoll = (int) prefixTypeTable.maxRoll; + int randomPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); + prefixEntry = ModTableEntry.rollTable(prefixTable.modTableID, randomPrefix); - if (maxRoll > 320) - maxRoll = 320; + if (prefixEntry != null) + prefix = prefixEntry.action; - int randomPrefix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? - - if (randomPrefix1 < prefixTypeTable.minRoll) - randomPrefix1 = (int) prefixTypeTable.minRoll; - - if (randomPrefix1 > prefixTypeTable.maxRoll) - randomPrefix1 = (int) prefixTypeTable.maxRoll; - - LootRow prefixTypelootRow = prefixTypeTable.getLootRow(randomPrefix1); - - if (prefixTypelootRow == null) - prefixTypelootRow = prefixTypeTable.getLootRow((int) ((prefixTypeTable.maxRoll + prefixTypeTable.minRoll) * .05f)); - - if (prefixTypelootRow != null) { - prefix = prefixTypelootRow.getAction(); - } - } } - int rollSuffix = ThreadLocalRandom.current().nextInt(100); + int rollSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); if (rollSuffix < 80) { - int randomSuffix = ThreadLocalRandom.current().nextInt(100) + 1; - LootRow suffixLootRow = suffixLootTable.getLootRow(randomSuffix); - - if (suffixLootRow != null) { - - LootTable suffixTypeTable = LootTable.getModTable(suffixLootRow.getValueOne()); - - if (suffixTypeTable != null) { - int minRoll = (int) ((calculatedMobLevel - 5) * 5); - int maxRoll = (int) ((calculatedMobLevel + 15) * 5); - - if (minRoll < (int) suffixTypeTable.minRoll) - minRoll = (int) suffixTypeTable.minRoll; - - if (maxRoll < minRoll) - maxRoll = minRoll; - - if (maxRoll > suffixTypeTable.maxRoll) - maxRoll = (int) suffixTypeTable.maxRoll; - - if (maxRoll > 320) - maxRoll = 320; - - int randomSuffix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? - - if (randomSuffix1 < suffixTypeTable.minRoll) - randomSuffix1 = (int) suffixTypeTable.minRoll; - - if (randomSuffix1 > suffixTypeTable.maxRoll) - randomSuffix1 = (int) suffixTypeTable.maxRoll; - - LootRow suffixTypelootRow = suffixTypeTable.getLootRow(randomSuffix1); - - if (suffixTypelootRow != null) { - suffix = suffixTypelootRow.getAction(); - } - } - } - } - - if (prefix.isEmpty() && suffix.isEmpty()) { + int randomSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); + suffixEntry = ModTableEntry.rollTable(suffixTable.modTableID, randomSuffix); - rollPrefix = ThreadLocalRandom.current().nextInt(100); - - if (rollPrefix < 50) { - - int randomPrefix = ThreadLocalRandom.current().nextInt(100) + 1; - LootRow prefixLootRow = prefixLootTable.getLootRow(randomPrefix); - - if (prefixLootRow != null) { - - LootTable prefixTypeTable = LootTable.getModTable(prefixLootRow.getValueOne()); - - int minRoll = (int) ((calculatedMobLevel) * 5); - int maxRoll = (int) ((calculatedMobLevel + 15) * 5); - - if (minRoll < (int) prefixTypeTable.minRoll) - minRoll = (int) prefixTypeTable.minRoll; - - if (maxRoll < minRoll) - maxRoll = minRoll; - - if (maxRoll > prefixTypeTable.maxRoll) - maxRoll = (int) prefixTypeTable.maxRoll; - - if (maxRoll > 320) - maxRoll = 320; - - int randomPrefix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? - - if (randomPrefix1 < prefixTypeTable.minRoll) - randomPrefix1 = (int) prefixTypeTable.minRoll; - - if (randomPrefix1 > prefixTypeTable.maxRoll) - randomPrefix1 = (int) prefixTypeTable.maxRoll; - - LootRow prefixTypelootRow = prefixTypeTable.getLootRow(randomPrefix1); - - if (prefixTypelootRow == null) - prefixTypelootRow = prefixTypeTable.getLootRow((int) ((prefixTypeTable.maxRoll + prefixTypeTable.minRoll) * .05f)); - - if (prefixTypelootRow != null) { - prefix = prefixTypelootRow.getAction(); - } - } - } else { - int randomSuffix = ThreadLocalRandom.current().nextInt(100) + 1; - LootRow suffixLootRow = suffixLootTable.getLootRow(randomSuffix); - - if (suffixLootRow != null) { - - LootTable suffixTypeTable = LootTable.getModTable(suffixLootRow.getValueOne()); - - if (suffixTypeTable != null) { - - int minRoll = (int) ((calculatedMobLevel) * 5); - int maxRoll = (int) ((calculatedMobLevel + 15) * 5); - - if (minRoll < (int) suffixTypeTable.minRoll) - minRoll = (int) suffixTypeTable.minRoll; - - if (maxRoll < minRoll) - maxRoll = minRoll; - - if (maxRoll > suffixTypeTable.maxRoll) - maxRoll = (int) suffixTypeTable.maxRoll; - - if (maxRoll > 320) - maxRoll = 320; - - int randomSuffix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? - - if (randomSuffix1 < suffixTypeTable.minRoll) - randomSuffix1 = (int) suffixTypeTable.minRoll; - - if (randomSuffix1 > suffixTypeTable.maxRoll) - randomSuffix1 = (int) suffixTypeTable.maxRoll; - - LootRow suffixTypelootRow = suffixTypeTable.getLootRow(randomSuffix1); - - if (suffixTypelootRow != null) - suffix = suffixTypelootRow.getAction(); - } - } - } + if (suffixEntry != null) + suffix = suffixEntry.action; } - toRoll = ItemFactory.produceRandomRoll(vendor, pc, prefix, suffix, itemID); + MobLoot toRoll = ItemFactory.produceRandomRoll(vendor, pc, prefix, suffix, itemID); if (toRoll == null) return null; diff --git a/src/engine/objects/LootRow.java b/src/engine/objects/LootRow.java deleted file mode 100644 index 4e99ae3d..00000000 --- a/src/engine/objects/LootRow.java +++ /dev/null @@ -1,63 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -public class LootRow { - - private int valueOne; - private int valueTwo; - private int valueThree; - private String action; - - - /** - * Generic Constructor - */ - public LootRow(int valueOne, int valueTwo, int valueThree, String action) { - this.valueOne = valueOne; - this.valueTwo = valueTwo; - this.valueThree = valueThree; - this.action = action; - - } - - public int getValueOne() { - return this.valueOne; - } - - public void setValueOne(int value) { - this.valueOne = value; - } - - public int getValueTwo() { - return this.valueTwo; - } - - public void setValueTwo(int value) { - this.valueTwo = value; - } - - public int getValueThree() { - return this.valueThree; - } - - public void setValueThree(int value) { - this.valueThree = value; - } - - public String getAction() { - return this.action; - } - - public void setAction(String value) { - this.action = value; - } - -} diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java deleted file mode 100644 index 47dbd4ed..00000000 --- a/src/engine/objects/LootTable.java +++ /dev/null @@ -1,77 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.server.MBServerStatics; - -import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; - -public class LootTable { -private static final ConcurrentHashMap modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap modTypeTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap statRuneChances = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - public static boolean initialized = false; - public static HashMap itemsDroppedMap = new HashMap<>(); - public static HashMap resourceDroppedMap = new HashMap<>(); - public static HashMap runeDroppedMap = new HashMap<>(); - public static HashMap contractDroppedMap = new HashMap<>(); - public static HashMap glassDroppedMap = new HashMap<>(); - public static int rollCount = 0; - public static int dropCount = 0; - public static int runeCount = 0; - public static int contractCount = 0; - public static int resourceCount = 0; - public static int glassCount = 0; - private final ConcurrentHashMap lootTable = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - public float minRoll = 320; - public float maxRoll = 1; - public int lootTableID = 0; - - - /** - * Generic Constructor - */ - public LootTable(int lootTableID) { - this.lootTableID = lootTableID; - } - - - public static LootTable getModTypeTable(int UUID) { - - if (modTypeTables.containsKey(UUID)) - return modTypeTables.get(UUID); - - LootTable modTable = new LootTable(UUID); - modTypeTables.put(UUID, modTable); - - return modTable; - } - - public static LootTable getModTable(int UUID) { - - if (modTables.containsKey(UUID)) - return modTables.get(UUID); - - LootTable modTypeTable = new LootTable(UUID); - modTables.put(UUID, modTypeTable); - - return modTypeTable; - } - - public LootRow getLootRow(int probability) { - - if (lootTable.containsKey(probability)) - return lootTable.get(probability); - - return null; - } - -} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 9ac027e6..cdcf6f90 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -504,7 +504,6 @@ public class WorldServer { Logger.info("Bootstrap time was " + boottime); bootTime = LocalDateTime.now(); - LootTable.initialized = true; Logger.info("Running garbage collection..."); System.gc(); From a5ab912ffa4977a86ad4f8a9ef40e066b3ed8247 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 13:36:16 -0400 Subject: [PATCH 82/88] Method for adjusted table rolls based on mpc level. --- src/engine/objects/ItemFactory.java | 33 +++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index c54469d8..a4ca24aa 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -696,15 +696,22 @@ public class ItemFactory { return null; } - ModTypeTableEntry prefixTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - ModTypeTableEntry suffixTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + // Roll on the tables for this vendor + + ModTypeTableEntry prefixTypeTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + ModTypeTableEntry suffixTypeTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + + // Sanity check. + + if (prefixTypeTable == null || suffixTypeTable == null) + return null; int rollPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); if (rollPrefix < 80) { - int randomPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - prefixEntry = ModTableEntry.rollTable(prefixTable.modTableID, randomPrefix); + int randomPrefix = getAdjustedRollForNPC((int) calculatedMobLevel, prefixTypeTable.minRoll, prefixTypeTable.maxRoll); + prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); if (prefixEntry != null) prefix = prefixEntry.action; @@ -715,8 +722,8 @@ public class ItemFactory { if (rollSuffix < 80) { - int randomSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - suffixEntry = ModTableEntry.rollTable(suffixTable.modTableID, randomSuffix); + int randomSuffix = getAdjustedRollForNPC((int) calculatedMobLevel, suffixTypeTable.minRoll, suffixTypeTable.maxRoll); + suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); if (suffixEntry != null) suffix = suffixEntry.action; @@ -763,6 +770,20 @@ public class ItemFactory { return toRoll; } + private static int getAdjustedRollForNPC(int npcLevel, int minRoll, int maxRoll) { + int randomRoll; + + int minValue = (npcLevel - 5) * 5; + int maxValue = (npcLevel + 15) * 5; + + minValue = Math.max(minRoll, Math.min(maxRoll, minValue)); + maxValue = Math.max(minRoll, Math.min(maxRoll, maxValue)); + + randomRoll = ThreadLocalRandom.current().nextInt(minValue, maxValue + 1); //Does not return Max, but does return min? + + return randomRoll; + } + public static MobLoot produceRandomRoll(NPC npc, PlayerCharacter pc, String prefixString, String suffixString, int itemID) { boolean useWarehouse = false; From b05c4a91e5ed0d192b057d3a0292853c8e1f75e2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 13:53:16 -0400 Subject: [PATCH 83/88] Using LootManager for forge scaling. --- src/engine/gameManager/LootManager.java | 2 +- src/engine/objects/ItemFactory.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index b19e5bf6..56b19d59 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -261,7 +261,7 @@ public enum LootManager { return inItem; } - private static int TableRoll(int mobLevel, Boolean inHotzone) { + public static int TableRoll(int mobLevel, Boolean inHotzone) { if (mobLevel > 65) mobLevel = 65; diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index a4ca24aa..6eaa0987 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -710,7 +710,7 @@ public class ItemFactory { if (rollPrefix < 80) { - int randomPrefix = getAdjustedRollForNPC((int) calculatedMobLevel, prefixTypeTable.minRoll, prefixTypeTable.maxRoll); + int randomPrefix = LootManager.TableRoll((int) calculatedMobLevel, false); prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); if (prefixEntry != null) @@ -722,7 +722,7 @@ public class ItemFactory { if (rollSuffix < 80) { - int randomSuffix = getAdjustedRollForNPC((int) calculatedMobLevel, suffixTypeTable.minRoll, suffixTypeTable.maxRoll); + int randomSuffix = LootManager.TableRoll((int) calculatedMobLevel, false); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); if (suffixEntry != null) From 339b6c5025a3e695d11755eb934d3aa008589871 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 13:55:22 -0400 Subject: [PATCH 84/88] Using LootManager for forge scaling. --- src/engine/objects/ItemFactory.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 6eaa0987..8469adbb 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -667,15 +667,6 @@ public class ItemFactory { return null; } - float calculatedMobLevel; - calculatedMobLevel = vendor.getLevel(); - - if (calculatedMobLevel < 16) - calculatedMobLevel = 16; - - if (calculatedMobLevel > 49) - calculatedMobLevel = 49; - itemModTable = (byte) ib.getModTable(); if (!vendor.getItemModTable().contains(itemModTable)) { @@ -710,7 +701,7 @@ public class ItemFactory { if (rollPrefix < 80) { - int randomPrefix = LootManager.TableRoll((int) calculatedMobLevel, false); + int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false); prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); if (prefixEntry != null) @@ -722,7 +713,7 @@ public class ItemFactory { if (rollSuffix < 80) { - int randomSuffix = LootManager.TableRoll((int) calculatedMobLevel, false); + int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); if (suffixEntry != null) From 557292a56d318985087e5aae5413d204cfd6cd87 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 14:31:33 -0400 Subject: [PATCH 85/88] Removed unused code. --- src/engine/objects/ItemFactory.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 8469adbb..a00e354e 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -761,20 +761,6 @@ public class ItemFactory { return toRoll; } - private static int getAdjustedRollForNPC(int npcLevel, int minRoll, int maxRoll) { - int randomRoll; - - int minValue = (npcLevel - 5) * 5; - int maxValue = (npcLevel + 15) * 5; - - minValue = Math.max(minRoll, Math.min(maxRoll, minValue)); - maxValue = Math.max(minRoll, Math.min(maxRoll, maxValue)); - - randomRoll = ThreadLocalRandom.current().nextInt(minValue, maxValue + 1); //Does not return Max, but does return min? - - return randomRoll; - } - public static MobLoot produceRandomRoll(NPC npc, PlayerCharacter pc, String prefixString, String suffixString, int itemID) { boolean useWarehouse = false; From e382ba2b9ab0b60413e3fffad5b342af4277e34f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 15:00:18 -0400 Subject: [PATCH 86/88] Always at least one stat rolled. --- src/engine/objects/ItemFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index a00e354e..ba120beb 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -711,7 +711,7 @@ public class ItemFactory { int rollSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (rollSuffix < 80) { + if (rollSuffix < 80 || prefixEntry == null) { int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); From a392c5213cc0a67e1359824ed2e803df9afa81a6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 7 Aug 2023 15:52:50 -0400 Subject: [PATCH 87/88] Method cleanup. --- src/engine/objects/ItemFactory.java | 37 +++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index ba120beb..34b06cb0 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -646,7 +646,7 @@ public class ItemFactory { } - public static Item randomRoll(NPC vendor, PlayerCharacter pc, int itemsToRoll, int itemID) { + public static Item randomRoll(NPC vendor, PlayerCharacter playerCharacter, int itemsToRoll, int itemBaseID) { byte itemModTable; int prefixMod = 0; int suffixMod = 0; @@ -656,28 +656,34 @@ public class ItemFactory { ModTableEntry prefixEntry = null; ModTableEntry suffixEntry = null; - ItemBase ib = ItemBase.getItemBase(itemID); + ItemBase ib = ItemBase.getItemBase(itemBaseID); if (ib == null) return null; if (!vendor.getCharItemManager().hasRoomInventory(ib.getWeight())) { - if (pc != null) - ChatManager.chatSystemInfo(pc, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full."); + + if (playerCharacter != null) + ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full."); + return null; } itemModTable = (byte) ib.getModTable(); if (!vendor.getItemModTable().contains(itemModTable)) { - if (pc != null) - ErrorPopupMsg.sendErrorPopup(pc, 59); + + if (playerCharacter != null) + ErrorPopupMsg.sendErrorPopup(playerCharacter, 59); + 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)); } @@ -711,6 +717,9 @@ public class ItemFactory { 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. + if (rollSuffix < 80 || prefixEntry == null) { int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); @@ -720,7 +729,7 @@ public class ItemFactory { suffix = suffixEntry.action; } - MobLoot toRoll = ItemFactory.produceRandomRoll(vendor, pc, prefix, suffix, itemID); + MobLoot toRoll = ItemFactory.produceRandomRoll(vendor, playerCharacter, prefix, suffix, itemBaseID); if (toRoll == null) return null; @@ -739,9 +748,10 @@ public class ItemFactory { } // No job is submitted, as object's upgradetime field - // is used to determin whether or not an object has - // compelted rolling. The game object exists previously - // to this, not when 'compelte' is pressed. + // is used to determine whether an object has + // completed rolling. The game object exists previously + // to this, not when 'complete' is pressed. + long upgradeTime = System.currentTimeMillis() + (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); DateTime dateTime = new DateTime(); @@ -750,14 +760,17 @@ public class ItemFactory { int playerID = 0; - if (pc != null) - playerID = pc.getObjectUUID(); + if (playerCharacter != null) + playerID = playerCharacter.getObjectUUID(); + DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getItemBaseID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID); + ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getItemBaseID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID); pi.setProducedItemID(toRoll.getObjectUUID()); pi.setAmount(itemsToRoll); ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); ItemProductionManager.send(produced); + return toRoll; } From 6c255323fb2fd9832eed7d1006679e0f501143f4 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 7 Aug 2023 22:06:45 -0500 Subject: [PATCH 88/88] vendors now require ranks to roll high tier items --- src/engine/objects/NPC.java | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index e4851196..ae21de63 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1310,20 +1310,47 @@ public class NPC extends AbstractCharacter { if (this.canRoll == null) { this.canRoll = DbManager.ItemQueries.GET_ITEMS_FOR_VENDOR(this.vendorID); - + } + HashSet fullItemList = this.canRoll; + HashSet returnIDs = new HashSet<>(); + short maxSkill = 25; + switch(this.getRank()){ + case 1: + maxSkill = 25; + break; + case 2: + maxSkill = 50; + break; + case 3: + case 4: + maxSkill = 75; + break; + case 5: + case 6: + maxSkill = 100; + break; + case 7: + maxSkill = 110; + break; + } + for(Integer itemID : fullItemList){ + if(ItemBase.getItemBase(itemID).getPercentRequired() <= maxSkill){ + returnIDs.add(itemID); + } + } if (this.contract.getVendorID() == 102) { for (int i = 0; i < this.getRank(); i++) { int subID = i + 1; - this.canRoll.add(910010 + subID); + returnIDs.add(910010 + subID); } if (this.getRank() == 7) - this.canRoll.add(910018); + returnIDs.add(910018); } - } + //} - return this.canRoll; + return returnIDs; } public int getRollingTimeInSeconds(int itemID) {