From ea555be08ed4c811a1c6b47a166fe9f97fed0441 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 13:13:28 -0400 Subject: [PATCH] Mobtype work related to ForgeManager --- src/engine/gameManager/ForgeManager.java | 16 ++++++++++++---- src/engine/mbEnums.java | 5 +++++ src/engine/net/client/msg/ManageNPCMsg.java | 8 ++++---- src/engine/objects/Contract.java | 6 +++--- src/engine/objects/ItemFactory.java | 2 +- src/engine/objects/NPC.java | 4 ++-- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 276c1052..010164eb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -10,10 +10,7 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; -import engine.objects.Item; -import engine.objects.ItemTemplate; -import engine.objects.MobLoot; -import engine.objects.Warehouse; +import engine.objects.*; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -284,4 +281,15 @@ public enum ForgeManager implements Runnable { Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); } } + + public static void calsRandomModType(NPC vendor, mbEnums.ItemModType itemModType, Item item) { + + int modifier; + + if (itemModType.equals(mbEnums.ItemModType.PREFIX)) + modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); + else + modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); + + } } diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index 0196d136..720ede75 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -3039,5 +3039,10 @@ public class mbEnums { CONFIRM_DEPOSIT, CONFIRM_TAKE; } + + public enum ItemModType { + PREFIX, + SUFFIX; + } } diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 2ec99f38..3be1d778 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -523,10 +523,10 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(2); writer.putInt(0); writer.putInt(1); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt));//writer.putInt(-916801465); effectItemType + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue());//writer.putInt(-916801465); effectItemType writer.putInt(mtp); //prefix int mts = modPrefixList.indexOf(mtp); writer.putInt(npc.getModSuffixTable().get(mts)); //suffix diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index 5defef35..c094f9c6 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -34,7 +34,7 @@ public class Contract extends AbstractGameObject { private ArrayList npcMenuOptions = new ArrayList<>(); private ArrayList npcModTypeTable = new ArrayList<>(); private ArrayList npcModSuffixTable = new ArrayList<>(); - private ArrayList itemModTable = new ArrayList<>(); + private ArrayList itemModTable = new ArrayList<>(); private ArrayList sellInventory = new ArrayList<>(); public EnumSet allowedBuildings; private ArrayList buyItemType = new ArrayList<>(); @@ -122,7 +122,7 @@ public class Contract extends AbstractGameObject { if (!itemMod.isEmpty()) { String[] data2 = itemMod.split(" "); for (byte i = 0; i < data2.length; i++) { - this.itemModTable.add(Byte.parseByte(data2[i])); + this.itemModTable.add(Integer.parseInt(data2[i])); } } @@ -193,7 +193,7 @@ public class Contract extends AbstractGameObject { return npcModSuffixTable; } - public ArrayList getItemModTable() { + public ArrayList getItemModTable() { return itemModTable; } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 4ae1b050..b5d937e6 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -663,7 +663,7 @@ public class ItemFactory { return null; } - for (byte temp : vendor.getItemModTable()) { + for (int temp : vendor.getItemModTable()) { if (itemModTable != temp) continue; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 95cafce1..58556907 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -70,7 +70,7 @@ public class NPC extends AbstractCharacter { protected int vendorID; protected ArrayList modTypeTable; protected ArrayList modSuffixTable; - protected ArrayList itemModTable; + protected ArrayList itemModTable; protected int symbol; // Variables NOT to be stored in db protected boolean isStatic = false; @@ -805,7 +805,7 @@ public class NPC extends AbstractCharacter { return modSuffixTable; } - public ArrayList getItemModTable() { + public ArrayList getItemModTable() { return itemModTable; }