Browse Source

place holder

master
FatBoy-DOTC 2 years ago
parent
commit
95352e778d
  1. 228
      src/engine/db/handlers/dbLootTableHandler.java
  2. 114
      src/engine/loot/LootGroup.java
  3. 428
      src/engine/loot/LootManager.java
  4. 98
      src/engine/loot/LootTable.java
  5. 78
      src/engine/loot/ModifierGroup.java
  6. 88
      src/engine/loot/ModifierTable.java
  7. 2
      src/engine/objects/MobBase.java

228
src/engine/db/handlers/dbLootTableHandler.java

@ -9,10 +9,7 @@
package engine.db.handlers; package engine.db.handlers;
import engine.loot.LootGroup;
import engine.loot.LootManager; import engine.loot.LootManager;
import engine.loot.ModifierGroup;
import engine.loot.ModifierTable;
import engine.objects.Item; import engine.objects.Item;
import engine.objects.LootTable; import engine.objects.LootTable;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -30,7 +27,7 @@ public class dbLootTableHandler extends dbHandlerBase {
public void populateLootGroups() { public void populateLootGroups() {
int recordsRead = 0; int recordsRead = 0;
prepareCallable("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_lootgroups`"); prepareCallable("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_lootgroups`");
try { try {
ResultSet rs = executeQuery(); ResultSet rs = executeQuery();
if (rs != null) if (rs != null)
@ -39,7 +36,7 @@ public class dbLootTableHandler extends dbHandlerBase {
LootTable lootTable = LootTable.getLootGroup(rs.getInt("groupID")); LootTable lootTable = LootTable.getLootGroup(rs.getInt("groupID"));
lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("lootTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), ""); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("lootTableID"), rs.getInt("pModTableID"), rs.getInt("sModTableID"), "");
} }
Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootGroups().size()); Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootGroups().size());
} catch (SQLException e) { } catch (SQLException e) {
} finally { } finally {
@ -49,9 +46,9 @@ public class dbLootTableHandler extends dbHandlerBase {
public void populateLootTables() { public void populateLootTables() {
int recordsRead = 0; int recordsRead = 0;
prepareCallable("SELECT `lootTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_loottables`"); prepareCallable("SELECT `lootTable`, `minRoll`, `maxRoll`, `itemBaseUUID`, `minSpawn`, `maxSpawn` FROM `static_loottables`");
try { try {
ResultSet rs = executeQuery(); ResultSet rs = executeQuery();
if (rs != null) if (rs != null)
@ -60,8 +57,8 @@ public class dbLootTableHandler extends dbHandlerBase {
LootTable lootTable = LootTable.getLootTable(rs.getInt("lootTable")); LootTable lootTable = LootTable.getLootTable(rs.getInt("lootTable"));
lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemBaseUUID"), rs.getInt("minSpawn"), rs.getInt("maxSpawn"), ""); lootTable.addRow(rs.getFloat("minRoll"), rs.getFloat("maxRoll"), rs.getInt("itemBaseUUID"), rs.getInt("minSpawn"), rs.getInt("maxSpawn"), "");
} }
Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootTables().size()); Logger.info("read: " + recordsRead + " cached: " + LootTable.getLootTables().size());
} catch (SQLException e) { } catch (SQLException e) {
} finally { } finally {
closeCallable(); closeCallable();
@ -69,11 +66,11 @@ public class dbLootTableHandler extends dbHandlerBase {
} }
public void populateModTables() { public void populateModTables() {
int recordsRead = 0; int recordsRead = 0;
prepareCallable("SELECT `modTable`,`minRoll`,`maxRoll`,`value`,`action` FROM `static_modtables`"); prepareCallable("SELECT `modTable`,`minRoll`,`maxRoll`,`value`,`action` FROM `static_modtables`");
try { try {
ResultSet rs = executeQuery(); ResultSet rs = executeQuery();
if (rs != null) if (rs != null)
@ -90,11 +87,11 @@ public class dbLootTableHandler extends dbHandlerBase {
} }
public void populateModGroups() { public void populateModGroups() {
int recordsRead = 0; int recordsRead = 0;
prepareCallable("SELECT `modGroup`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modgroups`"); prepareCallable("SELECT `modGroup`,`minRoll`,`maxRoll`,`subTableID` FROM `static_modgroups`");
try { try {
ResultSet rs = executeQuery(); ResultSet rs = executeQuery();
if (rs != null) if (rs != null)
@ -111,10 +108,10 @@ public class dbLootTableHandler extends dbHandlerBase {
} }
public void LOAD_ENCHANT_VALUES() { public void LOAD_ENCHANT_VALUES() {
prepareCallable("SELECT `IDString`, `minMod` FROM `static_power_effectmod` WHERE `modType` = ?"); prepareCallable("SELECT `IDString`, `minMod` FROM `static_power_effectmod` WHERE `modType` = ?");
setString(1,"Value"); setString(1,"Value");
try { try {
ResultSet rs = executeQuery(); ResultSet rs = executeQuery();
while (rs.next()) { while (rs.next()) {
@ -126,108 +123,99 @@ public class dbLootTableHandler extends dbHandlerBase {
closeCallable(); closeCallable();
} }
} }
public void LOAD_ALL_LOOTGROUPS() { public void LOAD_ALL_LOOTGROUPS() {
int recordsRead = 0;
LootGroup lootGroup;
int recordsRead = 0; prepareCallable("SELECT * FROM static_lootgroups");
prepareCallable("SELECT * FROM static_lootgroups"); try {
ResultSet rs = executeQuery();
try {
ResultSet rs = executeQuery(); while (rs.next()) {
LootManager.GenTable gt = new LootManager.GenTable();
while (rs.next()) { LootManager.AddGenTableRow(rs.getInt("groupID"),gt,new LootManager.GenTableRow(rs));
}
recordsRead++;
lootGroup = new LootGroup(rs); Logger.info( "read: " + recordsRead);
LootManager.addLootGroup(lootGroup);
} } catch (SQLException e) {
Logger.error( e.getErrorCode() + ' ' + e.getMessage(), e);
Logger.info( "read: " + recordsRead); } finally {
closeCallable();
} catch (SQLException e) { }
Logger.error( e.getErrorCode() + ' ' + e.getMessage(), e); }
} finally {
closeCallable(); public void LOAD_ALL_LOOTTABLES() {
}
} int recordsRead = 0;
public void LOAD_ALL_LOOTTABLES() { prepareCallable("SELECT * FROM static_loottables");
engine.loot.LootTable lootTable; try {
int recordsRead = 0; ResultSet rs = executeQuery();
prepareCallable("SELECT * FROM static_loottables"); while (rs.next()) {
try { recordsRead++;
ResultSet rs = executeQuery(); LootManager.ItemTable it = new LootManager.ItemTable();
LootManager.AddItemTableRow(rs.getInt("lootTable"),it,new LootManager.ItemTableRow(rs));
while (rs.next()) { }
recordsRead++; Logger.info("read: " + recordsRead);
lootTable = new engine.loot.LootTable(rs);
LootManager.addLootTable(lootTable); } catch (SQLException e) {
} Logger.error( e.getErrorCode() + ' ' + e.getMessage(), e);
} finally {
Logger.info("read: " + recordsRead); closeCallable();
}
} catch (SQLException e) { }
Logger.error( e.getErrorCode() + ' ' + e.getMessage(), e);
} finally { public void LOAD_ALL_MODGROUPS() {
closeCallable(); int recordsRead = 0;
}
} prepareCallable("SELECT * FROM static_modgroups");
public void LOAD_ALL_MODGROUPS() { try {
ResultSet rs = executeQuery();
ModifierGroup modGroup;
int recordsRead = 0; while (rs.next()) {
prepareCallable("SELECT * FROM static_modgroups"); recordsRead++;
LootManager.ModTypeTable mtt = new LootManager.ModTypeTable();
try { LootManager.AddModTypeTableRow(rs.getInt("modGroup"),mtt,new LootManager.ModTypeTableRow(rs));
ResultSet rs = executeQuery(); }
while (rs.next()) { Logger.info( "read: " + recordsRead);
recordsRead++; } catch (SQLException e) {
modGroup = new ModifierGroup(rs); Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e);
LootManager.addModifierGroup(modGroup); } finally {
} closeCallable();
}
Logger.info( "read: " + recordsRead); }
} catch (SQLException e) { public void LOAD_ALL_MODTABLES() {
Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e); int recordsRead = 0;
} finally {
closeCallable(); prepareCallable("SELECT * FROM static_modtables");
}
} try {
ResultSet rs = executeQuery();
public void LOAD_ALL_MODTABLES() {
while (rs.next()) {
ModifierTable modTable;
int recordsRead = 0; recordsRead++;
LootManager.ModTable mt = new LootManager.ModTable();
prepareCallable("SELECT * FROM static_modtables"); LootManager.AddModTableRow(rs.getInt("modTable"),mt,new LootManager.ModTableRow(rs));
}
try {
ResultSet rs = executeQuery(); Logger.info( "read: " + recordsRead);
while (rs.next()) { } catch (SQLException e) {
Logger.error( e.getErrorCode() + ' ' + e.getMessage(), e);
recordsRead++; } finally {
modTable = new ModifierTable(rs); closeCallable();
LootManager.addModifierTable(modTable); }
} }
Logger.info( "read: " + recordsRead);
} catch (SQLException e) {
Logger.error( e.getErrorCode() + ' ' + e.getMessage(), e);
} finally {
closeCallable();
}
}
} }

114
src/engine/loot/LootGroup.java

@ -1,114 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.loot;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Data storage object for Loot System.
* Holds row in the lootGroup database table
*/
public class LootGroup {
private final int groupID;
private final String groupName;
private final int minRoll;
private final int maxRoll;
private final int lootTableID;
private final String lootTableName;
private final int pMod;
private final int pModTableID;
private final int sMod;
private final int sModTableID;
public LootGroup(ResultSet rs) throws SQLException {
this.groupID = rs.getInt("groupID");
this.groupName = rs.getString("groupName");
this.minRoll = rs.getInt("minRoll");
this.maxRoll = rs.getInt("maxRoll");
this.lootTableID = rs.getInt("lootTableID");
this.lootTableName = rs.getString("lootTableName");
this.pMod = rs.getInt("pMod");
this.pModTableID = rs.getInt("pModTableID");
this.sMod = rs.getInt("sMod");
this.sModTableID = rs.getInt("sModTableID");
}
/**
* @return the groupID
*/
public int getGroupID() {
return groupID;
}
/**
* @return the groupName
*/
public String getGroupName() {
return groupName;
}
/**
* @return the minRoll
*/
public int getMinRoll() {
return minRoll;
}
/**
* @return the maxRoll
*/
public int getMaxRoll() {
return maxRoll;
}
/**
* @return the lootTableID
*/
public int getLootTableID() {
return lootTableID;
}
/**
* @return the lootTableName
*/
public String getLootTableName() {
return lootTableName;
}
/**
* @return the pMod
*/
public int getpMod() {
return pMod;
}
/**
* @return the pModTableID
*/
public int getpModTableID() {
return pModTableID;
}
/**
* @return the sMod
*/
public int getsMod() {
return sMod;
}
/**
* @return the sModTableID
*/
public int getsModTableID() {
return sModTableID;
}
}

428
src/engine/loot/LootManager.java

@ -8,11 +8,18 @@
package engine.loot; package engine.loot;
import engine.Enum;
import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.objects.Item; 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.HashMap;
import java.util.TreeMap; import java.util.Random;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
/** /**
@ -20,212 +27,239 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
public class LootManager { public class LootManager {
private static final HashMap<Integer, TreeMap<Integer, LootGroup>> _lootGroups = new HashMap<>(); //new tables
private static final HashMap<Integer, TreeMap<Integer, LootTable>> _lootTables = new HashMap<>(); private static final HashMap<Integer,GenTable> generalItemTables = new HashMap<>();
private static final HashMap<Integer, TreeMap<Integer, ModifierGroup>> _modGroups = new HashMap<>(); private static final HashMap<Integer,ItemTable> itemTables = new HashMap<>();
private static final HashMap<Integer, TreeMap> _modTables = new HashMap<>(); private static final HashMap<Integer,ModTypeTable> modTypeTables = new HashMap<>();
private static final HashMap<Integer,ModTable> modTables = new HashMap<>();
private LootManager() {
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){
// Method adds a lootGroup to the class's internal collection //determine if mob is in hotzone
// and configures the treemap accordingly boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
//get multiplier form config manager
public static void addLootGroup(LootGroup lootGroup) { float multiplier = Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue());
if (inHotzone) {
// If entry for this lootGroup does not currently exist //if mob is inside hotzone, use the hotzone gold multiplier form the config instead
// we need to create one. multiplier = Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue());
}
if (_lootGroups.containsKey(lootGroup.getGroupID()) == false) //iterate the booty sets
_lootGroups.put(lootGroup.getGroupID(), new TreeMap<>()); for(BootySetEntry bse : mob.getMobBase().bootySets) {
//check if chance roll is good
// Add this lootgroup to the appropriate treemap if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier)) {
//early exit, failed to hit minimum chance roll
_lootGroups.get(lootGroup.getGroupID()).put(lootGroup.getMaxRoll(), lootGroup); continue;
}
if (bse.bootyType.equals("GOLD")) {
//determine and add gold to mob inventory
int gold = new Random().nextInt(bse.highGold - bse.lowGold) + bse.lowGold;
if (gold > 0) {
MobLoot goldAmount = new MobLoot(mob, (int) (gold * multiplier));
mob.getCharItemManager().addItemToInventory(goldAmount);
}
} else if (bse.bootyType.equals("BOOTYTABLE")) {
//iterate the booty tables and add items to mob inventory
Item toAdd = getGenTableItem(bse.lootTable, mob);
if(toAdd != null) {
mob.getCharItemManager().addItemToInventory(toAdd);
}
if (inHotzone) {
Item toAddHZ = getGenTableItem(bse.lootTable + 1, mob);
mob.getCharItemManager().addItemToInventory(toAddHZ);
}
}
}
//lastly, check mobs inventory for godly or disc runes to send a server announcement
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);
}
}
} }
public static Item getGenTableItem(int genTableID, Mob mob){
public static void addLootTable(engine.loot.LootTable lootTable) { Item outItem;
int minRollRange = mob.getParentZone().minLvl + mob.getLevel();
// If entry for this lootTabe does not currently exist int maxRollRange = (mob.getParentZone().minLvl + mob.getLevel() + mob.getParentZone().maxLvl) * 2;
// we need to create one. GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(new Random().nextInt(100));
int itemUUID = itemTables.get(selectedRow.itemTableID).getRowForRange(new Random().nextInt(maxRollRange) + minRollRange).cacheID;
if (_lootTables.containsKey(lootTable.getLootTable()) == false) if(itemUUID == 0){
_lootTables.put(lootTable.getLootTable(), return null;
new TreeMap<>()); }
ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable);
// Add this lootTable to the appropriate treemap ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable);
ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(100).modTableID);
_lootTables.get(lootTable.getLootTable()).put(lootTable.getMaxRoll(), lootTable); ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(100).modTableID);
ModTableRow prefixMod = prefixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange);
ModTableRow suffixMod = suffixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange);
outItem = Item.getItem(itemUUID);
if(prefixMod.action.length() > 0){
outItem.addPermanentEnchantment(prefixMod.action, prefixMod.level);
}
if(suffixMod.action.length() > 0){
outItem.addPermanentEnchantment(suffixMod.action, suffixMod.level);
}
return outItem;
} }
public static void AddGenTableRow(int tableID, GenTable genTable, GenTableRow row){
public static void addModifierGroup(ModifierGroup modGroup) { if(!generalItemTables.containsKey(tableID)){
//create the new table
// If entry for this lootTabe does not currently exist generalItemTables.put(tableID,genTable);
// we need to create one. //add row to new table
generalItemTables.get(tableID).rows.add(row);
if (_modGroups.containsKey(modGroup.getModGroup()) == false) } else{
_modGroups.put(modGroup.getModGroup(), //add row to existing table
new TreeMap<>()); GenTable toAdd = generalItemTables.get(tableID);
toAdd.rows.add(row);
// Add this lootTable to the appropriate treemap }
_modGroups.get(modGroup.getModGroup()).put(modGroup.getMaxRoll(), modGroup);
} }
public static void AddItemTableRow(int tableID,ItemTable itemTable, ItemTableRow row){
public static void addModifierTable(ModifierTable modTable) { if(!itemTables.containsKey(tableID)){
//create the new table
// If entry for this lootTabe does not currently exist itemTables.put(tableID,itemTable);
// we need to create one. //add new row to table
itemTables.get(tableID).rows.add(row);
if (_modTables.containsKey(modTable.getModTable()) == false) } else{
_modTables.put(modTable.getModTable(), //add row to existing table
new TreeMap<Float, ModifierGroup>()); ItemTable toAdd = itemTables.get(tableID);
toAdd.rows.add(row);
// Add this lootTable to the appropriate treemap }
_modTables.get(modTable.getModTable()).put(modTable.getMaxRoll(), modTable);
} }
public static void AddModTypeTableRow(int tableID,ModTypeTable modtypeTable, ModTypeTableRow row){
/* Mainline interfaces for this class. Methods below retrieve if(!modTypeTables.containsKey(tableID)){
* entries from the loottable by random number and range. //create the new table
*/ modTypeTables.put(tableID,modtypeTable);
//add row to new table
public static LootGroup getRandomLootGroup(int lootGroupID, int randomRoll) { modTypeTables.get(tableID).rows.add(row);
} else{
if ((randomRoll < 1) || (randomRoll > 100)) //add row to existing table
return null; ModTypeTable toAdd = modTypeTables.get(tableID);
toAdd.rows.add(row);
// Get random lootGroup for this roll }
return _lootGroups.get(lootGroupID).floorEntry(randomRoll).getValue();
} }
public static void AddModTableRow(int tableID, ModTable modTable, ModTableRow row){
public static engine.loot.LootTable getRandomLootTable(int lootTableID, int randomRoll) { if(!itemTables.containsKey(tableID)){
//create the new table
if ((randomRoll < 1) || (randomRoll > 100)) modTables.put(tableID,modTable);
return null; //add row to new table
modTables.get(tableID).rows.add(row);
// Get random lootTable for this roll } else{
//add row to existing table
return _lootTables.get(lootTableID).floorEntry(randomRoll).getValue(); ModTable toAdd = modTables.get(tableID);
toAdd.rows.add(row);
}
} }
public static class GenTable{
public static ModifierGroup getRandomModifierGroup(int modGroupID, int randomRoll) { public ArrayList<GenTableRow> rows = new ArrayList<GenTableRow>();
public GenTableRow getRowForRange(int roll){
if ((randomRoll < 1) || (randomRoll > 100)) GenTableRow outRow = null;
return null; for(GenTableRow iteration : this.rows){
if(iteration.minRoll >= roll && iteration.maxRoll <= roll){
// Get random modGroup for this roll outRow = iteration;
}
return _modGroups.get(modGroupID).floorEntry(randomRoll).getValue(); }
return outRow;
}
} }
public static class ItemTable{
public static ModifierTable getRandomModifierTable(int modTableID, float randomRoll) { public ArrayList<ItemTableRow> rows = new ArrayList<ItemTableRow>();
public ItemTableRow getRowForRange(int roll){
if ((randomRoll < 1.0f)) if(roll > 320){
return null; roll = 320;
}
// Roll is outside of range ItemTableRow outRow = null;
for(ItemTableRow iteration : this.rows){
if (randomRoll > getMaxRangeForModifierTable(modTableID)) if(iteration.minRoll >= roll && iteration.maxRoll <= roll){
return null; outRow = iteration;
}
// Get random lootGroup for this roll }
return outRow;
return (ModifierTable) _modTables.get(modTableID).floorEntry(randomRoll).getValue(); }
} }
public static class ModTypeTable{
// Returns minmum rolling range for a particular modifier table entry public ArrayList<ModTypeTableRow> rows = new ArrayList<ModTypeTableRow>();
public ModTypeTableRow getRowForRange(int roll){
public static float getMinRangeForModifierTable(int modTableID) { ModTypeTableRow outRow = null;
for(ModTypeTableRow iteration : this.rows){
ModifierTable outTable; if(iteration.minRoll >= roll && iteration.maxRoll <= roll){
outRow = iteration;
outTable = (ModifierTable) _modTables.get(modTableID).firstEntry(); }
}
return outTable.getMinRoll(); return outRow;
}
} }
public static class ModTable{
// Returns maximum rolling range for a particular modifier table entry public ArrayList<ModTableRow> rows = new ArrayList<ModTableRow>();
public ModTableRow getRowForRange(int roll){
public static float getMaxRangeForModifierTable(int modTableID) { if(roll > 320){
roll = 320;
ModifierTable outTable; }
ModTableRow outRow = null;
outTable = (ModifierTable) _modTables.get(modTableID).lastEntry(); for(ModTableRow iteration : this.rows){
if(iteration.minRoll >= roll && iteration.maxRoll <= roll){
return outTable.getMaxRoll(); outRow = iteration;
}
}
return outRow;
}
} }
public static class GenTableRow{
public static Item getRandomItemFromLootGroup(int lootGroupID, int randomRoll) { public int minRoll;
public int maxRoll;
Item outItem = null; public int itemTableID;
LootGroup lootGroup; public int pModTable;
LootTable lootTable; public int sModTable;
ModifierGroup modGroup; public GenTableRow(ResultSet rs) throws SQLException {
ModifierTable prefixTable; this.minRoll = rs.getInt("minRoll");
ModifierTable suffixTable; this.maxRoll = rs.getInt("maxRoll");
this.itemTableID = rs.getInt("lootTableID");
// Retrieve a random loot group this.pModTable = rs.getInt("pModTableID");
this.sModTable = rs.getInt("sModTableID");
lootGroup = getRandomLootGroup(lootGroupID, randomRoll); }
if (lootGroup == null)
return null;
// Retrieve a random loot table
lootTable = getRandomLootTable(lootGroup.getLootTableID(), ThreadLocalRandom.current().nextInt(100));
if (lootTable == null)
return null;
// Retrieve a random prefix
modGroup = getRandomModifierGroup(lootGroup.getpModTableID(), ThreadLocalRandom.current().nextInt(100));
if (modGroup == null)
return null;
prefixTable = getRandomModifierTable(modGroup.getSubTableID(), ThreadLocalRandom.current().nextFloat() * getMaxRangeForModifierTable(lootGroup.getpModTableID()));
if (prefixTable == null)
return null;
// Retrieve a random suffix
modGroup = getRandomModifierGroup(lootGroup.getsModTableID(), ThreadLocalRandom.current().nextInt(100));
if (modGroup == null)
return null;
suffixTable = getRandomModifierTable(modGroup.getSubTableID(), ThreadLocalRandom.current().nextFloat() * getMaxRangeForModifierTable(lootGroup.getsModTableID()));
if (suffixTable == null)
return null;
// Create the item!
return outItem;
} }
public static class ItemTableRow{
// Bootstrap routine to load loot data from database public int minRoll;
public int maxRoll;
public static void loadLootData() { public int cacheID;
DbManager.LootQueries.LOAD_ALL_LOOTGROUPS(); public ItemTableRow(ResultSet rs) throws SQLException {
DbManager.LootQueries.LOAD_ALL_LOOTTABLES(); this.minRoll = rs.getInt("minRoll");
DbManager.LootQueries.LOAD_ALL_MODGROUPS(); this.maxRoll = rs.getInt("maxRoll");
DbManager.LootQueries.LOAD_ALL_MODTABLES(); this.cacheID = rs.getInt("itemBaseUUID");
}
}
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");
}
} }
} }

98
src/engine/loot/LootTable.java

@ -1,98 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.loot;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Data storage object for Loot System.
* Holds row in the lootTable database table
*/
public class LootTable {
private final int lootTale;
private final String tableName;
private final String itemName;
private final int minRoll;
private final int maxRoll;
private final int itemBaseUUID;
private final int minSpawn;
private final int maxSpawn;
public LootTable(ResultSet rs) throws SQLException {
this.lootTale = rs.getInt("lootTable");
this.tableName = rs.getString("tableName");
this.itemName = rs.getString("itemName");
this.minRoll = rs.getInt("minRoll");
this.maxRoll = rs.getInt("maxRoll");
this.itemBaseUUID = rs.getInt("itemBaseUUID");
this.minSpawn = rs.getInt("minSpawn");
this.maxSpawn = rs.getInt("maxSpawn");
}
/**
* @return the lootTale
*/
public int getLootTable() {
return lootTale;
}
/**
* @return the tableName
*/
public String getTableName() {
return tableName;
}
/**
* @return the itemName
*/
public String getItemName() {
return itemName;
}
/**
* @return the minRoll
*/
public int getMinRoll() {
return minRoll;
}
/**
* @return the maxRoll
*/
public int getMaxRoll() {
return maxRoll;
}
/**
* @return the itemBaseUUID
*/
public int getItemBaseUUID() {
return itemBaseUUID;
}
/**
* @return the minSpawn
*/
public int getMinSpawn() {
return minSpawn;
}
/**
* @return the maxSpawn
*/
public int getMaxSpawn() {
return maxSpawn;
}
}

78
src/engine/loot/ModifierGroup.java

@ -1,78 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.loot;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Data storage object for Loot System.
* Holds row in the modGroup database table
*/
public class ModifierGroup {
private final int modGroup;
private final String groupName;
private final int minRoll;
private final int maxRoll;
private final int subTableID;
private final String subTableName;
public ModifierGroup(ResultSet rs) throws SQLException {
this.modGroup = rs.getInt("modGroup");
this.groupName = rs.getString("groupName");
this.minRoll = rs.getInt("minRoll");
this.maxRoll = rs.getInt("maxRoll");
this.subTableID = rs.getInt("subTableID");
this.subTableName = rs.getString("subTableName");
}
/**
* @return the modGroup
*/
public int getModGroup() {
return modGroup;
}
/**
* @return the groupName
*/
public String getGroupName() {
return groupName;
}
/**
* @return the minRoll
*/
public int getMinRoll() {
return minRoll;
}
/**
* @return the maxRoll
*/
public int getMaxRoll() {
return maxRoll;
}
/**
* @return the subTableID
*/
public int getSubTableID() {
return subTableID;
}
/**
* @return the subTableName
*/
public String getSubTableName() {
return subTableName;
}
}

88
src/engine/loot/ModifierTable.java

@ -1,88 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.loot;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Data storage object for Loot System.
* Holds row in the modTables database table
*/
public class ModifierTable{
private final int modTable;
private final String tableName;
private final float minRoll;
private final float maxRoll;
private final String action;
private final int level;
private final int value;
public ModifierTable(ResultSet rs) throws SQLException {
this.modTable = rs.getInt("modTable");
this.tableName = rs.getString("tableName");
this.minRoll = rs.getInt("minRoll");
this.maxRoll = rs.getInt("maxRoll");
this.action = rs.getString("action");
this.level = rs.getInt("level");
this.value = rs.getInt("value");
}
/**
* @return the modTable
*/
public int getModTable() {
return modTable;
}
/**
* @return the tableName
*/
public String getTableName() {
return tableName;
}
/**
* @return the minRoll
*/
public float getMinRoll() {
return minRoll;
}
/**
* @return the maxRoll
*/
public float getMaxRoll() {
return maxRoll;
}
/**
* @return the action
*/
public String getAction() {
return action;
}
/**
* @return the level
*/
public int getLevel() {
return level;
}
/**
* @return the value
*/
public int getValue() {
return value;
}
}

2
src/engine/objects/MobBase.java

@ -60,7 +60,7 @@ public class MobBase extends AbstractGameObject {
private float run = 0; private float run = 0;
private float walkCombat = 0; private float walkCombat = 0;
private float runCombat = 0; private float runCombat = 0;
public ArrayList<BootySetEntry> bootySets;
/** /**
* ResultSet Constructor * ResultSet Constructor
*/ */

Loading…
Cancel
Save