forked from MagicBane/Server
				
			
				 29 changed files with 1082 additions and 2665 deletions
			
			
		@ -0,0 +1,240 @@
				@@ -0,0 +1,240 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.db.handlers; | 
				
			||||
 | 
				
			||||
import engine.gameManager.DbManager; | 
				
			||||
import engine.loot.*; | 
				
			||||
import engine.objects.Item; | 
				
			||||
import org.pmw.tinylog.Logger; | 
				
			||||
 | 
				
			||||
import java.sql.Connection; | 
				
			||||
import java.sql.PreparedStatement; | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
import java.util.ArrayList; | 
				
			||||
import java.util.HashMap; | 
				
			||||
 | 
				
			||||
public class dbLootHandler extends dbHandlerBase { | 
				
			||||
 | 
				
			||||
    public dbLootHandler() { | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public HashMap<Integer, ArrayList<GenTableEntry>> LOAD_GEN_ITEM_TABLES() { | 
				
			||||
 | 
				
			||||
        HashMap<Integer, ArrayList<GenTableEntry>> genTables = new HashMap<>(); | 
				
			||||
        GenTableEntry genTableEntry; | 
				
			||||
 | 
				
			||||
        int genTableID; | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_gen`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
 | 
				
			||||
                recordsRead++; | 
				
			||||
 | 
				
			||||
                genTableID = rs.getInt("genTable"); | 
				
			||||
                genTableEntry = new GenTableEntry(rs); | 
				
			||||
 | 
				
			||||
                if (genTables.get(genTableID) == null) { | 
				
			||||
                    ArrayList<GenTableEntry> genItemList = new ArrayList<>(); | 
				
			||||
                    genItemList.add(genTableEntry); | 
				
			||||
                    genTables.put(genTableID, genItemList); | 
				
			||||
                } else { | 
				
			||||
                    ArrayList<GenTableEntry> genItemList = genTables.get(genTableID); | 
				
			||||
                    genItemList.add(genTableEntry); | 
				
			||||
                    genTables.put(genTableID, genItemList); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
            return genTables; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + genTables.size()); | 
				
			||||
        return genTables; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public HashMap<Integer, ArrayList<ItemTableEntry>> LOAD_ITEM_TABLES() { | 
				
			||||
 | 
				
			||||
        HashMap<Integer, ArrayList<ItemTableEntry>> itemTables = new HashMap<>(); | 
				
			||||
        ItemTableEntry itemTableEntry; | 
				
			||||
 | 
				
			||||
        int itemTableID; | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_item`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
 | 
				
			||||
                recordsRead++; | 
				
			||||
 | 
				
			||||
                itemTableID = rs.getInt("itemTable"); | 
				
			||||
                itemTableEntry = new ItemTableEntry(rs); | 
				
			||||
 | 
				
			||||
                if (itemTables.get(itemTableID) == null) { | 
				
			||||
                    ArrayList<ItemTableEntry> itemTableList = new ArrayList<>(); | 
				
			||||
                    itemTableList.add(itemTableEntry); | 
				
			||||
                    itemTables.put(itemTableID, itemTableList); | 
				
			||||
                } else { | 
				
			||||
                    ArrayList<ItemTableEntry> itemTableList = itemTables.get(itemTableID); | 
				
			||||
                    itemTableList.add(itemTableEntry); | 
				
			||||
                    itemTables.put(itemTableID, itemTableList); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
            return itemTables; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + itemTables.size()); | 
				
			||||
        return itemTables; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public HashMap<Integer, ArrayList<ModTableEntry>> LOAD_MOD_TABLES() { | 
				
			||||
 | 
				
			||||
        HashMap<Integer, ArrayList<ModTableEntry>> modTables = new HashMap<>(); | 
				
			||||
        ModTableEntry modTableEntry; | 
				
			||||
 | 
				
			||||
        int modTableID; | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_mod`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
 | 
				
			||||
                recordsRead++; | 
				
			||||
 | 
				
			||||
                modTableID = rs.getInt("modTable"); | 
				
			||||
                modTableEntry = new ModTableEntry(rs); | 
				
			||||
 | 
				
			||||
                if (modTables.get(modTableID) == null) { | 
				
			||||
                    ArrayList<ModTableEntry> modTableList = new ArrayList<>(); | 
				
			||||
                    modTableList.add(modTableEntry); | 
				
			||||
                    modTables.put(modTableID, modTableList); | 
				
			||||
                } else { | 
				
			||||
                    ArrayList<ModTableEntry> modTableList = modTables.get(modTableID); | 
				
			||||
                    modTableList.add(modTableEntry); | 
				
			||||
                    modTables.put(modTableID, modTableList); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
            return modTables; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + modTables.size()); | 
				
			||||
        return modTables; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public HashMap<Integer, ArrayList<ModTypeTableEntry>> LOAD_MOD_TYPE_TABLES() { | 
				
			||||
 | 
				
			||||
        HashMap<Integer, ArrayList<ModTypeTableEntry>> modTypeTables = new HashMap<>(); | 
				
			||||
        ModTypeTableEntry modTypeTableEntry; | 
				
			||||
 | 
				
			||||
        int modTableID; | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_loot_modtype`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
 | 
				
			||||
                recordsRead++; | 
				
			||||
 | 
				
			||||
                modTableID = rs.getInt("modType"); | 
				
			||||
                modTypeTableEntry = new ModTypeTableEntry(rs); | 
				
			||||
 | 
				
			||||
                if (modTypeTables.get(modTableID) == null) { | 
				
			||||
                    ArrayList<ModTypeTableEntry> modTypeTableList = new ArrayList<>(); | 
				
			||||
                    modTypeTableList.add(modTypeTableEntry); | 
				
			||||
                    modTypeTables.put(modTableID, modTypeTableList); | 
				
			||||
                } else { | 
				
			||||
                    ArrayList<ModTypeTableEntry> modTypeTableList = modTypeTables.get(modTableID); | 
				
			||||
                    modTypeTableList.add(modTypeTableEntry); | 
				
			||||
                    modTypeTables.put(modTableID, modTypeTableList); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
            return modTypeTables; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + modTypeTables.size()); | 
				
			||||
        return modTypeTables; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_TABLES() { | 
				
			||||
 | 
				
			||||
        HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>(); | 
				
			||||
        BootySetEntry bootySetEntry; | 
				
			||||
        int bootySetID; | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
 | 
				
			||||
                recordsRead++; | 
				
			||||
 | 
				
			||||
                bootySetID = rs.getInt("bootySet"); | 
				
			||||
                bootySetEntry = new BootySetEntry(rs); | 
				
			||||
 | 
				
			||||
                if (bootySets.get(bootySetID) == null) { | 
				
			||||
                    ArrayList<BootySetEntry> bootyList = new ArrayList<>(); | 
				
			||||
                    bootyList.add(bootySetEntry); | 
				
			||||
                    bootySets.put(bootySetID, bootyList); | 
				
			||||
                } else { | 
				
			||||
                    ArrayList<BootySetEntry> bootyList = bootySets.get(bootySetID); | 
				
			||||
                    bootyList.add(bootySetEntry); | 
				
			||||
                    bootySets.put(bootySetID, bootyList); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
            return bootySets; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); | 
				
			||||
        return bootySets; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void LOAD_ENCHANT_VALUES() { | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT `IDString`, `minMod` FROM `static_power_effectmod` WHERE `modType` = ?")) { | 
				
			||||
 | 
				
			||||
            preparedStatement.setString(1, "Value"); | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) | 
				
			||||
                Item.addEnchantValue(rs.getString("IDString"), rs.getInt("minMod")); | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -1,215 +0,0 @@
				@@ -1,215 +0,0 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.db.handlers; | 
				
			||||
 | 
				
			||||
import engine.gameManager.DbManager; | 
				
			||||
import engine.loot.LootManager; | 
				
			||||
import engine.objects.Item; | 
				
			||||
import engine.objects.LootTable; | 
				
			||||
import org.pmw.tinylog.Logger; | 
				
			||||
 | 
				
			||||
import java.sql.Connection; | 
				
			||||
import java.sql.PreparedStatement; | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
 | 
				
			||||
public class dbLootTableHandler extends dbHandlerBase { | 
				
			||||
 | 
				
			||||
    public dbLootTableHandler() { | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void populateLootGroups() { | 
				
			||||
 | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_lootgroups`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                recordsRead++; | 
				
			||||
                LootTable lootTable = LootTable.getLootGroup(rs.getInt("groupID")); | 
				
			||||
                lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("lootTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), ""); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootGroups().size()); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void populateLootTables() { | 
				
			||||
 | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT `lootTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_loottables`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                recordsRead++; | 
				
			||||
                LootTable lootTable = LootTable.getLootTable(rs.getInt("lootTable")); | 
				
			||||
                lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemBaseUUID"), rs.getInt("minSpawn"), rs.getInt("maxSpawn"), ""); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootTables().size()); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void populateModTables() { | 
				
			||||
 | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modTable`,`minRoll`,`maxRoll`,`value`,`action` FROM `static_modtables`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                recordsRead++; | 
				
			||||
                LootTable lootTable = LootTable.getModTable(rs.getInt("modTable")); | 
				
			||||
                lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("value"), 0, 0, rs.getString("action")); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + LootTable.getModTables().size()); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void populateModGroups() { | 
				
			||||
 | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT `modGroup`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modgroups`")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                recordsRead++; | 
				
			||||
                LootTable lootTable = LootTable.getModGroup(rs.getInt("modGroup")); | 
				
			||||
                lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("subTableID"), 0, 0, ""); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead + " cached: " + LootTable.getModGroups().size()); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void LOAD_ENCHANT_VALUES() { | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT `IDString`, `minMod` FROM `static_power_effectmod` WHERE `modType` = ?")) { | 
				
			||||
 | 
				
			||||
            preparedStatement.setString(1, "Value"); | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) | 
				
			||||
                Item.addEnchantValue(rs.getString("IDString"), rs.getInt("minMod")); | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void LOAD_ALL_LOOTGROUPS() { | 
				
			||||
 | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_lootgroups")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                LootManager.GenTableRow row = new LootManager.GenTableRow(rs); | 
				
			||||
                LootManager.AddGenTableRow(rs.getInt("groupID"), row); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void LOAD_ALL_LOOTTABLES() { | 
				
			||||
 | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_loottables")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                recordsRead++; | 
				
			||||
                LootManager.ItemTableRow row = new LootManager.ItemTableRow(rs); | 
				
			||||
                LootManager.AddItemTableRow(rs.getInt("lootTable"), row); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        Logger.info("read: " + recordsRead); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void LOAD_ALL_MODGROUPS() { | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_modgroups")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                recordsRead++; | 
				
			||||
                LootManager.ModTypeTableRow mttr = new LootManager.ModTypeTableRow(rs); | 
				
			||||
                LootManager.AddModTypeTableRow(rs.getInt("modGroup"), mttr); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
        Logger.info("read: " + recordsRead); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void LOAD_ALL_MODTABLES() { | 
				
			||||
        int recordsRead = 0; | 
				
			||||
 | 
				
			||||
        try (Connection connection = DbManager.getConnection(); | 
				
			||||
             PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_modtables")) { | 
				
			||||
 | 
				
			||||
            ResultSet rs = preparedStatement.executeQuery(); | 
				
			||||
 | 
				
			||||
            while (rs.next()) { | 
				
			||||
                recordsRead++; | 
				
			||||
                LootManager.ModTableRow mtr = new LootManager.ModTableRow(rs); | 
				
			||||
                LootManager.AddModTableRow(rs.getInt("modTable"), mtr); | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
        } catch (SQLException e) { | 
				
			||||
            Logger.error(e); | 
				
			||||
        } | 
				
			||||
        Logger.info("read: " + recordsRead); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,58 +0,0 @@
				@@ -1,58 +0,0 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.devcmd.cmds; | 
				
			||||
 | 
				
			||||
import engine.Enum.GameObjectType; | 
				
			||||
import engine.devcmd.AbstractDevCmd; | 
				
			||||
import engine.objects.AbstractGameObject; | 
				
			||||
import engine.objects.Mob; | 
				
			||||
import engine.objects.MobLootBase; | 
				
			||||
import engine.objects.PlayerCharacter; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author Eighty | 
				
			||||
 */ | 
				
			||||
public class GetMobBaseLoot extends AbstractDevCmd { | 
				
			||||
 | 
				
			||||
    public GetMobBaseLoot() { | 
				
			||||
        super("mobbaseloot"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected void _doCmd(PlayerCharacter pc, String[] words, | 
				
			||||
                          AbstractGameObject target) { | 
				
			||||
        if (target.getObjectType() != GameObjectType.Mob) { | 
				
			||||
            this.throwbackError(pc, "Must be targeting a Valid Mob For this Command."); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
 | 
				
			||||
        Mob mob = (Mob) target; | 
				
			||||
        for (MobLootBase mlb : MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())) { | 
				
			||||
 | 
				
			||||
            this.throwbackInfo(pc, "LootTable11 = " + mlb.getLootTableID() + "\rn "); | 
				
			||||
            this.throwbackInfo(pc, "Chance = " + mlb.getChance() + "\rn "); | 
				
			||||
 | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getHelpString() { | 
				
			||||
        return "Copies a Mob of type 'mobID' with optional new name"; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getUsageString() { | 
				
			||||
        return "' /mob mobID [name]'"; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -1,132 +0,0 @@
				@@ -1,132 +0,0 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.devcmd.cmds; | 
				
			||||
 | 
				
			||||
import engine.devcmd.AbstractDevCmd; | 
				
			||||
import engine.objects.AbstractGameObject; | 
				
			||||
import engine.objects.ItemBase; | 
				
			||||
import engine.objects.LootTable; | 
				
			||||
import engine.objects.PlayerCharacter; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @author Eighty | 
				
			||||
 */ | 
				
			||||
public class MBDropCmd extends AbstractDevCmd { | 
				
			||||
 | 
				
			||||
    public MBDropCmd() { | 
				
			||||
        super("mbdrop"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected void _doCmd(PlayerCharacter pcSender, String[] args, | 
				
			||||
                          AbstractGameObject target) { | 
				
			||||
        String newline = "\r\n "; | 
				
			||||
        if (args.length != 1) { | 
				
			||||
            this.sendUsage(pcSender); | 
				
			||||
            this.sendHelp(pcSender); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        String output = ""; | 
				
			||||
        switch (args[0].toLowerCase()) { | 
				
			||||
            case "clear": | 
				
			||||
 | 
				
			||||
                LootTable.contractCount = 0; | 
				
			||||
                LootTable.dropCount = 0; | 
				
			||||
                LootTable.glassCount = 0; | 
				
			||||
                LootTable.runeCount = 0; | 
				
			||||
                LootTable.rollCount = 0; | 
				
			||||
                LootTable.resourceCount = 0; | 
				
			||||
 | 
				
			||||
                LootTable.contractDroppedMap.clear(); | 
				
			||||
                LootTable.glassDroppedMap.clear(); | 
				
			||||
                LootTable.itemsDroppedMap.clear(); | 
				
			||||
                LootTable.resourceDroppedMap.clear(); | 
				
			||||
                LootTable.runeDroppedMap.clear(); | 
				
			||||
                break; | 
				
			||||
            case "all": | 
				
			||||
                output = LootTable.dropCount + " items - ITEM NAME : DROP COUNT" + newline; | 
				
			||||
                for (ItemBase ib : LootTable.itemsDroppedMap.keySet()) { | 
				
			||||
 | 
				
			||||
                    int dropCount = LootTable.itemsDroppedMap.get(ib); | 
				
			||||
                    output += ib.getName() + " : " + dropCount + newline; | 
				
			||||
 | 
				
			||||
                } | 
				
			||||
                break; | 
				
			||||
            case "resource": | 
				
			||||
                output = LootTable.resourceCount + " Resources - ITEM NAME : DROP COUNT" + newline; | 
				
			||||
                for (ItemBase ib : LootTable.resourceDroppedMap.keySet()) { | 
				
			||||
 | 
				
			||||
                    int dropCount = LootTable.resourceDroppedMap.get(ib); | 
				
			||||
                    output += ib.getName() + " : " + dropCount + newline; | 
				
			||||
 | 
				
			||||
                } | 
				
			||||
 | 
				
			||||
                break; | 
				
			||||
            case "rune": | 
				
			||||
 | 
				
			||||
                output = LootTable.runeCount + " Runes - ITEM NAME : DROP COUNT" + newline; | 
				
			||||
                for (ItemBase ib : LootTable.runeDroppedMap.keySet()) { | 
				
			||||
 | 
				
			||||
                    int dropCount = LootTable.runeDroppedMap.get(ib); | 
				
			||||
                    output += ib.getName() + " : " + dropCount + newline; | 
				
			||||
 | 
				
			||||
                } | 
				
			||||
                break; | 
				
			||||
            case "contract": | 
				
			||||
 | 
				
			||||
                output = LootTable.contractCount + " Contracts - ITEM NAME : DROP COUNT" + newline; | 
				
			||||
                for (ItemBase ib : LootTable.contractDroppedMap.keySet()) { | 
				
			||||
 | 
				
			||||
                    int dropCount = LootTable.contractDroppedMap.get(ib); | 
				
			||||
                    output += ib.getName() + " : " + dropCount + newline; | 
				
			||||
 | 
				
			||||
 | 
				
			||||
                } | 
				
			||||
                break; | 
				
			||||
 | 
				
			||||
            case "glass": | 
				
			||||
 | 
				
			||||
                output = LootTable.glassCount + " Glass - ITEM NAME : DROP COUNT" + newline; | 
				
			||||
                for (ItemBase ib : LootTable.glassDroppedMap.keySet()) { | 
				
			||||
 | 
				
			||||
                    int dropCount = LootTable.glassDroppedMap.get(ib); | 
				
			||||
                    output += ib.getName() + " : " + dropCount + newline; | 
				
			||||
                } | 
				
			||||
                break; | 
				
			||||
 | 
				
			||||
            case "chance": | 
				
			||||
                float chance = (float) LootTable.dropCount / (float) LootTable.rollCount * 100; | 
				
			||||
                output = LootTable.dropCount + " out of " + LootTable.rollCount + " items Dropped. chance = " + chance + '%'; | 
				
			||||
 | 
				
			||||
                break; | 
				
			||||
 | 
				
			||||
            default: | 
				
			||||
                this.sendUsage(pcSender); | 
				
			||||
                this.sendHelp(pcSender); | 
				
			||||
                return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        this.throwbackInfo(pcSender, output); | 
				
			||||
 | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getUsageString() { | 
				
			||||
        return "' /mbdrop all/resource/rune/contract/glass/chance/clear"; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getHelpString() { | 
				
			||||
        return "Lists drops for server since a reboot. All lists all items and drops. chance is the overall chance items drop from mobs on server. (not including Equipment)"; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -0,0 +1,156 @@
				@@ -0,0 +1,156 @@
					 | 
				
			||||
package engine.devcmd.cmds; | 
				
			||||
 | 
				
			||||
import engine.devcmd.AbstractDevCmd; | 
				
			||||
import engine.gameManager.LootManager; | 
				
			||||
import engine.gameManager.NPCManager; | 
				
			||||
import engine.gameManager.ZoneManager; | 
				
			||||
import engine.loot.BootySetEntry; | 
				
			||||
import engine.objects.*; | 
				
			||||
 | 
				
			||||
import java.util.ArrayList; | 
				
			||||
import java.util.concurrent.ThreadLocalRandom; | 
				
			||||
 | 
				
			||||
public class SimulateBootyCmd extends AbstractDevCmd { | 
				
			||||
    public SimulateBootyCmd() { | 
				
			||||
        super("bootysim"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected void _doCmd(PlayerCharacter playerCharacter, String[] words, | 
				
			||||
                          AbstractGameObject target) { | 
				
			||||
 | 
				
			||||
        if (playerCharacter == null) | 
				
			||||
            return; | 
				
			||||
 | 
				
			||||
        String newline = "\r\n "; | 
				
			||||
 | 
				
			||||
        String output; | 
				
			||||
 | 
				
			||||
        output = "Booty Simulation:" + newline; | 
				
			||||
 | 
				
			||||
        Mob mob = (Mob) target; | 
				
			||||
        output += "Name: " + mob.getName() + newline; | 
				
			||||
        output += "Special Loot:" + newline; | 
				
			||||
 | 
				
			||||
        if (mob.bootySet != 0) { | 
				
			||||
            for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.bootySet)) { | 
				
			||||
                ItemBase item = ItemBase.getItemBase(entry.itemBase); | 
				
			||||
                if (item != null) { | 
				
			||||
                    output += "[" + entry.bootyType + "] " + item.getName() + " [Chance] " + entry.dropChance + newline; | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        ArrayList<Item> GlassItems = new ArrayList<Item>(); | 
				
			||||
        ArrayList<Item> Resources = new ArrayList<Item>(); | 
				
			||||
        ArrayList<Item> Runes = new ArrayList<Item>(); | 
				
			||||
        ArrayList<Item> Contracts = new ArrayList<Item>(); | 
				
			||||
        ArrayList<Item> Offerings = new ArrayList<Item>(); | 
				
			||||
        ArrayList<Item> OtherDrops = new ArrayList<Item>(); | 
				
			||||
        ArrayList<Item> EquipmentDrops = new ArrayList<Item>(); | 
				
			||||
 | 
				
			||||
        int failures = 0; | 
				
			||||
        int goldAmount = 0; | 
				
			||||
 | 
				
			||||
        for (int i = 0; i < 100; ++i) { | 
				
			||||
 | 
				
			||||
            try { | 
				
			||||
                mob.loadInventory(); | 
				
			||||
                for (Item lootItem : mob.getCharItemManager().getInventory()) { | 
				
			||||
                    switch (lootItem.getItemBase().getType()) { | 
				
			||||
                        case CONTRACT: //CONTRACT
 | 
				
			||||
                            Contracts.add(lootItem); | 
				
			||||
                            break; | 
				
			||||
                        case OFFERING: //OFFERING
 | 
				
			||||
                            Offerings.add(lootItem); | 
				
			||||
                            break; | 
				
			||||
                        case RESOURCE: //RESOURCE
 | 
				
			||||
                            Resources.add(lootItem); | 
				
			||||
                            break; | 
				
			||||
                        case RUNE: //RUNE
 | 
				
			||||
                            Runes.add(lootItem); | 
				
			||||
                            break; | 
				
			||||
                        case WEAPON: //WEAPON
 | 
				
			||||
                            if (lootItem.getItemBase().isGlass()) | 
				
			||||
                                GlassItems.add(lootItem); | 
				
			||||
                            else | 
				
			||||
                                OtherDrops.add(lootItem); | 
				
			||||
                            break; | 
				
			||||
                        case GOLD: | 
				
			||||
                            goldAmount += lootItem.getNumOfItems(); | 
				
			||||
                            break; | 
				
			||||
                        default: | 
				
			||||
                            OtherDrops.add(lootItem); | 
				
			||||
                            break; | 
				
			||||
                    } | 
				
			||||
                } | 
				
			||||
            } catch (Exception ex) { | 
				
			||||
                failures++; | 
				
			||||
            } | 
				
			||||
            if (mob.getEquip() != null) { | 
				
			||||
                for (MobEquipment me : mob.getEquip().values()) { | 
				
			||||
 | 
				
			||||
                    if (me.getDropChance() == 0) | 
				
			||||
                        continue; | 
				
			||||
 | 
				
			||||
                    float equipmentRoll = ThreadLocalRandom.current().nextInt(99) + 1; | 
				
			||||
                    float dropChance = me.getDropChance() * 100; | 
				
			||||
 | 
				
			||||
                    if (equipmentRoll > (dropChance)) | 
				
			||||
                        continue; | 
				
			||||
 | 
				
			||||
                    MobLoot ml = new MobLoot(mob, me.getItemBase(), false); | 
				
			||||
 | 
				
			||||
                    if (ml != null) | 
				
			||||
                        EquipmentDrops.add(ml); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
        output += "MobBase BootySet: " + mob.getMobBase().bootySet + newline; | 
				
			||||
        output += "Mob BootySet: " + mob.bootySet + newline; | 
				
			||||
        output += "Tables Rolled On: " + newline; | 
				
			||||
 | 
				
			||||
        boolean hotZoneRan = false; | 
				
			||||
        float dropRate = 1.0f; | 
				
			||||
 | 
				
			||||
        if (ZoneManager.inHotZone(mob.getLoc())) | 
				
			||||
            dropRate = LootManager.HOTZONE_DROP_RATE; | 
				
			||||
        else | 
				
			||||
            dropRate = LootManager.NORMAL_DROP_RATE; | 
				
			||||
 | 
				
			||||
        for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { | 
				
			||||
 | 
				
			||||
            if (entry.bootyType.equals("GOLD")) | 
				
			||||
                output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.genTable + ": " + entry.dropChance + newline; | 
				
			||||
            else | 
				
			||||
                output += "NORMAL TABLE [" + entry.bootyType + "] " + entry.genTable + ": " + entry.dropChance * dropRate + newline; | 
				
			||||
 | 
				
			||||
            if (hotZoneRan == false && ZoneManager.inHotZone(mob.getLoc()) && LootManager._genTables.containsKey(entry.genTable + 1)) { | 
				
			||||
                output += "HOTZONE TABLE [" + entry.bootyType + "] " + (entry.genTable + 1) + ": " + entry.dropChance * dropRate + newline; | 
				
			||||
                hotZoneRan = true; | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        output += "GLASS DROPS: " + GlassItems.size() + newline; | 
				
			||||
        output += "RUNE DROPS: " + Runes.size() + newline; | 
				
			||||
        output += "CONTRACTS DROPS: " + Contracts.size() + newline; | 
				
			||||
        output += "RESOURCE DROPS: " + Resources.size() + newline; | 
				
			||||
        output += "OFFERINGS DROPPED: " + Offerings.size() + newline; | 
				
			||||
        output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline; | 
				
			||||
        output += "TOTAL GOLD DROPPED: " + goldAmount + newline; | 
				
			||||
        output += "EQUIPMENT DROPPED: " + EquipmentDrops.size() + newline; | 
				
			||||
        output += "FAILED ROLLS: " + failures + newline; | 
				
			||||
 | 
				
			||||
        throwbackInfo(playerCharacter, output); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getHelpString() { | 
				
			||||
        return "Simulates loot drops"; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getUsageString() { | 
				
			||||
        return "'/bootysim targetID'"; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,168 +0,0 @@
				@@ -1,168 +0,0 @@
					 | 
				
			||||
package engine.devcmd.cmds; | 
				
			||||
 | 
				
			||||
import engine.Enum; | 
				
			||||
import engine.devcmd.AbstractDevCmd; | 
				
			||||
import engine.gameManager.BuildingManager; | 
				
			||||
import engine.gameManager.NPCManager; | 
				
			||||
import engine.objects.*; | 
				
			||||
 | 
				
			||||
import java.util.ArrayList; | 
				
			||||
 | 
				
			||||
public class simulateBootyCmd extends AbstractDevCmd { | 
				
			||||
    public simulateBootyCmd() { | 
				
			||||
        super("simulatebooty"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected void _doCmd(PlayerCharacter pc, String[] words, | 
				
			||||
                          AbstractGameObject target) { | 
				
			||||
        // Arg Count Check
 | 
				
			||||
        if (words.length != 1) { | 
				
			||||
            this.sendUsage(pc); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
        if (pc == null) { | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        String newline = "\r\n "; | 
				
			||||
 | 
				
			||||
        try { | 
				
			||||
            int targetID = Integer.parseInt(words[0]); | 
				
			||||
            Building b = BuildingManager.getBuilding(targetID); | 
				
			||||
            if (b == null) | 
				
			||||
                throwbackError(pc, "Building with ID " + targetID | 
				
			||||
                        + " not found"); | 
				
			||||
            else | 
				
			||||
                target = b; | 
				
			||||
        } catch (Exception e) { | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        if (target == null) { | 
				
			||||
            throwbackError(pc, "Target is unknown or of an invalid type." | 
				
			||||
                    + newline + "Type ID: 0x" | 
				
			||||
                    + pc.getLastTargetType().toString() | 
				
			||||
                    + "   Table ID: " + pc.getLastTargetID()); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
 | 
				
			||||
        Enum.GameObjectType objType = target.getObjectType(); | 
				
			||||
        int objectUUID = target.getObjectUUID(); | 
				
			||||
        String output; | 
				
			||||
 | 
				
			||||
        output = "Booty Simulation:" + newline; | 
				
			||||
 | 
				
			||||
        switch (objType) { | 
				
			||||
            case Building: | 
				
			||||
 | 
				
			||||
                break; | 
				
			||||
            case PlayerCharacter: | 
				
			||||
 | 
				
			||||
                break; | 
				
			||||
 | 
				
			||||
            case NPC: | 
				
			||||
 | 
				
			||||
                break; | 
				
			||||
 | 
				
			||||
            case Mob: | 
				
			||||
                Mob mob = (Mob) target; | 
				
			||||
                output += "Name: " + mob.getName() + newline; | 
				
			||||
                int max = (int)(4.882 * mob.level + 127.0); | 
				
			||||
                if(max > 320){ | 
				
			||||
                    max = 320; | 
				
			||||
                } | 
				
			||||
                int min = (int)(4.469 * mob.level - 3.469); | 
				
			||||
                output += "Roll Range: " + min + " - " + max + newline; | 
				
			||||
                output += "Special Loot:" + newline; | 
				
			||||
                if (mob.bootySet != 0) { | 
				
			||||
                    for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.bootySet)) { | 
				
			||||
                        ItemBase item = ItemBase.getItemBase(entry.itemBase); | 
				
			||||
                        if (item != null) { | 
				
			||||
                            output += "[" + entry.bootyType + "] " + item.getName() + " [Chance] " + entry.dropChance + newline; | 
				
			||||
                        } | 
				
			||||
                    } | 
				
			||||
                } | 
				
			||||
                ArrayList<Item> GlassItems = new ArrayList<Item>(); | 
				
			||||
                ArrayList<Item> Resources = new ArrayList<Item>(); | 
				
			||||
                ArrayList<Item> Runes = new ArrayList<Item>(); | 
				
			||||
                ArrayList<Item> Contracts = new ArrayList<Item>(); | 
				
			||||
                ArrayList<Item> Offerings = new ArrayList<Item>(); | 
				
			||||
                ArrayList<Item> OtherDrops = new ArrayList<Item>(); | 
				
			||||
                int failures = 0; | 
				
			||||
                for (int i = 0; i < 100; ++i) { | 
				
			||||
 | 
				
			||||
                    try { | 
				
			||||
                        mob.loadInventory(); | 
				
			||||
                        for (Item lootItem : mob.getCharItemManager().getInventory()) { | 
				
			||||
                            switch (lootItem.getItemBase().getType()) { | 
				
			||||
                                case CONTRACT: //CONTRACT
 | 
				
			||||
                                    Contracts.add(lootItem); | 
				
			||||
                                    break; | 
				
			||||
                                case OFFERING: //OFFERING
 | 
				
			||||
                                    Offerings.add(lootItem); | 
				
			||||
                                    break; | 
				
			||||
                                case RESOURCE: //RESOURCE
 | 
				
			||||
                                    Resources.add(lootItem); | 
				
			||||
                                    break; | 
				
			||||
                                case RUNE: //RUNE
 | 
				
			||||
                                    Runes.add(lootItem); | 
				
			||||
                                    break; | 
				
			||||
                                case WEAPON: //WEAPON
 | 
				
			||||
                                    if (lootItem.getItemBase().isGlass()) { | 
				
			||||
                                        GlassItems.add(lootItem); | 
				
			||||
                                    } else { | 
				
			||||
                                        OtherDrops.add(lootItem); | 
				
			||||
                                        if (lootItem.getName().toLowerCase().contains("crimson") || lootItem.getName().toLowerCase().contains("vorgrim") || lootItem.getName().toLowerCase().contains("bell")) { | 
				
			||||
                                            output += lootItem.getName() + newline; | 
				
			||||
                                        } | 
				
			||||
                                    } | 
				
			||||
                                    break; | 
				
			||||
                                default: | 
				
			||||
                                    OtherDrops.add(lootItem); | 
				
			||||
                                    if (lootItem.getName().toLowerCase().contains("crimson") || lootItem.getName().toLowerCase().contains("vorgrim") || lootItem.getName().toLowerCase().contains("bell")) { | 
				
			||||
                                        output += lootItem.getName() + newline; | 
				
			||||
                                    } | 
				
			||||
                                    break; | 
				
			||||
                            } | 
				
			||||
                        } | 
				
			||||
                    } catch (Exception ex) { | 
				
			||||
                        failures++; | 
				
			||||
                    } | 
				
			||||
                } | 
				
			||||
                int respawnTime = mob.getMobBase().getSpawnTime(); | 
				
			||||
                if (mob.spawnTime > 0) { | 
				
			||||
                    respawnTime = mob.spawnTime; | 
				
			||||
                } | 
				
			||||
                output += "MobBase BootySet: " + mob.getMobBase().bootySet + newline; | 
				
			||||
                output += "Mob BootySet: " + mob.bootySet + newline; | 
				
			||||
                output += "Tables Rolled On: " + newline; | 
				
			||||
                for (BootySetEntry entry : NPCManager._bootySetMap.get(mob.getMobBase().bootySet)) { | 
				
			||||
                    output += "[" + entry.bootyType + "] " + entry.lootTable + newline; | 
				
			||||
                } | 
				
			||||
                output += "Time Required To Gain Simulated Booty: " + respawnTime * 100 + " Seconds" + newline; | 
				
			||||
                output += "GLASS DROPS: " + GlassItems.size() + newline; | 
				
			||||
                output += "RUNE DROPS: " + Runes.size() + newline; | 
				
			||||
                output += "CONTRACTS DROPS: " + Contracts.size() + newline; | 
				
			||||
                for (Item contract : Contracts){ | 
				
			||||
                    output += contract.getName() + newline; | 
				
			||||
                } | 
				
			||||
                output += "RESOURCE DROPS: " + Resources.size() + newline; | 
				
			||||
                output += "OFFERINGS DROPPED: " + Offerings.size() + newline; | 
				
			||||
                output += "OTHER ITEMS DROPPED: " + OtherDrops.size() + newline; | 
				
			||||
                output += "FAILED ROLLS: " + failures + newline; | 
				
			||||
                break; | 
				
			||||
        } | 
				
			||||
        throwbackInfo(pc, output); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getHelpString() { | 
				
			||||
        return "Gets information on an Object."; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override | 
				
			||||
    protected String _getUsageString() { | 
				
			||||
        return "' /info targetID'"; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,370 @@
				@@ -0,0 +1,370 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
package engine.gameManager; | 
				
			||||
 | 
				
			||||
import engine.Enum; | 
				
			||||
import engine.loot.*; | 
				
			||||
import engine.net.DispatchMessage; | 
				
			||||
import engine.net.client.msg.chat.ChatSystemMsg; | 
				
			||||
import engine.objects.*; | 
				
			||||
import org.pmw.tinylog.Logger; | 
				
			||||
 | 
				
			||||
import java.util.ArrayList; | 
				
			||||
import java.util.HashMap; | 
				
			||||
import java.util.Random; | 
				
			||||
import java.util.concurrent.ThreadLocalRandom; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class contains static methods for data from Magicbane's loot tables | 
				
			||||
 */ | 
				
			||||
public enum LootManager { | 
				
			||||
 | 
				
			||||
    LOOTMANAGER; | 
				
			||||
 | 
				
			||||
    // Newer tables
 | 
				
			||||
 | 
				
			||||
    public static HashMap<Integer, ArrayList<GenTableEntry>> _genTables = new HashMap<>(); | 
				
			||||
    public static HashMap<Integer, ArrayList<ItemTableEntry>> _itemTables = new HashMap<>(); | 
				
			||||
    public static HashMap<Integer, ArrayList<ModTableEntry>> _modTables = new HashMap<>(); | 
				
			||||
    public static HashMap<Integer, ArrayList<ModTypeTableEntry>> _modTypeTables = new HashMap<>(); | 
				
			||||
 | 
				
			||||
    // Drop Rates
 | 
				
			||||
 | 
				
			||||
    public static float NORMAL_DROP_RATE; | 
				
			||||
    public static float NORMAL_EXP_RATE; | 
				
			||||
    public static float NORMAL_GOLD_RATE; | 
				
			||||
    public static float HOTZONE_DROP_RATE; | 
				
			||||
    public static float HOTZONE_EXP_RATE; | 
				
			||||
    public static float HOTZONE_GOLD_RATE; | 
				
			||||
 | 
				
			||||
    // Bootstrap routine to initialize the Loot Manager
 | 
				
			||||
 | 
				
			||||
    public static void init() { | 
				
			||||
 | 
				
			||||
        // Load loot tables from database.
 | 
				
			||||
 | 
				
			||||
        _genTables = DbManager.LootQueries.LOAD_GEN_ITEM_TABLES(); | 
				
			||||
        _itemTables = DbManager.LootQueries.LOAD_ITEM_TABLES(); | 
				
			||||
        _modTables = DbManager.LootQueries.LOAD_MOD_TABLES(); | 
				
			||||
        _modTypeTables = DbManager.LootQueries.LOAD_MOD_TYPE_TABLES(); | 
				
			||||
 | 
				
			||||
        // Cache drop rate values from Config manager.
 | 
				
			||||
 | 
				
			||||
        NORMAL_DROP_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); | 
				
			||||
        NORMAL_EXP_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()); | 
				
			||||
        NORMAL_GOLD_RATE = Float.parseFloat(ConfigManager.MB_NORMAL_GOLD_RATE.getValue()); | 
				
			||||
        HOTZONE_DROP_RATE = Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue()); | 
				
			||||
        HOTZONE_EXP_RATE = Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue()); | 
				
			||||
        HOTZONE_GOLD_RATE = Float.parseFloat(ConfigManager.MB_HOTZONE_GOLD_RATE.getValue()); | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static void GenerateMobLoot(Mob mob, boolean fromDeath) { | 
				
			||||
 | 
				
			||||
        //determine if mob is in hotzone
 | 
				
			||||
 | 
				
			||||
        boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); | 
				
			||||
 | 
				
			||||
        //iterate the booty sets
 | 
				
			||||
 | 
				
			||||
        if (mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet) == true) | 
				
			||||
            RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone, fromDeath); | 
				
			||||
 | 
				
			||||
        if (mob.bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.bootySet) == true) | 
				
			||||
            RunBootySet(NPCManager._bootySetMap.get(mob.bootySet), mob, inHotzone, fromDeath); | 
				
			||||
 | 
				
			||||
        //lastly, check mobs inventory for godly or disc runes to send a server announcement
 | 
				
			||||
 | 
				
			||||
        if (!fromDeath) | 
				
			||||
            for (Item it : mob.getInventory()) { | 
				
			||||
 | 
				
			||||
                ItemBase ib = it.getItemBase(); | 
				
			||||
 | 
				
			||||
                if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) { | 
				
			||||
                    ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ib.getName() + ". Are you tough enough to take it?"); | 
				
			||||
                    chatMsg.setMessageType(10); | 
				
			||||
                    chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); | 
				
			||||
                    DispatchMessage.dispatchMsgToAll(chatMsg); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, boolean inHotzone, boolean fromDeath) { | 
				
			||||
 | 
				
			||||
        boolean hotzoneWasRan = false; | 
				
			||||
        float dropRate = LootManager.NORMAL_DROP_RATE; | 
				
			||||
 | 
				
			||||
        if (fromDeath) { | 
				
			||||
            GenerateEquipmentDrop(mob); | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        // Iterate all entries in this bootySet and process accordingly
 | 
				
			||||
 | 
				
			||||
        for (BootySetEntry bse : entries) { | 
				
			||||
            switch (bse.bootyType) { | 
				
			||||
                case "GOLD": | 
				
			||||
                    GenerateGoldDrop(mob, bse, inHotzone); | 
				
			||||
                    break; | 
				
			||||
                case "LOOT": | 
				
			||||
 | 
				
			||||
                    if (inHotzone == true) | 
				
			||||
                        dropRate = LootManager.HOTZONE_DROP_RATE; | 
				
			||||
                    else | 
				
			||||
                        dropRate = LootManager.NORMAL_DROP_RATE; | 
				
			||||
 | 
				
			||||
                    if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) | 
				
			||||
                        GenerateLootDrop(mob, bse.genTable, false);  //generate normal loot drop
 | 
				
			||||
 | 
				
			||||
                    // Generate hotzone loot if in hotzone
 | 
				
			||||
                    // Only one bite at the hotzone apple per bootyset.
 | 
				
			||||
 | 
				
			||||
                    if (inHotzone == true && hotzoneWasRan == false) | 
				
			||||
                        if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) { | 
				
			||||
                            GenerateLootDrop(mob, bse.genTable + 1, true);  //generate loot drop from hotzone table
 | 
				
			||||
                            hotzoneWasRan = true; | 
				
			||||
                        } | 
				
			||||
 | 
				
			||||
                    break; | 
				
			||||
                case "ITEM": | 
				
			||||
                    GenerateInventoryDrop(mob, bse); | 
				
			||||
                    break; | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static MobLoot getGenTableItem(int genTableID, Mob mob, Boolean inHotzone) { | 
				
			||||
 | 
				
			||||
        if (mob == null || _genTables.containsKey(genTableID) == false) | 
				
			||||
            return null; | 
				
			||||
 | 
				
			||||
        MobLoot outItem; | 
				
			||||
 | 
				
			||||
        int genRoll = new Random().nextInt(99) + 1; | 
				
			||||
 | 
				
			||||
        GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); | 
				
			||||
 | 
				
			||||
        if (selectedRow == null) | 
				
			||||
            return null; | 
				
			||||
 | 
				
			||||
        int itemTableId = selectedRow.itemTableID; | 
				
			||||
 | 
				
			||||
        if (_itemTables.containsKey(itemTableId) == false) | 
				
			||||
            return null; | 
				
			||||
 | 
				
			||||
        //gets the 1-320 roll for this mob
 | 
				
			||||
 | 
				
			||||
        int itemTableRoll = TableRoll(mob.level, inHotzone); | 
				
			||||
 | 
				
			||||
        ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); | 
				
			||||
 | 
				
			||||
        if (tableRow == null) | 
				
			||||
            return null; | 
				
			||||
 | 
				
			||||
        int itemUUID = tableRow.cacheID; | 
				
			||||
 | 
				
			||||
        if (itemUUID == 0) | 
				
			||||
            return null; | 
				
			||||
 | 
				
			||||
        if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { | 
				
			||||
            int amount = ThreadLocalRandom.current().nextInt(tableRow.maxSpawn - tableRow.minSpawn) + tableRow.minSpawn; | 
				
			||||
            return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        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 (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) { | 
				
			||||
 | 
				
			||||
        GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); | 
				
			||||
 | 
				
			||||
        if (selectedRow == null) | 
				
			||||
            return inItem; | 
				
			||||
 | 
				
			||||
        int prefixroll = ThreadLocalRandom.current().nextInt(1, 100 + 1); | 
				
			||||
 | 
				
			||||
        ModTypeTableEntry prefixTable = ModTypeTableEntry.rollTable(selectedRow.pModTable, prefixroll); | 
				
			||||
 | 
				
			||||
        if (prefixTable == null) | 
				
			||||
            return inItem; | 
				
			||||
 | 
				
			||||
        ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, TableRoll(mob.level, inHotzone)); | 
				
			||||
 | 
				
			||||
        if (prefixMod == null) | 
				
			||||
            return inItem; | 
				
			||||
 | 
				
			||||
        if (prefixMod.action.length() > 0) { | 
				
			||||
            inItem.setPrefix(prefixMod.action); | 
				
			||||
            inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return inItem; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    private static MobLoot GenerateSuffix(Mob mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { | 
				
			||||
 | 
				
			||||
        GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll); | 
				
			||||
 | 
				
			||||
        if (selectedRow == null) | 
				
			||||
            return inItem; | 
				
			||||
 | 
				
			||||
        int suffixRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); | 
				
			||||
 | 
				
			||||
        ModTypeTableEntry suffixTable = ModTypeTableEntry.rollTable(selectedRow.sModTable, suffixRoll); | 
				
			||||
 | 
				
			||||
        if (suffixTable == null) | 
				
			||||
            return inItem; | 
				
			||||
 | 
				
			||||
        ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, TableRoll(mob.level, inHotzone)); | 
				
			||||
 | 
				
			||||
        if (suffixMod == null) | 
				
			||||
            return inItem; | 
				
			||||
 | 
				
			||||
        if (suffixMod.action.length() > 0) { | 
				
			||||
            inItem.setPrefix(suffixMod.action); | 
				
			||||
            inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, true); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        return inItem; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static int TableRoll(int mobLevel, Boolean inHotzone) { | 
				
			||||
 | 
				
			||||
        if (mobLevel > 65) | 
				
			||||
            mobLevel = 65; | 
				
			||||
 | 
				
			||||
        int max = (int) (4.882 * mobLevel + 127.0); | 
				
			||||
 | 
				
			||||
        if (max > 319) | 
				
			||||
            max = 319; | 
				
			||||
 | 
				
			||||
        int min = (int) (4.469 * mobLevel - 3.469); | 
				
			||||
 | 
				
			||||
        if (min < 70) | 
				
			||||
            min = 70; | 
				
			||||
 | 
				
			||||
        if (inHotzone) | 
				
			||||
            min += mobLevel; | 
				
			||||
 | 
				
			||||
        int roll = ThreadLocalRandom.current().nextInt(max - min) + min; | 
				
			||||
 | 
				
			||||
        return roll; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { | 
				
			||||
 | 
				
			||||
        int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); | 
				
			||||
 | 
				
			||||
        //early exit, failed to hit minimum chance roll
 | 
				
			||||
 | 
				
			||||
        if (chanceRoll > bse.dropChance) | 
				
			||||
            return; | 
				
			||||
 | 
				
			||||
        //determine and add gold to mob inventory
 | 
				
			||||
 | 
				
			||||
        int high = bse.highGold; | 
				
			||||
        int low = bse.lowGold; | 
				
			||||
        int gold = ThreadLocalRandom.current().nextInt(high - low) + low; | 
				
			||||
 | 
				
			||||
        if (inHotzone == true) | 
				
			||||
            gold = (int) (gold * HOTZONE_GOLD_RATE); | 
				
			||||
        else | 
				
			||||
            gold = (int) (gold * NORMAL_GOLD_RATE); | 
				
			||||
 | 
				
			||||
        if (gold > 0) { | 
				
			||||
            MobLoot goldAmount = new MobLoot(mob, gold); | 
				
			||||
            mob.getCharItemManager().addItemToInventory(goldAmount); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) { | 
				
			||||
 | 
				
			||||
        try { | 
				
			||||
 | 
				
			||||
            MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); | 
				
			||||
 | 
				
			||||
            if (toAdd != null) | 
				
			||||
                mob.getCharItemManager().addItemToInventory(toAdd); | 
				
			||||
 | 
				
			||||
        } catch (Exception e) { | 
				
			||||
            //TODO chase down loot generation error, affects roughly 2% of drops
 | 
				
			||||
            int i = 0; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static void GenerateEquipmentDrop(Mob mob) { | 
				
			||||
 | 
				
			||||
        //do equipment here
 | 
				
			||||
 | 
				
			||||
        if (mob.getEquip() != null) | 
				
			||||
            for (MobEquipment me : mob.getEquip().values()) { | 
				
			||||
 | 
				
			||||
                if (me.getDropChance() == 0) | 
				
			||||
                    continue; | 
				
			||||
 | 
				
			||||
                float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); | 
				
			||||
                float dropChance = me.getDropChance() * 100; | 
				
			||||
 | 
				
			||||
                if (equipmentRoll > dropChance) | 
				
			||||
                    continue; | 
				
			||||
 | 
				
			||||
                MobLoot ml = new MobLoot(mob, me.getItemBase(), false); | 
				
			||||
 | 
				
			||||
                if (ml != null) { | 
				
			||||
                    ml.setIsID(true); | 
				
			||||
                    ml.setDurabilityCurrent((short) (ml.getDurabilityCurrent() - ThreadLocalRandom.current().nextInt(5) + 1)); | 
				
			||||
                    mob.getCharItemManager().addItemToInventory(ml); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static void GenerateInventoryDrop(Mob mob, BootySetEntry bse) { | 
				
			||||
 | 
				
			||||
        int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); | 
				
			||||
 | 
				
			||||
        //early exit, failed to hit minimum chance roll
 | 
				
			||||
 | 
				
			||||
        if (chanceRoll > bse.dropChance) | 
				
			||||
            return; | 
				
			||||
 | 
				
			||||
        MobLoot lootItem = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); | 
				
			||||
 | 
				
			||||
        if (lootItem != null) | 
				
			||||
            mob.getCharItemManager().addItemToInventory(lootItem); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
@ -0,0 +1,45 @@
				@@ -0,0 +1,45 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
package engine.loot; | 
				
			||||
 | 
				
			||||
import engine.gameManager.LootManager; | 
				
			||||
 | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
import java.util.List; | 
				
			||||
 | 
				
			||||
public class GenTableEntry { | 
				
			||||
    public int minRoll; | 
				
			||||
    public int maxRoll; | 
				
			||||
    public int itemTableID; | 
				
			||||
    public int pModTable; | 
				
			||||
    public int sModTable; | 
				
			||||
 | 
				
			||||
    public GenTableEntry(ResultSet rs) throws SQLException { | 
				
			||||
        this.minRoll = rs.getInt("minRoll"); | 
				
			||||
        this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
        this.itemTableID = rs.getInt("itemTableID"); | 
				
			||||
        this.pModTable = rs.getInt("pModTableID"); | 
				
			||||
        this.sModTable = rs.getInt("sModTableID"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static GenTableEntry rollTable(int genTable, int roll) { | 
				
			||||
 | 
				
			||||
        GenTableEntry genTableEntry = null; | 
				
			||||
        List<GenTableEntry> genTableEntryList; | 
				
			||||
 | 
				
			||||
        genTableEntryList = LootManager._genTables.get(genTable); | 
				
			||||
 | 
				
			||||
        for (GenTableEntry iteration : genTableEntryList) | 
				
			||||
            if (roll >= iteration.minRoll && roll <= iteration.maxRoll) | 
				
			||||
                genTableEntry = iteration; | 
				
			||||
 | 
				
			||||
        return genTableEntry; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,45 @@
				@@ -0,0 +1,45 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
package engine.loot; | 
				
			||||
 | 
				
			||||
import engine.gameManager.LootManager; | 
				
			||||
 | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
import java.util.List; | 
				
			||||
 | 
				
			||||
public class ItemTableEntry { | 
				
			||||
    public int minRoll; | 
				
			||||
    public int maxRoll; | 
				
			||||
    public int cacheID; | 
				
			||||
    public int minSpawn; | 
				
			||||
    public int maxSpawn; | 
				
			||||
 | 
				
			||||
    public ItemTableEntry(ResultSet rs) throws SQLException { | 
				
			||||
        this.minRoll = rs.getInt("minRoll"); | 
				
			||||
        this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
        this.cacheID = rs.getInt("itemBaseUUID"); | 
				
			||||
        this.minSpawn = rs.getInt("minSpawn"); | 
				
			||||
        this.maxSpawn = rs.getInt("maxSpawn"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static ItemTableEntry rollTable(int itemTable, int roll) { | 
				
			||||
 | 
				
			||||
        ItemTableEntry itemTableEntry = null; | 
				
			||||
        List<ItemTableEntry> itemTableEntryList; | 
				
			||||
 | 
				
			||||
        itemTableEntryList = LootManager._itemTables.get(itemTable); | 
				
			||||
 | 
				
			||||
        for (ItemTableEntry iteration : itemTableEntryList) | 
				
			||||
            if (roll >= iteration.minRoll && roll <= iteration.maxRoll) | 
				
			||||
                itemTableEntry = iteration; | 
				
			||||
 | 
				
			||||
        return itemTableEntry; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,446 +0,0 @@
				@@ -1,446 +0,0 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
package engine.loot; | 
				
			||||
 | 
				
			||||
import engine.Enum; | 
				
			||||
import engine.gameManager.ConfigManager; | 
				
			||||
import engine.gameManager.DbManager; | 
				
			||||
import engine.gameManager.NPCManager; | 
				
			||||
import engine.gameManager.ZoneManager; | 
				
			||||
import engine.net.DispatchMessage; | 
				
			||||
import engine.net.client.msg.chat.ChatSystemMsg; | 
				
			||||
import engine.objects.*; | 
				
			||||
 | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
import java.util.ArrayList; | 
				
			||||
import java.util.HashMap; | 
				
			||||
import java.util.Random; | 
				
			||||
import java.util.concurrent.ThreadLocalRandom; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class contains static methods for data from Magicbane's loot tables | 
				
			||||
 */ | 
				
			||||
public class LootManager { | 
				
			||||
 | 
				
			||||
    //new tables
 | 
				
			||||
    private static final HashMap<Integer, GenTable> generalItemTables = new HashMap<>(); | 
				
			||||
    private static final HashMap<Integer, ItemTable> itemTables = new HashMap<>(); | 
				
			||||
    private static final HashMap<Integer, ModTypeTable> modTypeTables = new HashMap<>(); | 
				
			||||
    private static final HashMap<Integer, ModTable> modTables = new HashMap<>(); | 
				
			||||
 | 
				
			||||
    private LootManager() { | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    // Bootstrap routine to load loot data from database
 | 
				
			||||
    public static void loadLootData() { | 
				
			||||
        DbManager.LootQueries.LOAD_ALL_LOOTGROUPS(); | 
				
			||||
        DbManager.LootQueries.LOAD_ALL_LOOTTABLES(); | 
				
			||||
        DbManager.LootQueries.LOAD_ALL_MODGROUPS(); | 
				
			||||
        DbManager.LootQueries.LOAD_ALL_MODTABLES(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static void GenerateMobLoot(Mob mob, boolean fromDeath) { | 
				
			||||
        //determine if mob is in hotzone
 | 
				
			||||
        boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); | 
				
			||||
        //get multiplier form config manager
 | 
				
			||||
        float multiplier = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); | 
				
			||||
        if (inHotzone) { | 
				
			||||
            //if mob is inside hotzone, use the hotzone multiplier from the config instead
 | 
				
			||||
            multiplier = Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue()); | 
				
			||||
        } | 
				
			||||
        //iterate the booty sets
 | 
				
			||||
        if (mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet) == true) { | 
				
			||||
                RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, multiplier, inHotzone, fromDeath); | 
				
			||||
        } | 
				
			||||
        if (mob.bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.bootySet) == true) { | 
				
			||||
            RunBootySet(NPCManager._bootySetMap.get(mob.bootySet), mob, multiplier, inHotzone, fromDeath); | 
				
			||||
        } | 
				
			||||
        //lastly, check mobs inventory for godly or disc runes to send a server announcement
 | 
				
			||||
        if (!fromDeath) { | 
				
			||||
            for (Item it : mob.getInventory()) { | 
				
			||||
                ItemBase ib = it.getItemBase(); | 
				
			||||
                if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) { | 
				
			||||
                    ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ib.getName() + ". Are you tough enough to take it?"); | 
				
			||||
                    chatMsg.setMessageType(10); | 
				
			||||
                    chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); | 
				
			||||
                    DispatchMessage.dispatchMsgToAll(chatMsg); | 
				
			||||
                } | 
				
			||||
 | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) { | 
				
			||||
            if (fromDeath) { | 
				
			||||
                DropEquipment(mob,multiplier); | 
				
			||||
                return; | 
				
			||||
            } | 
				
			||||
            for (BootySetEntry bse : entries) { | 
				
			||||
                switch (bse.bootyType) { | 
				
			||||
                    case "GOLD": | 
				
			||||
                        GenerateGoldDrop(mob,bse,multiplier); | 
				
			||||
                        break; | 
				
			||||
                    case "LOOT": | 
				
			||||
                        GenerateNormalLootDrop(mob,bse,multiplier); | 
				
			||||
                        if (inHotzone && mob.level < 80) { | 
				
			||||
                            if (generalItemTables.containsKey(bse.lootTable + 1)) { | 
				
			||||
                                GenerateHotzoneLootDrop(mob, bse, multiplier); | 
				
			||||
                            } | 
				
			||||
                        } | 
				
			||||
                        if(mob.level > 80){ | 
				
			||||
                            RollForGlass(mob); | 
				
			||||
                        } | 
				
			||||
                        break; | 
				
			||||
                    case "ITEM": | 
				
			||||
                        GenerateItemLootDrop(mob,bse,multiplier); | 
				
			||||
                        break; | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
            if(inHotzone){ | 
				
			||||
                RollForGlass(mob); | 
				
			||||
            } | 
				
			||||
    } | 
				
			||||
    public static MobLoot getGenTableItem(int genTableID, Mob mob) { | 
				
			||||
            if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { | 
				
			||||
                return null; | 
				
			||||
            } | 
				
			||||
            MobLoot outItem; | 
				
			||||
            int genRoll = new Random().nextInt(100)+1; | 
				
			||||
            GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); | 
				
			||||
            if (selectedRow == null) { | 
				
			||||
                return null; | 
				
			||||
            } | 
				
			||||
            int itemTableId = selectedRow.itemTableID; | 
				
			||||
            //gets the 1-320 roll for this mob
 | 
				
			||||
            int roll2 = TableRoll(mob.level); | 
				
			||||
            ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2); | 
				
			||||
            if (tableRow == null) { | 
				
			||||
                return null; | 
				
			||||
            } | 
				
			||||
            int itemUUID = tableRow.cacheID; | 
				
			||||
            if (itemUUID == 0) { | 
				
			||||
                return null; | 
				
			||||
            } | 
				
			||||
            if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { | 
				
			||||
                int amount = ThreadLocalRandom.current().nextInt(tableRow.maxSpawn - tableRow.minSpawn) + tableRow.minSpawn; | 
				
			||||
                return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); | 
				
			||||
            } | 
				
			||||
            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) { | 
				
			||||
                    int prefixChanceRoll = ThreadLocalRandom.current().nextInt(100)+1; | 
				
			||||
                    double prefixChance = 2.057 * mob.level - 28.67; | 
				
			||||
                    if (prefixChanceRoll < prefixChance) { | 
				
			||||
                        ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); | 
				
			||||
 | 
				
			||||
                        int prefixroll = ThreadLocalRandom.current().nextInt(100)+1; | 
				
			||||
                        if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { | 
				
			||||
                            ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); | 
				
			||||
                            ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level)); | 
				
			||||
                            if (prefixMod != null && prefixMod.action.length() > 0) { | 
				
			||||
                                outItem.setPrefix(prefixMod.action); | 
				
			||||
                                outItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); | 
				
			||||
                            } | 
				
			||||
                        } | 
				
			||||
                    } | 
				
			||||
                    int suffixChanceRoll = ThreadLocalRandom.current().nextInt(100)+1; | 
				
			||||
                    double suffixChance = 2.057 * mob.level - 28.67; | 
				
			||||
                    if (suffixChanceRoll < suffixChance) { | 
				
			||||
                        int suffixroll = ThreadLocalRandom.current().nextInt(100)+1; | 
				
			||||
                        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(TableRoll(mob.level)); | 
				
			||||
                            if (suffixMod != null && suffixMod.action.length() > 0) { | 
				
			||||
                                outItem.setSuffix(suffixMod.action); | 
				
			||||
                                outItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); | 
				
			||||
                            } | 
				
			||||
                        } | 
				
			||||
                    } | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
            return outItem; | 
				
			||||
    } | 
				
			||||
    private static int TableRoll(int mobLevel){ | 
				
			||||
        if(mobLevel > 65){ | 
				
			||||
            mobLevel = 65; | 
				
			||||
        } | 
				
			||||
        int max = (int)(4.882 * mobLevel + 127.0); | 
				
			||||
        if(max > 321){ | 
				
			||||
            max = 321; | 
				
			||||
        } | 
				
			||||
        int min = (int)(4.469 * mobLevel - 3.469); | 
				
			||||
        int roll = ThreadLocalRandom.current().nextInt(max-min) + min; | 
				
			||||
        return roll; | 
				
			||||
    } | 
				
			||||
    public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, float multiplier){ | 
				
			||||
        int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; | 
				
			||||
        if (chanceRoll > bse.dropChance) { | 
				
			||||
            //early exit, failed to hit minimum chance roll OR booty was generated from mob's death
 | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
        //determine and add gold to mob inventory
 | 
				
			||||
        int high = (int)(bse.highGold * multiplier); | 
				
			||||
        int low = (int)(bse.lowGold * multiplier); | 
				
			||||
        int gold = ThreadLocalRandom.current().nextInt(high - low) + low; | 
				
			||||
        if (gold > 0) { | 
				
			||||
            MobLoot goldAmount = new MobLoot(mob, (int) (gold * multiplier)); | 
				
			||||
            mob.getCharItemManager().addItemToInventory(goldAmount); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static void GenerateNormalLootDrop(Mob mob, BootySetEntry bse,float multiplier){ | 
				
			||||
        try{ | 
				
			||||
        int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; | 
				
			||||
        if (chanceRoll > bse.dropChance * multiplier) { | 
				
			||||
            //early exit, failed to hit minimum chance roll
 | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
        //iterate the booty tables and add items to mob inventory
 | 
				
			||||
        MobLoot toAdd = getGenTableItem(bse.lootTable, mob); | 
				
			||||
        if (toAdd != null) { | 
				
			||||
            if(toAdd.getPrefix() == null && toAdd.getSuffix() == null){ | 
				
			||||
                toAdd.setIsID(true); | 
				
			||||
            } | 
				
			||||
            mob.getCharItemManager().addItemToInventory(toAdd); | 
				
			||||
        } | 
				
			||||
        } | 
				
			||||
        catch(Exception e){ | 
				
			||||
            //TODO chase down loot generation error, affects roughly 2% of drops
 | 
				
			||||
            int i = 0; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static void GenerateHotzoneLootDrop(Mob mob, BootySetEntry bse, float multiplier){ | 
				
			||||
            int lootTableID = bse.lootTable + 1; | 
				
			||||
            int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; | 
				
			||||
            if (chanceRoll > bse.dropChance * multiplier) { | 
				
			||||
                //early exit, failed to hit minimum chance roll
 | 
				
			||||
                return; | 
				
			||||
            } | 
				
			||||
            MobLoot toAdd = getGenTableItem(lootTableID, mob); | 
				
			||||
            if (toAdd != null) { | 
				
			||||
                if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) { | 
				
			||||
                    toAdd.setIsID(true); | 
				
			||||
                } | 
				
			||||
                mob.getCharItemManager().addItemToInventory(toAdd); | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
    public static void RollForGlass(Mob mob){ | 
				
			||||
        int glassRoll = ThreadLocalRandom.current().nextInt(100) + 1; | 
				
			||||
        if (glassRoll >= 99) { | 
				
			||||
            int roll2 = TableRoll(mob.level); | 
				
			||||
            if (itemTables.get(126).getRowForRange(roll2) == null) { | 
				
			||||
                return; | 
				
			||||
            } | 
				
			||||
            ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2); | 
				
			||||
            if (tableRow == null) { | 
				
			||||
                return; | 
				
			||||
            } | 
				
			||||
            int itemUUID = tableRow.cacheID; | 
				
			||||
            if (itemUUID == 0) { | 
				
			||||
                return; | 
				
			||||
            } | 
				
			||||
            MobLoot toAddHZ = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); | 
				
			||||
            if (toAddHZ != null) | 
				
			||||
                mob.getCharItemManager().addItemToInventory(toAddHZ); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static void DropEquipment(Mob mob, float multiplier){ | 
				
			||||
        //do equipment here
 | 
				
			||||
        if (mob.getEquip() != null) { | 
				
			||||
            for (MobEquipment me : mob.getEquip().values()) { | 
				
			||||
                if (me.getDropChance() == 0) | 
				
			||||
                    continue; | 
				
			||||
                float equipmentRoll = ThreadLocalRandom.current().nextInt(101); | 
				
			||||
                float dropChance = me.getDropChance() * 100; | 
				
			||||
                if (equipmentRoll <= (dropChance * multiplier)) { | 
				
			||||
                    MobLoot ml = new MobLoot(mob, me.getItemBase(), false); | 
				
			||||
                    if (ml.getPrefix().isEmpty() == true && ml.getSuffix().isEmpty() == true) { | 
				
			||||
                        ml.setIsID(true); | 
				
			||||
                    } | 
				
			||||
                    mob.getCharItemManager().addItemToInventory(ml); | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
        return; | 
				
			||||
    } | 
				
			||||
    public static void GenerateItemLootDrop(Mob mob, BootySetEntry bse, float multiplier){ | 
				
			||||
        int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1; | 
				
			||||
        if (chanceRoll > bse.dropChance * multiplier) { | 
				
			||||
            //early exit, failed to hit minimum chance roll
 | 
				
			||||
            return; | 
				
			||||
        } | 
				
			||||
        MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); | 
				
			||||
        if (disc != null) | 
				
			||||
            mob.getCharItemManager().addItemToInventory(disc); | 
				
			||||
    } | 
				
			||||
    public static void AddGenTableRow(int tableID, GenTableRow row) { | 
				
			||||
        if (!generalItemTables.containsKey(tableID)) { | 
				
			||||
            //create the new table
 | 
				
			||||
            GenTable gt = new GenTable(); | 
				
			||||
            gt.rows.add(row); | 
				
			||||
            generalItemTables.put(tableID, gt); | 
				
			||||
        } else { | 
				
			||||
            //add row to existing table
 | 
				
			||||
            GenTable toAdd = generalItemTables.get(tableID); | 
				
			||||
            toAdd.rows.add(row); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static void AddItemTableRow(int tableID, ItemTableRow row) { | 
				
			||||
        if (!itemTables.containsKey(tableID)) { | 
				
			||||
            //create the new table
 | 
				
			||||
            ItemTable it = new ItemTable(); | 
				
			||||
            it.rows.add(row); | 
				
			||||
            itemTables.put(tableID, it); | 
				
			||||
        } else { | 
				
			||||
            //add row to existing table
 | 
				
			||||
            ItemTable toAdd = itemTables.get(tableID); | 
				
			||||
            toAdd.rows.add(row); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static void AddModTypeTableRow(int tableID, ModTypeTableRow row) { | 
				
			||||
        if (!modTypeTables.containsKey(tableID)) { | 
				
			||||
            //create the new table
 | 
				
			||||
            ModTypeTable mtt = new ModTypeTable(); | 
				
			||||
            mtt.rows.add(row); | 
				
			||||
            modTypeTables.put(tableID, mtt); | 
				
			||||
        } else { | 
				
			||||
            //add row to existing table
 | 
				
			||||
            ModTypeTable toAdd = modTypeTables.get(tableID); | 
				
			||||
            toAdd.rows.add(row); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static void AddModTableRow(int tableID, ModTableRow row) { | 
				
			||||
        if (!modTables.containsKey(tableID)) { | 
				
			||||
            //create the new table
 | 
				
			||||
            ModTable mt = new ModTable(); | 
				
			||||
            mt.rows.add(row); | 
				
			||||
            modTables.put(tableID, mt); | 
				
			||||
        } else { | 
				
			||||
            //add row to existing table
 | 
				
			||||
            ModTable toAdd = modTables.get(tableID); | 
				
			||||
            toAdd.rows.add(row); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class GenTable { | 
				
			||||
        public ArrayList<GenTableRow> rows = new ArrayList<GenTableRow>(); | 
				
			||||
 | 
				
			||||
        public GenTableRow getRowForRange(int roll) { | 
				
			||||
            GenTableRow outRow = null; | 
				
			||||
            for (GenTableRow iteration : this.rows) { | 
				
			||||
                if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { | 
				
			||||
                    outRow = iteration; | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
            return outRow; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class ItemTable { | 
				
			||||
        public ArrayList<ItemTableRow> rows = new ArrayList<ItemTableRow>(); | 
				
			||||
 | 
				
			||||
        public ItemTableRow getRowForRange(int roll) { | 
				
			||||
            if (roll > 320) { | 
				
			||||
                roll = 320; | 
				
			||||
            } | 
				
			||||
            ItemTableRow outRow = null; | 
				
			||||
            for (ItemTableRow iteration : this.rows) { | 
				
			||||
                if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { | 
				
			||||
                    outRow = iteration; | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
            return outRow; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class ModTypeTable { | 
				
			||||
        public ArrayList<ModTypeTableRow> rows = new ArrayList<ModTypeTableRow>(); | 
				
			||||
 | 
				
			||||
        public ModTypeTableRow getRowForRange(int roll) { | 
				
			||||
            ModTypeTableRow outRow = null; | 
				
			||||
            for (ModTypeTableRow iteration : this.rows) { | 
				
			||||
                if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { | 
				
			||||
                    return iteration; | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
            return outRow; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class ModTable { | 
				
			||||
        public ArrayList<ModTableRow> rows = new ArrayList<ModTableRow>(); | 
				
			||||
 | 
				
			||||
        public ModTableRow getRowForRange(int roll) { | 
				
			||||
            if (roll > 320) { | 
				
			||||
                roll = 320; | 
				
			||||
            } | 
				
			||||
            ModTableRow outRow = null; | 
				
			||||
            for (ModTableRow iteration : this.rows) { | 
				
			||||
                if (roll >= iteration.minRoll && roll <= iteration.maxRoll) { | 
				
			||||
                    outRow = iteration; | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
            return outRow; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class GenTableRow { | 
				
			||||
        public int minRoll; | 
				
			||||
        public int maxRoll; | 
				
			||||
        public int itemTableID; | 
				
			||||
        public int pModTable; | 
				
			||||
        public int sModTable; | 
				
			||||
 | 
				
			||||
        public GenTableRow(ResultSet rs) throws SQLException { | 
				
			||||
            this.minRoll = rs.getInt("minRoll"); | 
				
			||||
            this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
            this.itemTableID = rs.getInt("lootTableID"); | 
				
			||||
            this.pModTable = rs.getInt("pModTableID"); | 
				
			||||
            this.sModTable = rs.getInt("sModTableID"); | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class ItemTableRow { | 
				
			||||
        public int minRoll; | 
				
			||||
        public int maxRoll; | 
				
			||||
        public int cacheID; | 
				
			||||
        public int minSpawn; | 
				
			||||
        public int maxSpawn; | 
				
			||||
 | 
				
			||||
        public ItemTableRow(ResultSet rs) throws SQLException { | 
				
			||||
            this.minRoll = rs.getInt("minRoll"); | 
				
			||||
            this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
            this.cacheID = rs.getInt("itemBaseUUID"); | 
				
			||||
            this.minSpawn = rs.getInt("minSpawn"); | 
				
			||||
            this.maxSpawn = rs.getInt("maxSpawn"); | 
				
			||||
 | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class ModTypeTableRow { | 
				
			||||
        public int minRoll; | 
				
			||||
        public int maxRoll; | 
				
			||||
        public int modTableID; | 
				
			||||
 | 
				
			||||
        public ModTypeTableRow(ResultSet rs) throws SQLException { | 
				
			||||
            this.minRoll = rs.getInt("minRoll"); | 
				
			||||
            this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
            this.modTableID = rs.getInt("subTableID"); | 
				
			||||
 | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    public static class ModTableRow { | 
				
			||||
        public int minRoll; | 
				
			||||
        public int maxRoll; | 
				
			||||
        public String action; | 
				
			||||
        public int level; | 
				
			||||
 | 
				
			||||
        public ModTableRow(ResultSet rs) throws SQLException { | 
				
			||||
            this.minRoll = rs.getInt("minRoll"); | 
				
			||||
            this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
            this.action = rs.getString("action"); | 
				
			||||
            this.level = rs.getInt("level"); | 
				
			||||
 | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,43 @@
				@@ -0,0 +1,43 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
package engine.loot; | 
				
			||||
 | 
				
			||||
import engine.gameManager.LootManager; | 
				
			||||
 | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
import java.util.List; | 
				
			||||
 | 
				
			||||
public class ModTableEntry { | 
				
			||||
    public int minRoll; | 
				
			||||
    public int maxRoll; | 
				
			||||
    public String action; | 
				
			||||
    public int level; | 
				
			||||
 | 
				
			||||
    public ModTableEntry(ResultSet rs) throws SQLException { | 
				
			||||
        this.minRoll = rs.getInt("minRoll"); | 
				
			||||
        this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
        this.action = rs.getString("action"); | 
				
			||||
        this.level = rs.getInt("level"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static ModTableEntry rollTable(int modTablwe, int roll) { | 
				
			||||
 | 
				
			||||
        ModTableEntry modTableEntry = null; | 
				
			||||
        List<ModTableEntry> itemTableEntryList; | 
				
			||||
 | 
				
			||||
        itemTableEntryList = LootManager._modTables.get(modTablwe); | 
				
			||||
 | 
				
			||||
        for (ModTableEntry iteration : itemTableEntryList) | 
				
			||||
            if (roll >= iteration.minRoll && roll <= iteration.maxRoll) | 
				
			||||
                modTableEntry = iteration; | 
				
			||||
 | 
				
			||||
        return modTableEntry; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,41 @@
				@@ -0,0 +1,41 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
package engine.loot; | 
				
			||||
 | 
				
			||||
import engine.gameManager.LootManager; | 
				
			||||
 | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
import java.util.List; | 
				
			||||
 | 
				
			||||
public class ModTypeTableEntry { | 
				
			||||
    public int minRoll; | 
				
			||||
    public int maxRoll; | 
				
			||||
    public int modTableID; | 
				
			||||
 | 
				
			||||
    public ModTypeTableEntry(ResultSet rs) throws SQLException { | 
				
			||||
        this.minRoll = rs.getInt("minRoll"); | 
				
			||||
        this.maxRoll = rs.getInt("maxRoll"); | 
				
			||||
        this.modTableID = rs.getInt("subTableID"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public static ModTypeTableEntry rollTable(int modTablwe, int roll) { | 
				
			||||
 | 
				
			||||
        ModTypeTableEntry modTypeTableEntry = null; | 
				
			||||
        List<ModTypeTableEntry> modTypeTableEntryList; | 
				
			||||
 | 
				
			||||
        modTypeTableEntryList = LootManager._modTypeTables.get(modTablwe); | 
				
			||||
 | 
				
			||||
        for (ModTypeTableEntry iteration : modTypeTableEntryList) | 
				
			||||
            if (roll >= iteration.minRoll && roll <= iteration.maxRoll) | 
				
			||||
                modTypeTableEntry = iteration; | 
				
			||||
 | 
				
			||||
        return modTypeTableEntry; | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,63 +0,0 @@
				@@ -1,63 +0,0 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.objects; | 
				
			||||
 | 
				
			||||
public class LootRow { | 
				
			||||
 | 
				
			||||
    private int valueOne; | 
				
			||||
    private int valueTwo; | 
				
			||||
    private int valueThree; | 
				
			||||
    private String action; | 
				
			||||
 | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Generic Constructor | 
				
			||||
     */ | 
				
			||||
    public LootRow(int valueOne, int valueTwo, int valueThree, String action) { | 
				
			||||
        this.valueOne = valueOne; | 
				
			||||
        this.valueTwo = valueTwo; | 
				
			||||
        this.valueThree = valueThree; | 
				
			||||
        this.action = action; | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public int getValueOne() { | 
				
			||||
        return this.valueOne; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void setValueOne(int value) { | 
				
			||||
        this.valueOne = value; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public int getValueTwo() { | 
				
			||||
        return this.valueTwo; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void setValueTwo(int value) { | 
				
			||||
        this.valueTwo = value; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public int getValueThree() { | 
				
			||||
        return this.valueThree; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void setValueThree(int value) { | 
				
			||||
        this.valueThree = value; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public String getAction() { | 
				
			||||
        return this.action; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void setAction(String value) { | 
				
			||||
        this.action = value; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
									
										
											File diff suppressed because it is too large
											Load Diff
										
									
								
							
						@ -1,59 +0,0 @@
				@@ -1,59 +0,0 @@
					 | 
				
			||||
// • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | 
				
			||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | 
				
			||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | 
				
			||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | 
				
			||||
// ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | 
				
			||||
//      Magicbane Emulator Project © 2013 - 2022
 | 
				
			||||
//                www.magicbane.com
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
package engine.objects; | 
				
			||||
 | 
				
			||||
import java.sql.ResultSet; | 
				
			||||
import java.sql.SQLException; | 
				
			||||
import java.util.ArrayList; | 
				
			||||
import java.util.HashMap; | 
				
			||||
 | 
				
			||||
public class MobLootBase { | 
				
			||||
 | 
				
			||||
    public static HashMap<Integer, ArrayList<MobLootBase>> MobLootSet = new HashMap<>(); | 
				
			||||
    private int mobBaseID; | 
				
			||||
    private int lootTableID; | 
				
			||||
    private float chance; | 
				
			||||
 | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * ResultSet Constructor | 
				
			||||
     */ | 
				
			||||
 | 
				
			||||
    public MobLootBase(ResultSet rs) throws SQLException { | 
				
			||||
        this.mobBaseID = rs.getInt("mobBaseID"); | 
				
			||||
        this.lootTableID = rs.getInt("lootTable"); | 
				
			||||
        this.chance = rs.getFloat("chance"); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public MobLootBase(int mobBaseID, int lootTableID, int chance) { | 
				
			||||
        super(); | 
				
			||||
        this.mobBaseID = mobBaseID; | 
				
			||||
        this.lootTableID = lootTableID; | 
				
			||||
        this.chance = chance; | 
				
			||||
 | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public int getMobBaseID() { | 
				
			||||
        return mobBaseID; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public float getChance() { | 
				
			||||
        return chance; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public int getLootTableID() { | 
				
			||||
        return lootTableID; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public void setLootTableID(int lootTableID) { | 
				
			||||
        this.lootTableID = lootTableID; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue