From 45fa191ef630cef47911084326aaadc42c4270ee Mon Sep 17 00:00:00 2001
From: FatBoy-DOTC <justin.chucksinsulating@gmail.com>
Date: Sun, 16 Jul 2023 11:35:54 -0500
Subject: [PATCH] prefix and suffix chances added to mobloot

---
 src/engine/loot/LootManager.java | 37 ++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/engine/loot/LootManager.java b/src/engine/loot/LootManager.java
index 470ff413..4e1e0cb3 100644
--- a/src/engine/loot/LootManager.java
+++ b/src/engine/loot/LootManager.java
@@ -179,22 +179,31 @@ 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) {
-                ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable);
-                ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable);
-                if (modTables.get(prefixTable.getRowForRange(100).modTableID) != null) {
-                    ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(100).modTableID);
-                    ModTableRow prefixMod = prefixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange);
-                    if (prefixMod != null && prefixMod.action.length() > 0) {
-                        outItem.setPrefix(prefixMod.action);
-                        outItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true);
+                int prefixChance = ThreadLocalRandom.current().nextInt(101);
+                if(prefixChance < mob.level) {
+                    ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable);
+
+                    int prefixroll = ThreadLocalRandom.current().nextInt(101);
+                    if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) {
+                        ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID);
+                        ModTableRow prefixMod = prefixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange);
+                        if (prefixMod != null && prefixMod.action.length() > 0) {
+                            outItem.setPrefix(prefixMod.action);
+                            outItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true);
+                        }
                     }
                 }
-                if (modTables.get(suffixTable.getRowForRange(100).modTableID) != null) {
-                    ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(100).modTableID);
-                    ModTableRow suffixMod = suffixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange);
-                    if (suffixMod != null && suffixMod.action.length() > 0) {
-                        outItem.setSuffix(suffixMod.action);
-                        outItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false);
+                int suffixChance = ThreadLocalRandom.current().nextInt(101);
+                if(suffixChance < mob.level) {
+                    int suffixroll = ThreadLocalRandom.current().nextInt(101);
+                    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(new Random().nextInt(maxRollRange) + minRollRange);
+                        if (suffixMod != null && suffixMod.action.length() > 0) {
+                            outItem.setSuffix(suffixMod.action);
+                            outItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false);
+                        }
                     }
                 }
             }