Browse Source

forge manager cleanup and special drop rates

lakebane
FatBoy-DOTC 3 weeks ago
parent
commit
eaeb2eb943
  1. 23
      src/engine/gameManager/SpecialLootHandler.java
  2. 38
      src/engine/objects/ItemFactory.java

23
src/engine/gameManager/SpecialLootHandler.java

@ -105,13 +105,24 @@ public class SpecialLootHandler {
} }
public static Zone getMacroZone(Mob mob){ public static Zone getMacroZone(Mob mob){
for(Zone zone : ZoneManager.macroZones){
HashSet<AbstractWorldObject> inZone = WorldGrid.getObjectsInRangePartial(zone.getLoc(),zone.getBounds().getHalfExtents().x * 2f, MBServerStatics.MASK_MOB); Zone parentZone = mob.parentZone;
if(inZone.contains(mob)){ if(parentZone == null)
return zone; return null;
}
while(!parentZone.isMacroZone() && !parentZone.equals(ZoneManager.getSeaFloor())){
parentZone = parentZone.getParent();
} }
return null;
return parentZone;
//for(Zone zone : ZoneManager.macroZones){
// HashSet<AbstractWorldObject> inZone = WorldGrid.getObjectsInRangePartial(zone.getLoc(),zone.getBounds().getHalfExtents().x * 2f, MBServerStatics.MASK_MOB);
// if(inZone.contains(mob)){
// return zone;
// }
//}
//return null;
} }
public static int getContractForZone(Zone zone){ public static int getContractForZone(Zone zone){

38
src/engine/objects/ItemFactory.java

@ -26,6 +26,7 @@ import org.joda.time.DateTime;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -679,58 +680,40 @@ public class ItemFactory {
return null; return null;
} }
for (byte temp : vendor.getItemModTable()) { Random random = new Random();
prefixMod = vendor.getModTypeTable().get(random.nextInt(vendor.getModTypeTable().size()));
if (itemModTable != temp) suffixMod = vendor.getModSuffixTable().get(random.nextInt(vendor.getModTypeTable().size()));
continue;
prefixMod = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(temp));
suffixMod = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(temp));
}
if (prefixMod == 0 && suffixMod == 0) { if (prefixMod == 0 && suffixMod == 0) {
Logger.info("Failed to find modTables for item " + ib.getName()); Logger.info("Failed to find modTables for item " + ib.getName());
return null; return null;
} }
// Roll on the tables for this vendor ArrayList<ModTypeTableEntry> prefixTable = LootManager._modTypeTables.get(prefixMod);
ArrayList<ModTypeTableEntry> suffixTable = LootManager._modTypeTables.get(suffixMod);
ModTypeTableEntry prefixTypeTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); ModTypeTableEntry prefixTypeTable = prefixTable.get(random.nextInt(prefixTable.size()));
ModTypeTableEntry suffixTypeTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); ModTypeTableEntry suffixTypeTable = suffixTable.get(random.nextInt(suffixTable.size()));
// Sanity check. // Sanity check.
if (prefixTypeTable == null || suffixTypeTable == null) if (prefixTypeTable == null || suffixTypeTable == null)
return null; return null;
int rollPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); int rollPrefix = ThreadLocalRandom.current().nextInt(100);
if (rollPrefix < vendor.getLevel() + 30) { if (rollPrefix < vendor.getLevel() + 30) {
int randomPrefix = TableRoll(vendor.getLevel()); int randomPrefix = TableRoll(vendor.getLevel());
if(vendor.contract.getName().contains("Heavy") || vendor.contract.getName().contains("Medium") || vendor.contract.getName().contains("Leather"))
randomPrefix += vendor.level * 0.5f;
if(randomPrefix > 320)
randomPrefix = 320;
prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix);
if (prefixEntry != null) if (prefixEntry != null)
prefix = prefixEntry.action; prefix = prefixEntry.action;
} }
int rollSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); int rollSuffix = ThreadLocalRandom.current().nextInt( 100);
// Always have at least one mod on a magic rolled item.
// Suffix will be our backup plan.
if (rollSuffix < vendor.getLevel() + 30) { if (rollSuffix < vendor.getLevel() + 30) {
int randomSuffix = TableRoll(vendor.getLevel()); int randomSuffix = TableRoll(vendor.getLevel());
if(vendor.contract.getName().contains("Heavy") || vendor.contract.getName().contains("Medium") || vendor.contract.getName().contains("Leather"))
randomSuffix += vendor.level * 0.25f;
if(randomSuffix > 320)
randomSuffix = 320;
suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix);
if (suffixEntry != null) if (suffixEntry != null)
@ -1092,4 +1075,5 @@ public class ItemFactory {
return ml; return ml;
} }
} }

Loading…
Cancel
Save