Browse Source

Last vestiges of old loot system removed.

master
MagicBot 1 year ago
parent
commit
b84be6eea8
  1. 132
      src/engine/devcmd/cmds/MBDropCmd.java
  2. 1
      src/engine/gameManager/DevCmdManager.java
  3. 190
      src/engine/objects/ItemFactory.java
  4. 63
      src/engine/objects/LootRow.java
  5. 77
      src/engine/objects/LootTable.java
  6. 1
      src/engine/server/world/WorldServer.java

132
src/engine/devcmd/cmds/MBDropCmd.java

@ -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)";
}
}

1
src/engine/gameManager/DevCmdManager.java

@ -128,7 +128,6 @@ public enum DevCmdManager { @@ -128,7 +128,6 @@ public enum DevCmdManager {
DevCmdManager.registerDevCmd(new SetForceRenameCityCmd());
DevCmdManager.registerDevCmd(new GotoObj());
DevCmdManager.registerDevCmd(new convertLoc());
DevCmdManager.registerDevCmd(new MBDropCmd());
DevCmdManager.registerDevCmd(new AuditHeightMapCmd());
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());

190
src/engine/objects/ItemFactory.java

@ -14,6 +14,8 @@ import engine.Enum.ItemContainerType; @@ -14,6 +14,8 @@ import engine.Enum.ItemContainerType;
import engine.Enum.ItemType;
import engine.Enum.OwnerType;
import engine.gameManager.*;
import engine.loot.ModTableEntry;
import engine.loot.ModTypeTableEntry;
import engine.net.ItemProductionManager;
import engine.net.ItemQueue;
import engine.net.client.ClientConnection;
@ -648,11 +650,11 @@ public class ItemFactory { @@ -648,11 +650,11 @@ public class ItemFactory {
byte itemModTable;
int prefixMod = 0;
int suffixMod = 0;
LootTable prefixLootTable;
LootTable suffixLootTable;
String suffix = "";
String prefix = "";
MobLoot toRoll;
String suffix = "";
ModTableEntry prefixEntry = null;
ModTableEntry suffixEntry = null;
ItemBase ib = ItemBase.getItemBase(itemID);
@ -694,187 +696,33 @@ public class ItemFactory { @@ -694,187 +696,33 @@ public class ItemFactory {
return null;
}
prefixLootTable = LootTable.getModTypeTable(prefixMod);
suffixLootTable = LootTable.getModTypeTable(suffixMod);
if (prefixLootTable == null || suffixLootTable == null)
return null;
ModTypeTableEntry prefixTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1));
ModTypeTableEntry suffixTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1));
int rollPrefix = ThreadLocalRandom.current().nextInt(100);
int rollPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1);
if (rollPrefix < 80) {
int randomPrefix = ThreadLocalRandom.current().nextInt(100) + 1;
LootRow prefixLootRow = prefixLootTable.getLootRow(randomPrefix);
if (prefixLootRow != null) {
LootTable prefixTypeTable = LootTable.getModTable(prefixLootRow.getValueOne());
int minRoll = (int) ((calculatedMobLevel - 5) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) * 5);
if (minRoll < (int) prefixTypeTable.minRoll)
minRoll = (int) prefixTypeTable.minRoll;
if (maxRoll < minRoll)
maxRoll = minRoll;
if (maxRoll > prefixTypeTable.maxRoll)
maxRoll = (int) prefixTypeTable.maxRoll;
int randomPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1);
prefixEntry = ModTableEntry.rollTable(prefixTable.modTableID, randomPrefix);
if (maxRoll > 320)
maxRoll = 320;
if (prefixEntry != null)
prefix = prefixEntry.action;
int randomPrefix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min?
if (randomPrefix1 < prefixTypeTable.minRoll)
randomPrefix1 = (int) prefixTypeTable.minRoll;
if (randomPrefix1 > prefixTypeTable.maxRoll)
randomPrefix1 = (int) prefixTypeTable.maxRoll;
LootRow prefixTypelootRow = prefixTypeTable.getLootRow(randomPrefix1);
if (prefixTypelootRow == null)
prefixTypelootRow = prefixTypeTable.getLootRow((int) ((prefixTypeTable.maxRoll + prefixTypeTable.minRoll) * .05f));
if (prefixTypelootRow != null) {
prefix = prefixTypelootRow.getAction();
}
}
}
int rollSuffix = ThreadLocalRandom.current().nextInt(100);
int rollSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1);
if (rollSuffix < 80) {
int randomSuffix = ThreadLocalRandom.current().nextInt(100) + 1;
LootRow suffixLootRow = suffixLootTable.getLootRow(randomSuffix);
if (suffixLootRow != null) {
LootTable suffixTypeTable = LootTable.getModTable(suffixLootRow.getValueOne());
if (suffixTypeTable != null) {
int minRoll = (int) ((calculatedMobLevel - 5) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) * 5);
if (minRoll < (int) suffixTypeTable.minRoll)
minRoll = (int) suffixTypeTable.minRoll;
if (maxRoll < minRoll)
maxRoll = minRoll;
if (maxRoll > suffixTypeTable.maxRoll)
maxRoll = (int) suffixTypeTable.maxRoll;
if (maxRoll > 320)
maxRoll = 320;
int randomSuffix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min?
if (randomSuffix1 < suffixTypeTable.minRoll)
randomSuffix1 = (int) suffixTypeTable.minRoll;
if (randomSuffix1 > suffixTypeTable.maxRoll)
randomSuffix1 = (int) suffixTypeTable.maxRoll;
LootRow suffixTypelootRow = suffixTypeTable.getLootRow(randomSuffix1);
if (suffixTypelootRow != null) {
suffix = suffixTypelootRow.getAction();
}
}
}
}
if (prefix.isEmpty() && suffix.isEmpty()) {
int randomSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1);
suffixEntry = ModTableEntry.rollTable(suffixTable.modTableID, randomSuffix);
rollPrefix = ThreadLocalRandom.current().nextInt(100);
if (rollPrefix < 50) {
int randomPrefix = ThreadLocalRandom.current().nextInt(100) + 1;
LootRow prefixLootRow = prefixLootTable.getLootRow(randomPrefix);
if (prefixLootRow != null) {
LootTable prefixTypeTable = LootTable.getModTable(prefixLootRow.getValueOne());
int minRoll = (int) ((calculatedMobLevel) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) * 5);
if (minRoll < (int) prefixTypeTable.minRoll)
minRoll = (int) prefixTypeTable.minRoll;
if (maxRoll < minRoll)
maxRoll = minRoll;
if (maxRoll > prefixTypeTable.maxRoll)
maxRoll = (int) prefixTypeTable.maxRoll;
if (maxRoll > 320)
maxRoll = 320;
int randomPrefix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min?
if (randomPrefix1 < prefixTypeTable.minRoll)
randomPrefix1 = (int) prefixTypeTable.minRoll;
if (randomPrefix1 > prefixTypeTable.maxRoll)
randomPrefix1 = (int) prefixTypeTable.maxRoll;
LootRow prefixTypelootRow = prefixTypeTable.getLootRow(randomPrefix1);
if (prefixTypelootRow == null)
prefixTypelootRow = prefixTypeTable.getLootRow((int) ((prefixTypeTable.maxRoll + prefixTypeTable.minRoll) * .05f));
if (prefixTypelootRow != null) {
prefix = prefixTypelootRow.getAction();
}
}
} else {
int randomSuffix = ThreadLocalRandom.current().nextInt(100) + 1;
LootRow suffixLootRow = suffixLootTable.getLootRow(randomSuffix);
if (suffixLootRow != null) {
LootTable suffixTypeTable = LootTable.getModTable(suffixLootRow.getValueOne());
if (suffixTypeTable != null) {
int minRoll = (int) ((calculatedMobLevel) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) * 5);
if (minRoll < (int) suffixTypeTable.minRoll)
minRoll = (int) suffixTypeTable.minRoll;
if (maxRoll < minRoll)
maxRoll = minRoll;
if (maxRoll > suffixTypeTable.maxRoll)
maxRoll = (int) suffixTypeTable.maxRoll;
if (maxRoll > 320)
maxRoll = 320;
int randomSuffix1 = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min?
if (randomSuffix1 < suffixTypeTable.minRoll)
randomSuffix1 = (int) suffixTypeTable.minRoll;
if (randomSuffix1 > suffixTypeTable.maxRoll)
randomSuffix1 = (int) suffixTypeTable.maxRoll;
LootRow suffixTypelootRow = suffixTypeTable.getLootRow(randomSuffix1);
if (suffixTypelootRow != null)
suffix = suffixTypelootRow.getAction();
}
}
}
if (suffixEntry != null)
suffix = suffixEntry.action;
}
toRoll = ItemFactory.produceRandomRoll(vendor, pc, prefix, suffix, itemID);
MobLoot toRoll = ItemFactory.produceRandomRoll(vendor, pc, prefix, suffix, itemID);
if (toRoll == null)
return null;

