Browse Source

chase null pointer

master
FatBoy-DOTC 2 years ago
parent
commit
a7dccb6301
  1. 2
      src/engine/ai/MobileFSM.java
  2. 20
      src/engine/loot/LootManager.java

2
src/engine/ai/MobileFSM.java

@ -61,8 +61,6 @@ public class MobileFSM {
if (mob == null) { if (mob == null) {
return; return;
} }
if (mob.isGuard())
awakeNPCguard(mob);
STATE state = mob.state; STATE state = mob.state;
switch (state) { switch (state) {
case Idle: case Idle:

20
src/engine/loot/LootManager.java

@ -95,7 +95,8 @@ public class LootManager {
mob.getCharItemManager().addItemToInventory(toAdd); mob.getCharItemManager().addItemToInventory(toAdd);
} }
if (inHotzone) { if (inHotzone) {
MobLoot toAddHZ = getGenTableItem(bse.lootTable + 1, mob); int lootTableID = bse.lootTable + 1;
MobLoot toAddHZ = getGenTableItem(lootTableID, mob);
if (toAddHZ != null) if (toAddHZ != null)
mob.getCharItemManager().addItemToInventory(toAddHZ); mob.getCharItemManager().addItemToInventory(toAddHZ);
@ -111,19 +112,20 @@ public class LootManager {
} }
} }
public static MobLoot getGenTableItem(int genTableID, Mob mob){ public static MobLoot getGenTableItem(int genTableID, Mob mob){
if(genTableID == 0 ||mob == null){ if(genTableID == 0 ||mob == null || generalItemTables.containsKey(genTableID) == false){
return null; return null;
} }
MobLoot outItem; MobLoot outItem;
int minRollRange = mob.getParentZone().minLvl + mob.getLevel(); int minRollRange = mob.getParentZone().minLvl + mob.getLevel();
int maxRollRange = (mob.getParentZone().minLvl + mob.getLevel() + mob.getParentZone().maxLvl) * 2; int maxRollRange = (mob.getParentZone().minLvl + mob.getLevel() + mob.getParentZone().maxLvl) * 2;
GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(new Random().nextInt(100)); int roll = new Random().nextInt(100);
GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(roll);
if(selectedRow == null) { if(selectedRow == null) {
return null; return null;
} }
int itemTableId = selectedRow.itemTableID; int itemTableId = selectedRow.itemTableID;
int roll = new Random().nextInt(maxRollRange) + minRollRange; int roll2 = new Random().nextInt(maxRollRange) + minRollRange;
ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll); ItemTableRow tableRow = itemTables.get(itemTableId).getRowForRange(roll2);
if(tableRow == null){ if(tableRow == null){
return null; return null;
} }
@ -138,12 +140,10 @@ public class LootManager {
ModTableRow prefixMod = prefixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange); ModTableRow prefixMod = prefixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange);
ModTableRow suffixMod = suffixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange); ModTableRow suffixMod = suffixModTable.getRowForRange(new Random().nextInt(maxRollRange) + minRollRange);
outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
String prefixAction = prefixMod.action; if(prefixMod != null && prefixMod.action.length() > 0){
if(prefixMod.action.length() > 0){
outItem.setPrefix(prefixMod.action); outItem.setPrefix(prefixMod.action);
} }
String suffixaction = suffixMod.action; if(suffixMod != null && suffixMod.action.length() > 0){
if(suffixMod.action.length() > 0){
outItem.setSuffix(suffixMod.action); outItem.setSuffix(suffixMod.action);
} }
return outItem; return outItem;
@ -201,7 +201,7 @@ public class LootManager {
public GenTableRow getRowForRange(int roll){ public GenTableRow getRowForRange(int roll){
GenTableRow outRow = null; GenTableRow outRow = null;
for(GenTableRow iteration : this.rows){ for(GenTableRow iteration : this.rows){
if(iteration.minRoll >= roll && iteration.maxRoll <= roll){ if(roll >= iteration.minRoll && roll <= iteration.maxRoll){
outRow = iteration; outRow = iteration;
} }
} }

Loading…
Cancel
Save