Browse Source

any mob over level 30 has a small chance to drop glass

lakebane-master
FatBoy-DOTC 11 months ago
parent
commit
c0ec747e43
  1. 78
      src/engine/gameManager/LootManager.java
  2. 4
      src/engine/objects/ItemFactory.java

78
src/engine/gameManager/LootManager.java

@ -68,16 +68,13 @@ public enum LootManager {
public static void GenerateMobLoot(Mob mob) { public static void GenerateMobLoot(Mob mob) {
//determine if mob is in hotzone
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
//iterate the booty sets //iterate the booty sets
if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true) if (mob.getMobBase().bootySet != 0 && _bootySetMap.containsKey(mob.getMobBase().bootySet) == true)
RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob, inHotzone); RunBootySet(_bootySetMap.get(mob.getMobBase().bootySet), mob);
if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet) == true) if (mob.bootySet != 0 && _bootySetMap.containsKey(mob.bootySet) == true)
RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone); RunBootySet(_bootySetMap.get(mob.bootySet), mob);
//lastly, check mobs inventory for godly or disc runes to send a server announcement //lastly, check mobs inventory for godly or disc runes to send a server announcement
for (Item it : mob.getInventory()) { for (Item it : mob.getInventory()) {
@ -95,38 +92,33 @@ public enum LootManager {
} }
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, boolean inHotzone) { private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob) {
boolean hotzoneWasRan = false; float dropRate = NORMAL_DROP_RATE;
float dropRate = 1.0f;
// Iterate all entries in this bootySet and process accordingly // Iterate all entries in this bootySet and process accordingly
if (mob.level >= 30) {
if(ThreadLocalRandom.current().nextInt(1, 20000) < mob.level) {
ItemTableEntry tableRow = ItemTableEntry.rollTable(126, ThreadLocalRandom.current().nextInt(1, 100 + 1));
if (tableRow != null) {
int itemUUID = tableRow.cacheID;
if (itemUUID != 0) {
MobLoot glassItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false);
}
}
}
}
for (BootySetEntry bse : entries) { for (BootySetEntry bse : entries) {
switch (bse.bootyType) { switch (bse.bootyType) {
case "GOLD": case "GOLD":
GenerateGoldDrop(mob, bse, inHotzone); GenerateGoldDrop(mob, bse);
break; break;
case "LOOT": case "LOOT":
if (mob.getSafeZone() == false)
dropRate = LootManager.NORMAL_DROP_RATE;
if (inHotzone == true)
dropRate = LootManager.HOTZONE_DROP_RATE;
if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate))
GenerateLootDrop(mob, bse.genTable, false); //generate normal loot drop GenerateLootDrop(mob, bse.genTable); //generate normal loot drop
// Generate hotzone loot if in hotzone
// Only one bite at the hotzone apple per bootyset.
if (inHotzone == true && hotzoneWasRan == false)
if (_genTables.containsKey(bse.genTable + 1) && ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate)) {
GenerateLootDrop(mob, bse.genTable + 1, true); //generate loot drop from hotzone table
hotzoneWasRan = true;
}
break; break;
case "ITEM": case "ITEM":
GenerateInventoryDrop(mob, bse); GenerateInventoryDrop(mob, bse);
@ -135,7 +127,7 @@ public enum LootManager {
} }
} }
public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob, Boolean inHotzone) { public static MobLoot getGenTableItem(int genTableID, AbstractCharacter mob) {
if (mob == null || _genTables.containsKey(genTableID) == false) if (mob == null || _genTables.containsKey(genTableID) == false)
return null; return null;
@ -160,7 +152,7 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { //52 = player character if(mob.getObjectType().ordinal() == 52) { //52 = player character
itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); itemTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
itemTableRoll = TableRoll(mob.level, inHotzone); itemTableRoll = TableRoll(mob.level);
} }
ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll); ItemTableEntry tableRow = ItemTableEntry.rollTable(itemTableId, itemTableRoll);
if (tableRow == null) if (tableRow == null)
@ -182,7 +174,7 @@ public enum LootManager {
if(selectedRow.pModTable != 0){ if(selectedRow.pModTable != 0){
try { try {
outItem = GeneratePrefix(mob, outItem, genTableID, genRoll, inHotzone); outItem = GeneratePrefix(mob, outItem, genTableID, genRoll);
outItem.setIsID(false); outItem.setIsID(false);
} catch (Exception e) { } catch (Exception e) {
Logger.error("Failed to GeneratePrefix for item: " + outItem.getName()); Logger.error("Failed to GeneratePrefix for item: " + outItem.getName());
@ -190,7 +182,7 @@ public enum LootManager {
} }
if(selectedRow.sModTable != 0){ if(selectedRow.sModTable != 0){
try { try {
outItem = GenerateSuffix(mob, outItem, genTableID, genRoll, inHotzone); outItem = GenerateSuffix(mob, outItem, genTableID, genRoll);
outItem.setIsID(false); outItem.setIsID(false);
} catch (Exception e) { } catch (Exception e) {
Logger.error("Failed to GenerateSuffix for item: " + outItem.getName()); Logger.error("Failed to GenerateSuffix for item: " + outItem.getName());
@ -199,7 +191,7 @@ public enum LootManager {
return outItem; return outItem;
} }
private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { private static MobLoot GeneratePrefix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) {
GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
@ -216,7 +208,7 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { if(mob.getObjectType().ordinal() == 52) {
prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); prefixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
prefixTableRoll = TableRoll(mob.level, inHotzone); prefixTableRoll = TableRoll(mob.level);
} }
ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll); ModTableEntry prefixMod = ModTableEntry.rollTable(prefixTable.modTableID, prefixTableRoll);
@ -231,7 +223,7 @@ public enum LootManager {
return inItem; return inItem;
} }
private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll, Boolean inHotzone) { private static MobLoot GenerateSuffix(AbstractCharacter mob, MobLoot inItem, int genTableID, int genRoll) {
GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f); GenTableEntry selectedRow = GenTableEntry.rollTable(genTableID, genRoll, 1.0f);
@ -248,7 +240,7 @@ public enum LootManager {
if(mob.getObjectType().ordinal() == 52) { if(mob.getObjectType().ordinal() == 52) {
suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1); suffixTableRoll = ThreadLocalRandom.current().nextInt(1,320 + 1);
} else{ } else{
suffixTableRoll = TableRoll(mob.level, inHotzone); suffixTableRoll = TableRoll(mob.level);
} }
ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll); ModTableEntry suffixMod = ModTableEntry.rollTable(suffixTable.modTableID, suffixTableRoll);
@ -263,7 +255,7 @@ public enum LootManager {
return inItem; return inItem;
} }
public static int TableRoll(int mobLevel, Boolean inHotzone) { public static int TableRoll(int mobLevel) {
if (mobLevel > 65) if (mobLevel > 65)
mobLevel = 65; mobLevel = 65;
@ -278,15 +270,12 @@ public enum LootManager {
if (min < 70) if (min < 70)
min = 70; min = 70;
if (inHotzone)
min += mobLevel;
int roll = ThreadLocalRandom.current().nextInt(min, max + 1); int roll = ThreadLocalRandom.current().nextInt(min, max + 1);
return roll; return roll;
} }
public static void GenerateGoldDrop(Mob mob, BootySetEntry bse, Boolean inHotzone) { public static void GenerateGoldDrop(Mob mob, BootySetEntry bse) {
int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); int chanceRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
@ -301,10 +290,7 @@ public enum LootManager {
int low = bse.lowGold; int low = bse.lowGold;
int gold = ThreadLocalRandom.current().nextInt(low, high + 1); int gold = ThreadLocalRandom.current().nextInt(low, high + 1);
if (inHotzone == true) gold = (int) (gold * NORMAL_GOLD_RATE);
gold = (int) (gold * HOTZONE_GOLD_RATE);
else
gold = (int) (gold * NORMAL_GOLD_RATE);
if (gold > 0) { if (gold > 0) {
MobLoot goldAmount = new MobLoot(mob, gold); MobLoot goldAmount = new MobLoot(mob, gold);
@ -313,11 +299,11 @@ public enum LootManager {
} }
public static void GenerateLootDrop(Mob mob, int tableID, Boolean inHotzone) { public static void GenerateLootDrop(Mob mob, int tableID) {
try { try {
MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); MobLoot toAdd = getGenTableItem(tableID, mob);
if (toAdd != null) if (toAdd != null)
mob.getCharItemManager().addItemToInventory(toAdd); mob.getCharItemManager().addItemToInventory(toAdd);

4
src/engine/objects/ItemFactory.java

@ -707,7 +707,7 @@ public class ItemFactory {
if (rollPrefix < 80) { if (rollPrefix < 80) {
int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false); int randomPrefix = LootManager.TableRoll(vendor.getLevel());
prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix);
if (prefixEntry != null) if (prefixEntry != null)
@ -722,7 +722,7 @@ public class ItemFactory {
if (rollSuffix < 80 || prefixEntry == null) { if (rollSuffix < 80 || prefixEntry == null) {
int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); int randomSuffix = LootManager.TableRoll(vendor.getLevel());
suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix);
if (suffixEntry != null) if (suffixEntry != null)

Loading…
Cancel
Save