63
src/engine/objects/LootRow.java

@ -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;
}
}

77
src/engine/objects/LootTable.java

@ -1,77 +0,0 @@ @@ -1,77 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.objects;
import engine.server.MBServerStatics;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
public class LootTable {
private static final ConcurrentHashMap<Integer, LootTable> modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static final ConcurrentHashMap<Integer, LootTable> modTypeTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static final ConcurrentHashMap<Integer, Integer> statRuneChances = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public static boolean initialized = false;
public static HashMap<ItemBase, Integer> itemsDroppedMap = new HashMap<>();
public static HashMap<ItemBase, Integer> resourceDroppedMap = new HashMap<>();
public static HashMap<ItemBase, Integer> runeDroppedMap = new HashMap<>();
public static HashMap<ItemBase, Integer> contractDroppedMap = new HashMap<>();
public static HashMap<ItemBase, Integer> glassDroppedMap = new HashMap<>();
public static int rollCount = 0;
public static int dropCount = 0;
public static int runeCount = 0;
public static int contractCount = 0;
public static int resourceCount = 0;
public static int glassCount = 0;
private final ConcurrentHashMap<Integer, LootRow> lootTable = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public float minRoll = 320;
public float maxRoll = 1;
public int lootTableID = 0;
/**
* Generic Constructor
*/
public LootTable(int lootTableID) {
this.lootTableID = lootTableID;
}
public static LootTable getModTypeTable(int UUID) {
if (modTypeTables.containsKey(UUID))
return modTypeTables.get(UUID);
LootTable modTable = new LootTable(UUID);
modTypeTables.put(UUID, modTable);
return modTable;
}
public static LootTable getModTable(int UUID) {
if (modTables.containsKey(UUID))
return modTables.get(UUID);
LootTable modTypeTable = new LootTable(UUID);
modTables.put(UUID, modTypeTable);
return modTypeTable;
}
public LootRow getLootRow(int probability) {
if (lootTable.containsKey(probability))
return lootTable.get(probability);
return null;
}
}

1
src/engine/server/world/WorldServer.java

@ -504,7 +504,6 @@ public class WorldServer { @@ -504,7 +504,6 @@ public class WorldServer {
Logger.info("Bootstrap time was " + boottime);
bootTime = LocalDateTime.now();
LootTable.initialized = true;
Logger.info("Running garbage collection...");
System.gc();

Loading…
Cancel
Save