Browse Source

catch code for loot crash

master
FatBoy-DOTC 1 year ago
parent
commit
4932ee36ea
  1. 31
      src/engine/loot/LootManager.java

31
src/engine/loot/LootManager.java

@ -16,6 +16,7 @@ import engine.gameManager.ZoneManager;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.msg.chat.ChatSystemMsg; import engine.net.client.msg.chat.ChatSystemMsg;
import engine.objects.*; import engine.objects.*;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -47,7 +48,6 @@ public class LootManager {
} }
public static void GenerateMobLoot(Mob mob, boolean fromDeath) { public static void GenerateMobLoot(Mob mob, boolean fromDeath) {
try{
//determine if mob is in hotzone //determine if mob is in hotzone
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc()); boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
//get multiplier form config manager //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) { 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) { if (fromDeath) {
//do equipment here //do equipment here
if (mob.getEquip() != null) { if (mob.getEquip() != null) {
@ -92,7 +93,7 @@ public class LootManager {
float dropChance = me.getDropChance() * 100; float dropChance = me.getDropChance() * 100;
if (equipmentRoll <= (dropChance * multiplier)) { if (equipmentRoll <= (dropChance * multiplier)) {
MobLoot ml = new MobLoot(mob, me.getItemBase(), false); 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); ml.setIsID(true);
} }
mob.getCharItemManager().addItemToInventory(ml); mob.getCharItemManager().addItemToInventory(ml);
@ -102,7 +103,7 @@ public class LootManager {
return; return;
} }
for (BootySetEntry bse : entries) { for (BootySetEntry bse : entries) {
int roll; entry = bse;
float dropChance = bse.dropChance * multiplier; float dropChance = bse.dropChance * multiplier;
switch (bse.bootyType) { switch (bse.bootyType) {
case "GOLD": case "GOLD":
@ -127,7 +128,7 @@ public class LootManager {
//iterate the booty tables and add items to mob inventory //iterate the booty tables and add items to mob inventory
MobLoot toAdd = getGenTableItem(bse.lootTable, mob); MobLoot toAdd = getGenTableItem(bse.lootTable, mob);
if (toAdd != null) { 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); toAdd.setIsID(true);
} }
mob.getCharItemManager().addItemToInventory(toAdd); mob.getCharItemManager().addItemToInventory(toAdd);
@ -137,7 +138,7 @@ public class LootManager {
int lootTableID = bse.lootTable + 1; int lootTableID = bse.lootTable + 1;
MobLoot toAddHZ = getGenTableItem(lootTableID, mob); MobLoot toAddHZ = getGenTableItem(lootTableID, mob);
if (toAddHZ != null) 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); toAdd.setIsID(true);
} }
mob.getCharItemManager().addItemToInventory(toAddHZ); mob.getCharItemManager().addItemToInventory(toAddHZ);
@ -160,7 +161,7 @@ public class LootManager {
return; return;
} }
ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2); ItemTableRow tableRow = itemTables.get(126).getRowForRange(roll2);
if(tableRow == null){ if (tableRow == null) {
return; return;
} }
int itemUUID = tableRow.cacheID; int itemUUID = tableRow.cacheID;
@ -172,11 +173,18 @@ public class LootManager {
mob.getCharItemManager().addItemToInventory(toAddHZ); 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) { public static MobLoot getGenTableItem(int genTableID, Mob mob) {
try {
if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) { if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) {
return null; return null;
} }
@ -237,9 +245,6 @@ public class LootManager {
} }
} }
return outItem; return outItem;
}catch(Exception e){
return null;
}
} }
private static int TableRoll(int mobLevel){ private static int TableRoll(int mobLevel){
int max = (int)(4.882 * mobLevel + 121.0); int max = (int)(4.882 * mobLevel + 121.0);

Loading…
Cancel
Save