catch code for loot crash

This commit is contained in:
2023-07-29 19:04:59 -05:00
parent 99fc4b8671
commit 4932ee36ea
+18 -13
View File
@@ -16,6 +16,7 @@ import engine.gameManager.ZoneManager;
import engine.net.DispatchMessage;
import engine.net.client.msg.chat.ChatSystemMsg;
import engine.objects.*;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -47,7 +48,6 @@ public class LootManager {
}
public static void GenerateMobLoot(Mob mob, boolean fromDeath) {
try{
//determine if mob is in hotzone
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
//get multiplier form config manager
@@ -76,12 +76,13 @@ public class LootManager {
}
}
} catch(Exception e){
//TODO catch whatever went wrong
}
}
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) {
int roll; // table roll
BootySetEntry entry = null;
int setCount = 0;
try {
if (fromDeath) {
//do equipment here
if (mob.getEquip() != null) {
@@ -92,7 +93,7 @@ public class LootManager {
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){
if (ml.getPrefix().isEmpty() == true && ml.getSuffix().isEmpty() == true) {
ml.setIsID(true);
}
mob.getCharItemManager().addItemToInventory(ml);
@@ -102,7 +103,7 @@ public class LootManager {
return;
}
for (BootySetEntry bse : entries) {
int roll;
entry = bse;
float dropChance = bse.dropChance * multiplier;
switch (bse.bootyType) {
case "GOLD":
@@ -127,7 +128,7 @@ public class LootManager {
//iterate the booty tables and add items to mob inventory
MobLoot toAdd = getGenTableItem(bse.lootTable, mob);
if (toAdd != null) {
if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){
if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) {
toAdd.setIsID(true);
}
mob.getCharItemManager().addItemToInventory(toAdd);
@@ -137,7 +138,7 @@ public class LootManager {
int lootTableID = bse.lootTable + 1;
MobLoot toAddHZ = getGenTableItem(lootTableID, mob);
if (toAddHZ != null)
if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){
if (toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix() != null && toAdd.getSuffix().isEmpty() == true) {
toAdd.setIsID(true);
}
mob.getCharItemManager().addItemToInventory(toAddHZ);
@@ -160,7 +161,7 @@ public class LootManager {
return;
}
ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2);
if(tableRow == null){
if (tableRow == null) {
return;
}
int itemUUID = tableRow.cacheID;
@@ -172,11 +173,18 @@ public class LootManager {
mob.getCharItemManager().addItemToInventory(toAddHZ);
}
}
setCount++;
}catch(Exception e){
//catch crash bug
int tableID = entry.lootTable;
String bootyType = entry.bootyType;
int itemBase = entry.itemBase;
Logger.error("FAILED LOOT ROLL: TableID: " + tableID + "bootyType: " + bootyType + " itemUUID: " + itemBase);
}
}
public static MobLoot getGenTableItem(int genTableID, Mob mob) {
try {
if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) {
return null;
}
@@ -237,9 +245,6 @@ public class LootManager {
}
}
return outItem;
}catch(Exception e){
return null;
}
}
private static int TableRoll(int mobLevel){
int max = (int)(4.882 * mobLevel + 121.0);