From 9805ee8044b814a23ffd337f13b3a3ca9003c787 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 8 Aug 2023 15:43:24 -0500 Subject: [PATCH 01/10] Random to utilize max + 1 --- 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 56b19d59..c4d8f860 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -174,7 +174,7 @@ public enum LootManager { return null; if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { - int amount = ThreadLocalRandom.current().nextInt(tableRow.maxSpawn - tableRow.minSpawn) + tableRow.minSpawn; + int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); } @@ -279,7 +279,7 @@ public enum LootManager { if (inHotzone) min += mobLevel; - int roll = ThreadLocalRandom.current().nextInt(max - min) + min; + int roll = ThreadLocalRandom.current().nextInt(min, max + 1); return roll; } @@ -297,7 +297,7 @@ public enum LootManager { int high = bse.highGold; int low = bse.lowGold; - int gold = ThreadLocalRandom.current().nextInt(high - low) + low; + int gold = ThreadLocalRandom.current().nextInt(low, high + 1); if (inHotzone == true) gold = (int) (gold * HOTZONE_GOLD_RATE); From 47eb4cd536765678462ae0918d8d700bef4e35ec Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 8 Aug 2023 19:32:39 -0500 Subject: [PATCH 02/10] fate peddler conversion of LootManager methods --- src/engine/gameManager/LootManager.java | 47 ++++++++++--------- .../handlers/ObjectActionMsgHandler.java | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index f73a08b3..69b6f91e 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -141,7 +141,7 @@ public enum LootManager { } } - public static MobLoot getGenTableItem(int genTableID, Mob mob, Boolean inHotzone) { + public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) { if (mob == null || _genTables.containsKey(genTableID) == false) return null; @@ -182,33 +182,27 @@ 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) { - 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) { - Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); - } + if(selectedRow.pModTable != 0){ + try { + outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); + outItem.setIsID(false); + } catch (Exception e) { + Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); + } + } + if(selectedRow.sModTable != 0){ + try { + outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); + outItem.setIsID(false); + } catch (Exception e) { + Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); } } - - if (outItem.getPrefix() != null && outItem.getPrefix().isEmpty() == false) - outItem.setIsID(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) { + private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); @@ -235,7 +229,7 @@ public enum LootManager { return inItem; } - private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { + private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); @@ -367,5 +361,12 @@ public enum LootManager { if (lootItem != null) mob.getCharItemManager().addItemToInventory(lootItem); } + public static void peddleFate(AbstractCharacter character, int giftID){ + int tableID = LootManager._bootySetMap.get(giftID).get(ThreadLocalRandom.current().nextInt(1,LootManager._bootySetMap.get(giftID).size() - 1)).genTable; + MobLoot gamblingResult= getGenTableItem(tableID,character,false); + if(gamblingResult != null){ + gamblingResult.promoteToItem((PlayerCharacter)character); + } + } } diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 510c6bd8..517e4cc4 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -442,7 +442,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { } // Garbage method removed until rewritten. // LootTable.CreateGamblerItem(item, player); - + LootManager.peddleFate(player,item.getItemBaseID()); break; case 30: //water bucket From 57028101082ed1e044d21d4fceba382b277e6d89 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 8 Aug 2023 19:37:42 -0500 Subject: [PATCH 03/10] fate peddler work --- src/engine/gameManager/LootManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 69b6f91e..2c147855 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -362,7 +362,12 @@ public enum LootManager { mob.getCharItemManager().addItemToInventory(lootItem); } public static void peddleFate(AbstractCharacter character, int giftID){ - int tableID = LootManager._bootySetMap.get(giftID).get(ThreadLocalRandom.current().nextInt(1,LootManager._bootySetMap.get(giftID).size() - 1)).genTable; + int tableID = 0; + if(LootManager._bootySetMap.get(giftID) != null) { + tableID = LootManager._bootySetMap.get(giftID).get(ThreadLocalRandom.current().nextInt(1, LootManager._bootySetMap.get(giftID).size() - 1)).genTable; + } else{ + return; + } MobLoot gamblingResult= getGenTableItem(tableID,character,false); if(gamblingResult != null){ gamblingResult.promoteToItem((PlayerCharacter)character); From 04fcdd2545227c1f32bbec0c1ee8b0c061004664 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 8 Aug 2023 19:43:51 -0500 Subject: [PATCH 04/10] disable anniversary gift --- .../handlers/ObjectActionMsgHandler.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 517e4cc4..f85370c3 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -426,20 +426,20 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { case 31: - if (ib.getUUID() == 971012) { - int random = ThreadLocalRandom.current().nextInt(ItemBase.AnniverseryGifts.size()); - int annyID = ItemBase.AnniverseryGifts.get(random); - - ItemBase annyIB = ItemBase.getItemBase(annyID); - if (annyIB != null) { - Item gift = MobLoot.createItemForPlayer(player, annyIB); - if (gift != null) { - itemMan.addItemToInventory(gift); - itemMan.consume(item); - } - } - break; - } + //if (ib.getUUID() == 971012) { + // int random = ThreadLocalRandom.current().nextInt(ItemBase.AnniverseryGifts.size()); + // int annyID = ItemBase.AnniverseryGifts.get(random); + + // ItemBase annyIB = ItemBase.getItemBase(annyID); + // if (annyIB != null) { + // Item gift = MobLoot.createItemForPlayer(player, annyIB); + // if (gift != null) { + // itemMan.addItemToInventory(gift); + // itemMan.consume(item); + // } + // } + // break; + //} // Garbage method removed until rewritten. // LootTable.CreateGamblerItem(item, player); LootManager.peddleFate(player,item.getItemBaseID()); From d53bf0f66e85f0e6d4cd2c9c56edaa9ff35afe87 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 8 Aug 2023 20:37:31 -0500 Subject: [PATCH 05/10] fate peddler work --- src/engine/gameManager/LootManager.java | 53 ++++++++++++++----- .../handlers/ObjectActionMsgHandler.java | 2 +- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 2c147855..ae7dddf3 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -13,6 +13,7 @@ import engine.loot.*; import engine.net.DispatchMessage; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; +import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -148,7 +149,7 @@ public enum LootManager { MobLoot outItem; - int genRoll = new Random().nextInt(99) + 1; + int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); @@ -161,11 +162,14 @@ public enum LootManager { return null; //gets the 1-320 roll for this mob - - int itemTableRoll = TableRoll(mob.level, inHotzone); - + int itemTableRoll = 0; + int objectType = mob.getObjectType().ordinal(); + if(mob.getObjectType().ordinal() == 52) { //52 = player character + itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); + } else{ + itemTableRoll = TableRoll(mob.level, inHotzone); + } ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); - if (tableRow == null) return null; @@ -215,8 +219,13 @@ public enum LootManager { if (prefixTable == null) return inItem; - - ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, TableRoll(mob.level, inHotzone)); + int prefixTableRoll = 0; + if(mob.getObjectType().ordinal() == 52) { + prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); + } else{ + prefixTableRoll = TableRoll(mob.level, inHotzone); + } + ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll); if (prefixMod == null) return inItem; @@ -242,8 +251,13 @@ public enum LootManager { if (suffixTable == null) return inItem; - - ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, TableRoll(mob.level, inHotzone)); + int suffixTableRoll = 0; + if(mob.getObjectType().ordinal() == 52) { + suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); + } else{ + suffixTableRoll = TableRoll(mob.level, inHotzone); + } + ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll); if (suffixMod == null) return inItem; @@ -361,17 +375,28 @@ public enum LootManager { if (lootItem != null) mob.getCharItemManager().addItemToInventory(lootItem); } - public static void peddleFate(AbstractCharacter character, int giftID){ - int tableID = 0; - if(LootManager._bootySetMap.get(giftID) != null) { - tableID = LootManager._bootySetMap.get(giftID).get(ThreadLocalRandom.current().nextInt(1, LootManager._bootySetMap.get(giftID).size() - 1)).genTable; + public static void peddleFate(AbstractCharacter character, Item gift){ + if(character.getCharItemManager().inventoryContains(gift)){ + character.getCharItemManager().getInventory().remove(gift) ; } else{ + character.getCharItemManager().updateInventory(); return; } + int tableID = 3010; + //if(LootManager._bootySetMap.get(giftID) != null) { + // tableID = LootManager._bootySetMap.get(giftID).get(ThreadLocalRandom.current().nextInt(1, LootManager._bootySetMap.get(giftID).size() - 1)).genTable; + //} else{ + // return; + //} MobLoot gamblingResult= getGenTableItem(tableID,character,false); + Item winnings; if(gamblingResult != null){ - gamblingResult.promoteToItem((PlayerCharacter)character); + winnings = gamblingResult.promoteToItem(PlayerCharacter.getPlayerCharacter(character.getObjectUUID())); + } else{ + winnings = new MobLoot(character, ItemBase.getItemBase(1580008), 1, false);//item ID is coal set to amount of 1 } + character.getCharItemManager().updateInventory(winnings,true); + } } diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index f85370c3..9e3dfc30 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -442,7 +442,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { //} // Garbage method removed until rewritten. // LootTable.CreateGamblerItem(item, player); - LootManager.peddleFate(player,item.getItemBaseID()); + LootManager.peddleFate(player,item); break; case 30: //water bucket From 1b77eeabc0dc0671b59bc6f78f289f47899c7398 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 9 Aug 2023 14:48:22 -0500 Subject: [PATCH 06/10] fate peddler work --- src/engine/gameManager/LootManager.java | 70 ++++++++++++++++++------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index ae7dddf3..d71d7800 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -375,28 +375,62 @@ public enum LootManager { if (lootItem != null) mob.getCharItemManager().addItemToInventory(lootItem); } - public static void peddleFate(AbstractCharacter character, Item gift){ - if(character.getCharItemManager().inventoryContains(gift)){ - character.getCharItemManager().getInventory().remove(gift) ; - } else{ - character.getCharItemManager().updateInventory(); + public static void peddleFate(AbstractCharacter character, Item gift) { + //get table ID here, 3010 as a test + int tableID = 3010; + + if(tableID == 0) return; + + //get the character item manager + CharacterItemManager itemMan = character.getCharItemManager(); + if(itemMan == null) + return; + + //check if player owns the gift he is trying to open + if(itemMan.doesCharOwnThisItem(gift.getObjectUUID()) == false) + return; + + //roll 1-100 for the gen table selection + int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1); + GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll); + if(selectedRow == null) + return; + + //roll 220-320 for the item table selection + int itemRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); + ItemTableEntry selectedItem = ItemTableEntry.rollTable(selectedRow.itemTableID,itemRoll); + if(selectedItem == null) + return; + + //create the item from the table, quantity is always 1 + MobLoot winnings = new MobLoot(character, ItemBase.getItemBase(selectedItem.cacheID), 1, false); + if(winnings == null) + return; + + //determine if the winning item needs a prefix + if(selectedRow.pModTable != 0){ + int prefixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); + ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll); + if(prefix != null){ + winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true); + } } - int tableID = 3010; - //if(LootManager._bootySetMap.get(giftID) != null) { - // tableID = LootManager._bootySetMap.get(giftID).get(ThreadLocalRandom.current().nextInt(1, LootManager._bootySetMap.get(giftID).size() - 1)).genTable; - //} else{ - // return; - //} - MobLoot gamblingResult= getGenTableItem(tableID,character,false); - Item winnings; - if(gamblingResult != null){ - winnings = gamblingResult.promoteToItem(PlayerCharacter.getPlayerCharacter(character.getObjectUUID())); - } else{ - winnings = new MobLoot(character, ItemBase.getItemBase(1580008), 1, false);//item ID is coal set to amount of 1 + + //determine if the winning item needs a suffix + if(selectedRow.sModTable != 0){ + int suffixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); + ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll); + if(suffix != null){ + winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true); + } } - character.getCharItemManager().updateInventory(winnings,true); + //remove gift from inventory + itemMan.delete(gift); + + //add winnings to player inventory + itemMan.updateInventory(winnings.promoteToItem((PlayerCharacter)character),true); } } From 7c931e87a4a115a132615f3e199cde43b99b1bd5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 9 Aug 2023 14:53:05 -0500 Subject: [PATCH 07/10] fate peddler work --- src/engine/gameManager/LootManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index a5f4886e..a7899cb2 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -428,10 +428,12 @@ public enum LootManager { } //remove gift from inventory - itemMan.delete(gift); + itemMan.junk(gift); //add winnings to player inventory - itemMan.updateInventory(winnings.promoteToItem((PlayerCharacter)character),true); + Item playerWinnings = winnings.promoteToItem((PlayerCharacter)character); + itemMan.addItemToInventory(playerWinnings); + itemMan.updateInventory(playerWinnings,true); } } From 8747890e5ee17a19826ad15b73637791e6217af1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 9 Aug 2023 15:50:56 -0500 Subject: [PATCH 08/10] fate peddler work --- src/engine/gameManager/LootManager.java | 29 +++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index a7899cb2..618f09b8 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -377,9 +377,13 @@ public enum LootManager { mob.getCharItemManager().addItemToInventory(lootItem); } public static void peddleFate(AbstractCharacter character, Item gift) { - //get table ID here, 3010 as a test - int tableID = 3010; + //get table ID for the itembase ID + int tableID = 0; + if(_bootySetMap.get(gift.getItemBaseID()) != null) + tableID = _bootySetMap.get(gift.getItemBaseID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getItemBaseID()).size())).genTable; + //use 3010 for testing + //tableID = 3040; if(tableID == 0) return; @@ -396,7 +400,7 @@ public enum LootManager { int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1); GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll); if(selectedRow == null) - return; + return; //roll 220-320 for the item table selection int itemRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); @@ -409,31 +413,34 @@ public enum LootManager { if(winnings == null) return; + //early exit if the inventory of the player will not old the item + if(itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false){ + ChatManager.chatSay(character,"You cannot hold your winnings!",false); + return; + } + //determine if the winning item needs a prefix if(selectedRow.pModTable != 0){ int prefixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll); - if(prefix != null){ + if(prefix != null) winnings.addPermanentEnchantment(prefix.action, 0, prefix.level, true); - } } //determine if the winning item needs a suffix if(selectedRow.sModTable != 0){ int suffixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll); - if(suffix != null){ + if(suffix != null) winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true); - } } - + winnings.setIsID(true); //remove gift from inventory - itemMan.junk(gift); + itemMan.consume(gift); //add winnings to player inventory Item playerWinnings = winnings.promoteToItem((PlayerCharacter)character); itemMan.addItemToInventory(playerWinnings); - itemMan.updateInventory(playerWinnings,true); + itemMan.updateInventory(); } - } From 1efb9daff89f93ec1bc7773a5830cd1c675ec8a7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 9 Aug 2023 17:52:39 -0400 Subject: [PATCH 09/10] ErrorPopup for fate peddler encumbrance. --- src/engine/gameManager/LootManager.java | 54 ++++++++++++------- .../handlers/ObjectActionMsgHandler.java | 8 ++- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 618f09b8..5000b884 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -11,14 +11,13 @@ package engine.gameManager; import engine.Enum; import engine.loot.*; import engine.net.DispatchMessage; +import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; -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.ThreadLocalRandom; /** @@ -376,50 +375,63 @@ public enum LootManager { if (lootItem != null) mob.getCharItemManager().addItemToInventory(lootItem); } - public static void peddleFate(AbstractCharacter character, Item gift) { + + public static void peddleFate(PlayerCharacter playerCharacter, Item gift) { + //get table ID for the itembase ID + int tableID = 0; - if(_bootySetMap.get(gift.getItemBaseID()) != null) + + if (_bootySetMap.get(gift.getItemBaseID()) != null) tableID = _bootySetMap.get(gift.getItemBaseID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getItemBaseID()).size())).genTable; - //use 3010 for testing - //tableID = 3040; - if(tableID == 0) + if (tableID == 0) return; //get the character item manager - CharacterItemManager itemMan = character.getCharItemManager(); - if(itemMan == null) + + CharacterItemManager itemMan = playerCharacter.getCharItemManager(); + + if (itemMan == null) return; //check if player owns the gift he is trying to open - if(itemMan.doesCharOwnThisItem(gift.getObjectUUID()) == false) + + if (itemMan.doesCharOwnThisItem(gift.getObjectUUID()) == false) return; //roll 1-100 for the gen table selection + int genRoll = ThreadLocalRandom.current().nextInt(1,100 + 1); GenTableEntry selectedRow = GenTableEntry.rollTable(tableID, genRoll); + if(selectedRow == null) return; //roll 220-320 for the item table selection - int itemRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); - ItemTableEntry selectedItem = ItemTableEntry.rollTable(selectedRow.itemTableID,itemRoll); - if(selectedItem == null) + + int itemRoll = ThreadLocalRandom.current().nextInt(220, 320 + 1); + ItemTableEntry selectedItem = ItemTableEntry.rollTable(selectedRow.itemTableID, itemRoll); + + if (selectedItem == null) return; //create the item from the table, quantity is always 1 - MobLoot winnings = new MobLoot(character, ItemBase.getItemBase(selectedItem.cacheID), 1, false); - if(winnings == null) + + MobLoot winnings = new MobLoot(playerCharacter, ItemBase.getItemBase(selectedItem.cacheID), 1, false); + + if (winnings == null) return; //early exit if the inventory of the player will not old the item - if(itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false){ - ChatManager.chatSay(character,"You cannot hold your winnings!",false); + + if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) { + ErrorPopupMsg.sendErrorPopup(playerCharacter, 27); return; } //determine if the winning item needs a prefix + if(selectedRow.pModTable != 0){ int prefixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); ModTableEntry prefix = ModTableEntry.rollTable(selectedRow.pModTable, prefixRoll); @@ -428,18 +440,22 @@ public enum LootManager { } //determine if the winning item needs a suffix + if(selectedRow.sModTable != 0){ int suffixRoll = ThreadLocalRandom.current().nextInt(220,320 + 1); ModTableEntry suffix = ModTableEntry.rollTable(selectedRow.sModTable, suffixRoll); - if(suffix != null) + if (suffix != null) winnings.addPermanentEnchantment(suffix.action, 0, suffix.level, true); } winnings.setIsID(true); + //remove gift from inventory + itemMan.consume(gift); //add winnings to player inventory - Item playerWinnings = winnings.promoteToItem((PlayerCharacter)character); + + Item playerWinnings = winnings.promoteToItem((PlayerCharacter) playerCharacter); itemMan.addItemToInventory(playerWinnings); itemMan.updateInventory(); } diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 9e3dfc30..d6ef538e 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -19,7 +19,6 @@ import engine.powers.PowersBase; import org.pmw.tinylog.Logger; import java.util.ArrayList; -import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.locks.ReentrantReadWriteLock; /* @@ -424,7 +423,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { break; //ANNIVERSERY GIFT case 31: - + // *** Disabled for now: Needs bootyset created //if (ib.getUUID() == 971012) { // int random = ThreadLocalRandom.current().nextInt(ItemBase.AnniverseryGifts.size()); @@ -440,9 +439,8 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { // } // break; //} - // Garbage method removed until rewritten. - // LootTable.CreateGamblerItem(item, player); - LootManager.peddleFate(player,item); + + LootManager.peddleFate(player,item); break; case 30: //water bucket From 015e6301fb38f4f040481e0ec9ec6fd79b3b8498 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 9 Aug 2023 17:58:11 -0400 Subject: [PATCH 10/10] ErrorPopup for fate peddler encumbrance. --- 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 5000b884..145775ca 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -426,7 +426,7 @@ public enum LootManager { //early exit if the inventory of the player will not old the item if (itemMan.hasRoomInventory(winnings.getItemBase().getWeight()) == false) { - ErrorPopupMsg.sendErrorPopup(playerCharacter, 27); + ErrorPopupMsg.sendErrorPopup(playerCharacter, 21); return; }