Browse Source

MobileBooty system integrated.

master
MagicBot 2 years ago
parent
commit
2b307daeb2
  1. 3
      src/engine/Enum.java
  2. 75
      src/engine/db/handlers/dbSpecialLootHandler.java
  3. 64
      src/engine/devcmd/cmds/GetDisciplineLocCmd.java
  4. 1
      src/engine/gameManager/DbManager.java
  5. 1
      src/engine/gameManager/DevCmdManager.java
  6. 342
      src/engine/objects/LootTable.java
  7. 12
      src/engine/objects/Mob.java
  8. 77
      src/engine/objects/SpecialLoot.java
  9. 3
      src/engine/server/world/WorldServer.java

3
src/engine/Enum.java

@ -9,7 +9,6 @@
package engine; package engine;
import ch.claude_martin.enumbitset.EnumBitSetHelper; import ch.claude_martin.enumbitset.EnumBitSetHelper;
import engine.gameManager.ConfigManager;
import engine.gameManager.PowersManager; import engine.gameManager.PowersManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector2f; import engine.math.Vector2f;
@ -1773,7 +1772,7 @@ public class Enum {
SkillReq, SkillReq,
SkillsBase, SkillsBase,
SkillsBaseAttribute, SkillsBaseAttribute,
SpecialLoot, MobileBooty,
StrongBox, StrongBox,
Trigger, Trigger,
ValidRaceBeardStyle, ValidRaceBeardStyle,

75
src/engine/db/handlers/dbSpecialLootHandler.java

@ -1,75 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.db.handlers;
import engine.objects.SpecialLoot;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
public class dbSpecialLootHandler extends dbHandlerBase {
public dbSpecialLootHandler() {
this.localClass = SpecialLoot.class;
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public ArrayList<SpecialLoot> GET_SPECIALLOOT(int mobbaseID) {
prepareCallable("SELECT * FROM `static_npc_mob_specialloot` WHERE `mobbaseID`=?");
setInt(1, mobbaseID);
return getObjectList();
}
public void GenerateSpecialLoot(){
HashMap<Integer, ArrayList<SpecialLoot>> lootSets;
SpecialLoot lootSetEntry;
int lootSetID;
lootSets = new HashMap<>();
int recordsRead = 0;
prepareCallable("SELECT * FROM static_zone_npc_specialloot");
try {
ResultSet rs = executeQuery();
while (rs.next()) {
recordsRead++;
lootSetID = rs.getInt("lootSet");
lootSetEntry = new SpecialLoot(rs,true);
if (lootSets.get(lootSetID) == null){
ArrayList<SpecialLoot> lootList = new ArrayList<>();
lootList.add(lootSetEntry);
lootSets.put(lootSetID, lootList);
}
else{
ArrayList<SpecialLoot>lootList = lootSets.get(lootSetID);
lootList.add(lootSetEntry);
lootSets.put(lootSetID, lootList);
}
}
Logger.info( "read: " + recordsRead + " cached: " + lootSets.size());
} catch (SQLException e) {
Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e);
} finally {
closeCallable();
}
SpecialLoot.LootMap = lootSets;
}
}

64
src/engine/devcmd/cmds/GetDisciplineLocCmd.java

@ -1,64 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ZoneManager;
import engine.objects.*;
import java.util.ArrayList;
/**
* @author
*
*/
public class GetDisciplineLocCmd extends AbstractDevCmd {
public GetDisciplineLocCmd() {
super("getdiscloc");
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
System.out.println("MOB UUID , MOB NAME , MACRO ZONE NAME , MOB LOCATION, DROPPED ITEM, DROP CHANCE");
for (Zone zone: ZoneManager.getAllZones()){
for (Mob mob: zone.zoneMobSet){
if (mob.getLevel() >= 80)
continue;
ArrayList<SpecialLoot> specialLootList = SpecialLoot.LootMap.get(mob.getLootSet());
if (specialLootList != null)
for (SpecialLoot specialLoot: specialLootList){
ItemBase itemBase = ItemBase.getItemBase(specialLoot.getItemID());
System.out.println(mob.getObjectUUID() + " : " + mob.getName() + " : " + (mob.getParentZone().isMacroZone() ? mob.getParentZone().getName() : mob.getParentZone().getParent().getName()) + " , " + mob.getLoc().toString2D() + " , " + itemBase.getName() + " , " + specialLoot.getDropChance() + '%');
}
}
}
}
@Override
protected String _getHelpString() {
return "Enchants an item with a prefix and suffix";
}
@Override
protected String _getUsageString() {
return "' /enchant clear/Enchant1 Enchant2 Enchant3 ...'";
}
}

1
src/engine/gameManager/DbManager.java

@ -303,7 +303,6 @@ public enum DbManager {
public static final dbRuneBaseHandler RuneBaseQueries = new dbRuneBaseHandler(); public static final dbRuneBaseHandler RuneBaseQueries = new dbRuneBaseHandler();
public static final dbSkillBaseHandler SkillsBaseQueries = new dbSkillBaseHandler(); public static final dbSkillBaseHandler SkillsBaseQueries = new dbSkillBaseHandler();
public static final dbSkillReqHandler SkillReqQueries = new dbSkillReqHandler(); public static final dbSkillReqHandler SkillReqQueries = new dbSkillReqHandler();
public static final dbSpecialLootHandler SpecialLootQueries = new dbSpecialLootHandler();
public static final dbVendorDialogHandler VendorDialogQueries = new dbVendorDialogHandler(); public static final dbVendorDialogHandler VendorDialogQueries = new dbVendorDialogHandler();
public static final dbZoneHandler ZoneQueries = new dbZoneHandler(); public static final dbZoneHandler ZoneQueries = new dbZoneHandler();
public static final dbRealmHandler RealmQueries = new dbRealmHandler(); public static final dbRealmHandler RealmQueries = new dbRealmHandler();

1
src/engine/gameManager/DevCmdManager.java

@ -134,7 +134,6 @@ public enum DevCmdManager {
DevCmdManager.registerDevCmd(new convertLoc()); DevCmdManager.registerDevCmd(new convertLoc());
DevCmdManager.registerDevCmd(new GetMobBaseLoot()); DevCmdManager.registerDevCmd(new GetMobBaseLoot());
DevCmdManager.registerDevCmd(new MBDropCmd()); DevCmdManager.registerDevCmd(new MBDropCmd());
DevCmdManager.registerDevCmd(new GetDisciplineLocCmd());
DevCmdManager.registerDevCmd(new AuditHeightMapCmd()); DevCmdManager.registerDevCmd(new AuditHeightMapCmd());
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd()); DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
DevCmdManager.registerDevCmd(new SetNPCSlotCmd()); DevCmdManager.registerDevCmd(new SetNPCSlotCmd());

342
src/engine/objects/LootTable.java

@ -9,15 +9,14 @@
package engine.objects; package engine.objects;
import engine.Enum;
import engine.Enum.ItemContainerType; import engine.Enum.ItemContainerType;
import engine.Enum.ItemType; import engine.Enum.ItemType;
import engine.Enum.OwnerType; import engine.Enum.OwnerType;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.NPCManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
@ -182,32 +181,31 @@ public class LootTable {
} }
//Returns a list of random loot for a mob based on level, lootTable and hotzone //Returns a list of random loot for a mob based on level, lootTable and hotzone
public static ArrayList<MobLoot> getMobLoot(Mob mob, int mobLevel, int lootTable, boolean hotzone) { public static ArrayList<MobLoot> getMobLoot(Mob mobile, int mobLevel, int lootTable, boolean hotzone) {
// Member variable declaration ArrayList<MobLoot> mobLoot;
ArrayList<MobLoot> loot;
int calculatedLootTable; int calculatedLootTable;
int roll; int randomRoll;
// Member variable assignment mobLoot = new ArrayList<>();
loot = new ArrayList<>();
// Setup default loot table if none exists // Setup default loot table if none exists
calculatedLootTable = lootTable; calculatedLootTable = lootTable;
LootTable.rollCount++; LootTable.rollCount++;
if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){
if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()){
roll = ThreadLocalRandom.current().nextInt(100); randomRoll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone) if (randomRoll > 90)
addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, true); if (randomRoll > LootTable.oneDropHotZone)
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true);
else else
addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, true); addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true);
}else{ }else{
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){ for (MobLootBase mlb:MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())){
float chance = mlb.getChance() *.01f; float chance = mlb.getChance() *.01f;
@ -215,12 +213,10 @@ public class LootTable {
calculatedLootTable = mlb.getLootTableID(); calculatedLootTable = mlb.getLootTableID();
if (ThreadLocalRandom.current().nextFloat() > chance) if (ThreadLocalRandom.current().nextFloat() > chance)
continue; continue;
addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, false); addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, false);
} }
} }
@ -230,62 +226,48 @@ public class LootTable {
if (calculatedLootTable <= 1) if (calculatedLootTable <= 1)
calculatedLootTable = 1300; // GENERIC WORLD calculatedLootTable = 1300; // GENERIC WORLD
//handle hotzone random loot //handle hotzone random loot
if (hotzone) { if (hotzone) {
LootTable.rollCount++; LootTable.rollCount++;
if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){ if (!MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty())
for (MobLootBase mlb : MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())) {
roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, calculatedLootTable + 1, 1, true);
else
addMobLoot(mob, loot, mobLevel, calculatedLootTable + 1, 1, true);
}else{
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){
if (!LootTable.lootGroups.containsKey(mlb.getLootTableID() + 1)) if (!LootTable.lootGroups.containsKey(mlb.getLootTableID() + 1))
continue; continue;
calculatedLootTable = mlb.getLootTableID(); calculatedLootTable = mlb.getLootTableID();
break; break;
} }
roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, (calculatedLootTable + 1), 1, true);
else
addMobLoot(mob, loot, mobLevel, (calculatedLootTable + 1), 1, true);
} randomRoll = ThreadLocalRandom.current().nextInt(100);
if (randomRoll > 90)
if (randomRoll > LootTable.oneDropHotZone)
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true);
else
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true);
} }
//handle mob specific special loot //handle mob specific special loot
handleSpecialLoot(loot, mob, false);
return loot; ArrayList bootyLoot = getBootyLoot(mobile);
mobLoot.addAll(bootyLoot);
return mobLoot;
} }
public static ArrayList<MobLoot> getMobLootDeath(Mob mob, int mobLevel, int lootTable) { public static ArrayList<MobLoot> getMobLootDeath(Mob mobile, int mobLevel, int lootTable) {
ArrayList<MobLoot> loot = new ArrayList<>(); ArrayList<MobLoot> mobLoot = new ArrayList<>();
if (mob == null) if (mobile == null)
return loot; return mobLoot;
//handle hotzone random loot //handle hotzone random loot
boolean hotzone = ZoneManager.inHotZone(mob.getLoc()); boolean hotzone = ZoneManager.inHotZone(mobile.getLoc());
if (hotzone) { if (hotzone) {
if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){ if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()){
lootTable += 1; lootTable += 1;
if (lootTable <= 1) if (lootTable <= 1)
@ -293,11 +275,11 @@ public class LootTable {
int roll = ThreadLocalRandom.current().nextInt(100); int roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90) if (roll > 90)
if (roll > LootTable.oneDropHotZone) if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, lootTable, 1, true); addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true);
else else
addMobLoot(mob, loot, mobLevel, lootTable, 1, true); addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true);
}else{ }else{
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){ for (MobLootBase mlb:MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())){
lootTable = mlb.getLootTableID() + 1; lootTable = mlb.getLootTableID() + 1;
if (!LootTable.lootGroups.containsKey(lootTable)) if (!LootTable.lootGroups.containsKey(lootTable))
continue; continue;
@ -305,67 +287,54 @@ public class LootTable {
int roll = ThreadLocalRandom.current().nextInt(100); int roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90) if (roll > 90)
if (roll > LootTable.oneDropHotZone) if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, (lootTable), 1, true); addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true);
else else
addMobLoot(mob, loot, mobLevel, (lootTable), 1, true); addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true);
break; break;
} }
} }
if (loot.isEmpty()){ if (mobLoot.isEmpty()){
LootTable.rollCount++; //add another rollCount here. LootTable.rollCount++; //add another rollCount here.
int resourceRoll = ThreadLocalRandom.current().nextInt(100); int resourceRoll = ThreadLocalRandom.current().nextInt(100);
if (resourceRoll <=5) if (resourceRoll <=5)
addMobLootResources(mob, loot, mobLevel, (lootTable), 1, true); addMobLootResources(mobile, mobLoot, mobLevel, (lootTable), 1, true);
} }
} }
//handle mob specific special loot on death //handle mob specific booty on death
handleSpecialLoot(loot, mob, true);
ArrayList bootyLoot = getBootyLoot(mobile);
mobLoot.addAll(bootyLoot);
return loot; return mobLoot;
} }
private static void handleSpecialLoot(ArrayList<MobLoot> loot, Mob mob, boolean onDeath) { private static ArrayList<MobLoot> getBootyLoot(Mob mob) {
if (SpecialLoot.LootMap.containsKey(mob.getLootSet())) { ArrayList<BootySetEntry> bootySetList;
ArrayList<SpecialLoot> specialLoot = SpecialLoot.LootMap.get(mob.getLootSet()); ArrayList<MobLoot> mobLootList = new ArrayList<>();
for (SpecialLoot sl : specialLoot) {
if ((onDeath && sl.dropOnDeath()) || (!onDeath && !sl.dropOnDeath()))
if (ThreadLocalRandom.current().nextInt(100) < sl.getDropChance()) {
ItemBase ib = ItemBase.getItemBase(sl.getItemID());
if (ib != null) {
switch (ib.getUUID()){ if (mob.bootySetID == 0)
case 19290: return mobLootList;
continue;
case 19291:
continue;
case 19292:
continue;
case 27530:
continue;
case 973000:
continue;
case 973200:
continue;
case 26360:
continue;
}
MobLoot ml = new MobLoot(mob, ib, sl.noSteal());
loot.add(ml);
bootySetList = NPCManager._bootySetMap.get(mob.bootySetID);
for (BootySetEntry bootyEntry : bootySetList)
if (ThreadLocalRandom.current().nextInt(100) < bootyEntry.dropChance) {
ItemBase itemBase = ItemBase.getItemBase(bootyEntry.itemBase);
if (itemBase != null) {
MobLoot mobLoot = new MobLoot(mob, itemBase, true);
mobLootList.add(mobLoot);
} }
} }
} return mobLootList;
}
} }
@ -394,40 +363,29 @@ public class LootTable {
LootRow modRow = null; LootRow modRow = null;
// Used for actual generation of items // Used for actual generation of items
int itemBaseUUID; int itemBaseUUID;
ItemBase itemBase = null; ItemBase itemBase = null;
MobLoot mobLoot; MobLoot mobLoot;
Zone zone = mob.getParentZone();
// Member variable assignment
if (!LootTable.lootGroups.containsKey(lootTableID)) if (!LootTable.lootGroups.containsKey(lootTableID))
return; return;
lootGroup = LootTable.lootGroups.get(lootTableID); lootGroup = LootTable.lootGroups.get(lootTableID);
calculatedMobLevel = mobLevel; calculatedMobLevel = mobLevel;
if (calculatedMobLevel > 49) if (calculatedMobLevel > 49)
calculatedMobLevel = 49; calculatedMobLevel = 49;
int roll = 0; int randomRoll = 0;
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
Random random = new Random(); Random random = new Random();
randomRoll = random.nextInt(100) + 1; //random roll between 1 and 100
roll = random.nextInt(100) + 1; //random roll between 1 and 100 groupRow = lootGroup.getLootRow(randomRoll);
groupRow = lootGroup.getLootRow(roll);
if (groupRow == null) if (groupRow == null)
return; return;
@ -436,21 +394,13 @@ public class LootTable {
if (!LootTable.lootTables.containsKey(groupRow.getValueOne())) if (!LootTable.lootTables.containsKey(groupRow.getValueOne()))
return; return;
lootTable = LootTable.lootTables.get(groupRow.getValueOne()); lootTable = LootTable.lootTables.get(groupRow.getValueOne());
//get item ID //FUCK THIS RETARDED SHIT
// roll = gaussianLevel(calculatedMobLevel);
int minRoll = (int) ((calculatedMobLevel - 5) * 5); int minRoll = (int) ((calculatedMobLevel - 5) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) * 5); int maxRoll = (int) ((calculatedMobLevel + 15) * 5);
if (minRoll < (int)lootTable.minRoll){ if (minRoll < (int)lootTable.minRoll)
minRoll = (int)lootTable.minRoll; minRoll = (int)lootTable.minRoll;
}
if (maxRoll < minRoll) if (maxRoll < minRoll)
maxRoll = minRoll; maxRoll = minRoll;
@ -458,36 +408,30 @@ public class LootTable {
if (maxRoll > lootTable.maxRoll) if (maxRoll > lootTable.maxRoll)
maxRoll = (int) lootTable.maxRoll; maxRoll = (int) lootTable.maxRoll;
if (maxRoll > 320) if (maxRoll > 320)
maxRoll = 320; maxRoll = 320;
roll = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min? randomRoll = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min?
lootRow = lootTable.getLootRow(roll); //get the item row from the bell's curve of level +-15 lootRow = lootTable.getLootRow(randomRoll); //get the item row from the bell's curve of level +-15
if (lootRow == null) if (lootRow == null)
continue; //no item found for roll continue; //no item found for roll
itemBaseUUID = lootRow.getValueOne(); itemBaseUUID = lootRow.getValueOne();
if (lootRow.getValueOne() == 0) if (lootRow.getValueOne() == 0)
continue; continue;
//handle quantities > 1 for resource drops //handle quantities > 1 for resource drops
minSpawn = lootRow.getValueTwo(); minSpawn = lootRow.getValueTwo();
maxSpawn = lootRow.getValueThree(); maxSpawn = lootRow.getValueThree();
// spawnQuanity between minspawn (inclusive) and maxspawn (inclusive) // spawnQuantity between min spawn (inclusive) and max spawn (inclusive)
if (maxSpawn > 1) if (maxSpawn > 1)
spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn;
//get modifierPrefix //get modifierPrefix
calculatedMobLevel = mobLevel; calculatedMobLevel = mobLevel;
@ -500,20 +444,18 @@ public class LootTable {
int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1; int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1;
if (chanceMod < 25){ if (chanceMod < 25) {
modGroup = LootTable.modGroups.get(groupRow.getValueTwo()); modGroup = LootTable.modGroups.get(groupRow.getValueTwo());
if (modGroup != null) { if (modGroup != null) {
for (int a = 0;a<10;a++){ for (int a = 0;a<10;a++){
roll = ThreadLocalRandom.current().nextInt(100) + 1; randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll); modRow = modGroup.getLootRow(randomRoll);
if (modRow != null) if (modRow != null)
break; break;
} }
if (modRow != null) { if (modRow != null) {
subTableID = modRow.getValueOne(); subTableID = modRow.getValueOne();
@ -521,17 +463,15 @@ public class LootTable {
modTable = LootTable.modTables.get(subTableID); modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel); randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll)
roll = (int) modTable.minRoll;
if (roll > modTable.maxRoll) if (randomRoll < modTable.minRoll)
roll = (int) modTable.maxRoll; randomRoll = (int) modTable.minRoll;
if (randomRoll > modTable.maxRoll)
randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(randomRoll);
modRow = modTable.getLootRow(roll);
if (modRow != null) { if (modRow != null) {
prefixValue = modRow.getValueOne(); prefixValue = modRow.getValueOne();
@ -540,14 +480,14 @@ public class LootTable {
} }
} }
} }
}else if(chanceMod < 50){ }else if(chanceMod < 50) {
modGroup = LootTable.modGroups.get(groupRow.getValueThree()); modGroup = LootTable.modGroups.get(groupRow.getValueThree());
if (modGroup != null) { if (modGroup != null) {
for (int a = 0;a<10;a++){ for (int a = 0;a<10;a++){
roll = ThreadLocalRandom.current().nextInt(100) + 1; randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll); modRow = modGroup.getLootRow(randomRoll);
if (modRow != null) if (modRow != null)
break; break;
} }
@ -559,19 +499,19 @@ public class LootTable {
if (LootTable.modTables.containsKey(subTableID)) { if (LootTable.modTables.containsKey(subTableID)) {
modTable = LootTable.modTables.get(subTableID); modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel); randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll) if (randomRoll < modTable.minRoll)
roll = (int) modTable.minRoll; randomRoll = (int) modTable.minRoll;
if (roll > modTable.maxRoll) if (randomRoll > modTable.maxRoll)
roll = (int) modTable.maxRoll; randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(roll); modRow = modTable.getLootRow(randomRoll);
if (modRow == null){ if (modRow == null)
modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f)); modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f));
}
if (modRow != null) { if (modRow != null) {
suffixValue = modRow.getValueOne(); suffixValue = modRow.getValueOne();
@ -586,9 +526,9 @@ public class LootTable {
if (modGroup != null) { if (modGroup != null) {
for (int a = 0;a<10;a++){ for (int a = 0;a<10;a++) {
roll = ThreadLocalRandom.current().nextInt(100) + 1; randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll); modRow = modGroup.getLootRow(randomRoll);
if (modRow != null) if (modRow != null)
break; break;
} }
@ -601,21 +541,18 @@ public class LootTable {
modTable = LootTable.modTables.get(subTableID); modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel); randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll)
roll = (int) modTable.minRoll;
if (roll > modTable.maxRoll)
roll = (int) modTable.maxRoll;
if (randomRoll < modTable.minRoll)
randomRoll = (int) modTable.minRoll;
if (randomRoll > modTable.maxRoll)
randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(roll); modRow = modTable.getLootRow(randomRoll);
if (modRow == null){ if (modRow == null)
modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f)); modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f));
}
if (modRow != null) { if (modRow != null) {
prefixValue = modRow.getValueOne(); prefixValue = modRow.getValueOne();
@ -631,8 +568,8 @@ public class LootTable {
if (modGroup != null) { if (modGroup != null) {
for (int a = 0;a<10;a++){ for (int a = 0;a<10;a++){
roll = ThreadLocalRandom.current().nextInt(100) + 1; randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll); modRow = modGroup.getLootRow(randomRoll);
if (modRow != null) if (modRow != null)
break; break;
} }
@ -644,19 +581,18 @@ public class LootTable {
if (LootTable.modTables.containsKey(subTableID)) { if (LootTable.modTables.containsKey(subTableID)) {
modTable = LootTable.modTables.get(subTableID); modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel); randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll) if (randomRoll < modTable.minRoll)
roll = (int) modTable.minRoll; randomRoll = (int) modTable.minRoll;
if (roll > modTable.maxRoll) if (randomRoll > modTable.maxRoll)
roll = (int) modTable.maxRoll; randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(roll); modRow = modTable.getLootRow(randomRoll);
if (modRow == null){ if (modRow == null)
modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f)); modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f));
}
if (modRow != null) { if (modRow != null) {
suffixValue = modRow.getValueOne(); suffixValue = modRow.getValueOne();
@ -667,7 +603,6 @@ public class LootTable {
} }
} }
itemBase = ItemBase.getItemBase(itemBaseUUID); itemBase = ItemBase.getItemBase(itemBaseUUID);
if (itemBase == null) if (itemBase == null)
@ -676,19 +611,6 @@ public class LootTable {
//Handle logging of drops //Handle logging of drops
LootTable.HandleDropLogs(itemBase); LootTable.HandleDropLogs(itemBase);
// Handle drop rates of resources/runes/contracts.
// We intentionally drop them in half
// if ((itemBase.getMessageType() == ItemType.CONTRACT) ||
// (itemBase.getMessageType() == ItemType.RUNE) ){
// if (ThreadLocalRandom.current().nextBoolean() == false)
// continue;
// }
if (itemBase.getType() == ItemType.OFFERING) if (itemBase.getType() == ItemType.OFFERING)
spawnQuanity = 1; spawnQuanity = 1;
@ -702,12 +624,11 @@ public class LootTable {
if (!modifierSuffix.isEmpty()) if (!modifierSuffix.isEmpty())
mobLoot.addPermanentEnchantment(modifierSuffix, 0, suffixValue, false); mobLoot.addPermanentEnchantment(modifierSuffix, 0, suffixValue, false);
mobLoot.loadEnchantments(); mobLoot.loadEnchantments();
loot.add(mobLoot); loot.add(mobLoot);
} }
} }
@ -718,28 +639,18 @@ public class LootTable {
int minSpawn; int minSpawn;
int maxSpawn; int maxSpawn;
int spawnQuanity = 0; int spawnQuanity = 0;
int prefixValue = 0;
int suffixValue = 0;
int subTableID;
String modifierPrefix = "";
String modifierSuffix = "";
// Lookup Table Variables // Lookup Table Variables
LootTable lootTable; LootTable lootTable;
LootRow lootRow; LootRow lootRow;
LootTable lootGroup; LootTable lootGroup;
LootRow groupRow = null; LootRow groupRow = null;
LootTable modTable;
LootTable modGroup;
LootRow modRow = null;
// Used for actual generation of items // Used for actual generation of items
int itemBaseUUID; int itemBaseUUID;
ItemBase itemBase; ItemBase itemBase;
MobLoot mobLoot; MobLoot mobLoot;
Zone zone = mob.getParentZone();
// Member variable assignment
if (!LootTable.lootGroups.containsKey(lootTableID)) if (!LootTable.lootGroups.containsKey(lootTableID))
return; return;
@ -753,8 +664,6 @@ public class LootTable {
int roll = 0; int roll = 0;
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
if (lootTableID == 1901) if (lootTableID == 1901)
groupRow = lootGroup.getLootRow(66); groupRow = lootGroup.getLootRow(66);
else if (lootTableID == 1501) else if (lootTableID == 1501)
@ -762,38 +671,25 @@ public class LootTable {
else else
groupRow = lootGroup.getLootRow(80); groupRow = lootGroup.getLootRow(80);
if (groupRow == null) if (groupRow == null)
return; return;
//get loot table for this group //get loot table for this group
if (!LootTable.lootTables.containsKey(groupRow.getValueOne())) if (!LootTable.lootTables.containsKey(groupRow.getValueOne()))
return; return;
lootTable = LootTable.lootTables.get(groupRow.getValueOne()); lootTable = LootTable.lootTables.get(groupRow.getValueOne());
//get item ID //FUCK THIS RETARDED SHIT
// roll = gaussianLevel(calculatedMobLevel);
int minRoll = (int) ((calculatedMobLevel-5) * 5); int minRoll = (int) ((calculatedMobLevel-5) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) *5); int maxRoll = (int) ((calculatedMobLevel + 15) *5);
if (minRoll < (int)lootTable.minRoll){ if (minRoll < (int)lootTable.minRoll)
minRoll = (int)lootTable.minRoll; minRoll = (int)lootTable.minRoll;
}
if (maxRoll < minRoll) if (maxRoll < minRoll)
maxRoll = minRoll; maxRoll = minRoll;
if (maxRoll > 320) if (maxRoll > 320)
maxRoll = 320; maxRoll = 320;
@ -809,19 +705,21 @@ public class LootTable {
continue; continue;
//handle quantities > 1 for resource drops //handle quantities > 1 for resource drops
minSpawn = lootRow.getValueTwo(); minSpawn = lootRow.getValueTwo();
maxSpawn = lootRow.getValueThree(); maxSpawn = lootRow.getValueThree();
// spawnQuanity between minspawn (inclusive) and maxspawn (inclusive) // spawnQuanity between minspawn (inclusive) and maxspawn (inclusive)
if (maxSpawn > 1) if (maxSpawn > 1)
spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn; spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn;
itemBase = ItemBase.getItemBase(itemBaseUUID); itemBase = ItemBase.getItemBase(itemBaseUUID);
if (itemBase == null) if (itemBase == null)
return; return;
LootTable.HandleDropLogs(itemBase);
LootTable.HandleDropLogs(itemBase);
switch (itemBase.getUUID()){ switch (itemBase.getUUID()){
case 19290: case 19290:
@ -844,8 +742,6 @@ public class LootTable {
// Handle drop rates of resources/runes/contracts. // Handle drop rates of resources/runes/contracts.
// We intentionally drop them in half // We intentionally drop them in half
if (itemBase.getType() == ItemType.OFFERING) if (itemBase.getType() == ItemType.OFFERING)
spawnQuanity = 1; spawnQuanity = 1;
@ -867,18 +763,8 @@ public class LootTable {
} }
return (level * 5) + ret; return (level * 5) + ret;
// float useLevel = (float)(level + (ThreadLocalRandom.current().nextGaussian() * 5));
//
// if (useLevel < (level - 15))
// useLevel = level - 15;
// else if (useLevel > (level + 15))
// useLevel = level + 15;
// return (int)(useLevel * 5);
}
}
//This set's the drop chances for stat runes. //This set's the drop chances for stat runes.
public static void populateStatRuneChances() { public static void populateStatRuneChances() {

12
src/engine/objects/Mob.java

@ -108,8 +108,6 @@ public class Mob extends AbstractIntelligenceAgent {
private int equipmentSetID = 0; private int equipmentSetID = 0;
public int runeSetID = 0; public int runeSetID = 0;
public int bootySetID = 0; public int bootySetID = 0;
private int lootSet = 0;
private boolean isGuard;
/** /**
* No Id Constructor * No Id Constructor
@ -295,8 +293,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.contract != null) if (this.contract != null)
this.equipmentSetID = this.contract.getEquipmentSet(); this.equipmentSetID = this.contract.getEquipmentSet();
this.lootSet = (rs.getInt("lootSet"));
this.nameOverride = rs.getString("mob_name"); this.nameOverride = rs.getString("mob_name");
} catch (Exception e) { } catch (Exception e) {
@ -2466,14 +2462,6 @@ public class Mob extends AbstractIntelligenceAgent {
return equipmentSetID; return equipmentSetID;
} }
public int getLootSet() {
return lootSet;
}
public boolean isGuard() {
return this.isGuard;
}
public String getNameOverride() { public String getNameOverride() {
return nameOverride; return nameOverride;
} }

77
src/engine/objects/SpecialLoot.java

@ -1,77 +0,0 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.objects;
import engine.gameManager.DbManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
public class SpecialLoot extends AbstractGameObject {
private int itemID;
private int dropChance;
private boolean dropOnDeath;
private boolean noSteal;
private int lootSetID;
public static HashMap<Integer,ArrayList<SpecialLoot>> LootMap = new HashMap<>();
/**
* ResultSet Constructor
*/
public SpecialLoot(ResultSet rs) throws SQLException {
super(rs);
this.itemID = rs.getInt("itemID");
this.dropChance = rs.getInt("dropChance");
this.dropOnDeath = rs.getBoolean("dropOnDeath");
this.noSteal = rs.getBoolean("noSteal");
}
public SpecialLoot(ResultSet rs,boolean specialLoot) throws SQLException {
super(rs);
this.lootSetID = rs.getInt("lootSet");
this.itemID = rs.getInt("itemID");
this.dropChance = rs.getInt("dropChance");
this.dropOnDeath = false;
this.noSteal = true;
}
/*
* Getters
*/
public int getItemID() {
return this.itemID;
}
public int getDropChance() {
return this.dropChance;
}
public boolean dropOnDeath() {
return this.dropOnDeath;
}
public boolean noSteal() {
return this.noSteal;
}
public static ArrayList<SpecialLoot> getSpecialLoot(int mobbaseID) {
return DbManager.SpecialLootQueries.GET_SPECIALLOOT(mobbaseID);
}
@Override
public void updateDatabase() {
}
}

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

@ -344,9 +344,6 @@ public class WorldServer {
Blueprint.loadAllDoorNumbers(); Blueprint.loadAllDoorNumbers();
Blueprint.loadAllBlueprints(); Blueprint.loadAllBlueprints();
Logger.info("Loading Special Loot For Mobs");
DbManager.SpecialLootQueries.GenerateSpecialLoot();
Logger.info("Initializing Heightmap data"); Logger.info("Initializing Heightmap data");
HeightMap.loadAlHeightMaps(); HeightMap.loadAlHeightMaps();

Loading…
Cancel
Save