From c08a93e85dfc10bba582abb00af81a50fc7c5468 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 16 Feb 2024 22:21:40 -0600 Subject: [PATCH] Enchantment Exploring --- src/engine/gameManager/LootManager.java | 114 ++++++++++++++++++++++-- src/engine/objects/ItemBase.java | 105 +++++++++++++++++++++- 2 files changed, 211 insertions(+), 8 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 0760b057..5e743769 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -112,9 +112,22 @@ public enum LootManager { case "LOOT": if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) GenerateLootDrop(mob, bse.genTable); //generate normal loot drop - if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) { - if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { - GenerateLootDrop(mob, bse.genTable + 1); //generate loot drop from hotzone table + int extraRoll = ThreadLocalRandom.current().nextInt(1,20000); + if(extraRoll == 1000){//0.005% chance + MobLoot extraLoot = null; + int extraItemRoll = ThreadLocalRandom.current().nextInt(1,101); + if(extraItemRoll >= 1 && extraItemRoll <= 47){//0.00235% chance per mob killed or 1 in 425 + extraLoot = tryForContract(bse.genTable,mob); + } + if(extraItemRoll >= 48 && extraItemRoll <= 94){//0.00235% chance per mob killed or 1 in 425 + extraLoot = tryForStatRune(bse.genTable,mob); + } + if(extraItemRoll > 94){//0.0003% chance per mob killed or 1 in 3333 + extraLoot = tryForGlass(mob); + } + if(extraLoot != null){ + extraLoot.setIsID(true); + mob.getCharItemManager().addItemToInventory(extraLoot); } } break; @@ -314,7 +327,6 @@ public enum LootManager { public static void GenerateEquipmentDrop(Mob mob) { //do equipment here - int dropCount = 0; if (mob.getEquip() != null) for (MobEquipment me : mob.getEquip().values()) { @@ -345,12 +357,18 @@ public enum LootManager { } MobLoot ml = new MobLoot(mob, genericIB, false); - if (ml != null && dropCount < 1) { + if (ml != null) { ml.setIsID(true); ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); + + if(ml.getItemBase().isVorg()) { + ml.clearEnchantments(); + for (String enchant : ml.getItemBase().getCustomEnchants()) + ml.addPermanentEnchantment(enchant, 40); + + ml.setName(ml.getItemBase().getName()); + } mob.getCharItemManager().addItemToInventory(ml); - dropCount = 1; - //break; // Exit on first successful roll. } } } @@ -453,4 +471,86 @@ public enum LootManager { itemMan.addItemToInventory(playerWinnings); itemMan.updateInventory(); } + + public static MobLoot tryForContract(int tableID, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, 99, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(190,321));// 1 in 425 mobs + + MobLoot outItem = null; + + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null){ + return outItem; + } + + return null; + } + public static MobLoot tryForStatRune(int tableID, Mob mob){ + GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, 96, 1.0f); + if (selectedRow == null) + return null; + + int itemTableId = selectedRow.itemTableID; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321));//76.5% chance for stat rune or 1 in 750 mobs + + MobLoot outItem = null; + + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null){ + return outItem; + } + return null; + } + public static MobLoot tryForGlass(Mob mob){ + int itemTableId = 126; + + if (_itemTables.containsKey(itemTableId) == false) + return null; + + ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, ThreadLocalRandom.current().nextInt(1,321));//30.9% chance to get glass or 1 in 4362 mobs + + MobLoot outItem = null; + + if (tableRow == null) + return null; + + int itemUUID = tableRow.cacheID; + + if (itemUUID == 0) + return null; + + outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); + if(outItem != null){ + return outItem; + } + return null; + } } diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index ad5ff347..1acde538 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -155,7 +155,9 @@ public class ItemBase { } initBakedInStats(); initializeHashes(); - + if (this.isVorg()) { + removeBakedInStats(); + } } public static void addToCache(ItemBase itemBase) { @@ -347,6 +349,10 @@ public class ItemBase { return this.bakedInStats; } + public void removeBakedInStats(){ + this.bakedInStats.clear(); + } + //returns power tokens granted when using item, such as scrolls and potions public HashMap getUsedStats() { return this.usedStats; @@ -919,4 +925,101 @@ public class ItemBase { public boolean isVorg(){ return LootManager.vorg_ha_uuids.contains(this.uuid) || LootManager.vorg_ma_uuids.contains(this.uuid) || LootManager.vorg_la_uuids.contains(this.uuid) || LootManager.vorg_cloth_uuids.contains(this.uuid); } + public ArrayList getCustomEnchants(){ + ArrayList enchants = new ArrayList<>(); + switch(this.uuid){ + case 27550:// "Vorgrim Auxiliary's Bow" + + break; + case 27560:// "Vorgrim Auxiliary's Dagger" + + break; + case 27570: // "Bellugh Nuathal Hammer" + + break; + case 27580:// "Vorgrim Legionnaire's Axe" + + break; + case 27590:// "Vorgrim Legionnaire's Sword" + + break; + case 27600:// "Staff of the Crimson Circle" + + break; + case 188500:// "Vorgrim Legionnaire's Breastplate" + + break; + case 188510:// "Vorgrim Legionnaire's Armguards" + + break; + case 188520:// "Vorgrim Legionnaire's Legguards" + + break; + case 188530:// "Vorgrim Legionnaire's Gauntlets" + + break; + case 188540:// "Vorgrim Legionnaire's Boots" + + break; + case 188550:// "Vorgrim Legionnaire's Helm" + + break; + case 188700:// "Robe of the Crimson Circle" + + break; + case 188720:// "Hood of the Crimson Circle" + + break; + case 188900:// "Bellugh Nuathal Hauberk" + + break; + case 188910:// "Bellugh Nuathal Sleeves" + + break; + case 188920:// "Bellugh Nuathal Leggings" + + break; + case 188930:// "Bellugh Nuathal Gauntlets" + + break; + case 188940:// "Bellugh Nuathal Boots" + + break; + case 188950:// "Bellugh Nuathal Helmet" + + break; + case 189100:// "Vorgrim Auxiliary's Vest" + + break; + case 189110:// "Vorgrim Auxiliary's Sleeves" + + break; + case 189120:// "Vorgrim Auxiliary's Leggings" + + break; + case 189130:// "Vorgrim Auxiliary's Gloves" + + break; + case 189140:// "Vorgrim Auxiliary's Boots" + + break; + case 189150:// "Vorgrim Auxiliary's Hood" + + break; + case 189500:// "Bellugh Nuathal Shield" + + break; + case 189510:// "Vorgrim Legionnaire's Shield" + + break; + case 189550:// "Gloves of the Crimson Circle" + + break; + case 189560:// "Boots of the Crimson Circle" + + break; + } + + return enchants; + } }