From d53bf0f66e85f0e6d4cd2c9c56edaa9ff35afe87 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 8 Aug 2023 20:37:31 -0500 Subject: [PATCH] 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