Browse Source

Merge remote-tracking branch 'origin/bugfix-ITEM-chance'

master
MagicBot 1 year ago
parent
commit
0a36d2786c
  1. 25
      src/engine/loot/LootManager.java

25
src/engine/loot/LootManager.java

@ -104,7 +104,7 @@ public class LootManager {
} }
break; break;
case "ITEM": case "ITEM":
GenerateItemLootDrop(mob,bse); GenerateItemLootDrop(mob,bse,multiplier);
break; break;
} }
} }
@ -114,7 +114,7 @@ public class LootManager {
return null; return null;
} }
MobLoot outItem; MobLoot outItem;
int genRoll = new Random().nextInt(101); int genRoll = new Random().nextInt(100)+1;
GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll); GenTableRow selectedRow = generalItemTables.get(genTableID).getRowForRange(genRoll);
if (selectedRow == null) { if (selectedRow == null) {
return null; return null;
@ -138,12 +138,12 @@ public class LootManager {
Enum.ItemType outType = outItem.getItemBase().getType(); Enum.ItemType outType = outItem.getItemBase().getType();
if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) { if (outType.ordinal() == Enum.ItemType.WEAPON.ordinal() || outType.ordinal() == Enum.ItemType.ARMOR.ordinal() || outType.ordinal() == Enum.ItemType.JEWELRY.ordinal()) {
if (outItem.getItemBase().isGlass() == false) { if (outItem.getItemBase().isGlass() == false) {
int prefixChanceRoll = ThreadLocalRandom.current().nextInt(101); int prefixChanceRoll = ThreadLocalRandom.current().nextInt(100)+1;
double prefixChance = 2.057 * mob.level - 28.67; double prefixChance = 2.057 * mob.level - 28.67;
if (prefixChanceRoll < prefixChance) { if (prefixChanceRoll < prefixChance) {
ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable); ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable);
int prefixroll = ThreadLocalRandom.current().nextInt(101); int prefixroll = ThreadLocalRandom.current().nextInt(100)+1;
if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) { if (modTables.get(prefixTable.getRowForRange(prefixroll).modTableID) != null) {
ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID); ModTable prefixModTable = modTables.get(prefixTable.getRowForRange(prefixroll).modTableID);
ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level)); ModTableRow prefixMod = prefixModTable.getRowForRange(TableRoll(mob.level));
@ -153,10 +153,10 @@ public class LootManager {
} }
} }
} }
int suffixChanceRoll = ThreadLocalRandom.current().nextInt(101); int suffixChanceRoll = ThreadLocalRandom.current().nextInt(100)+1;
double suffixChance = 2.057 * mob.level - 28.67; double suffixChance = 2.057 * mob.level - 28.67;
if (suffixChanceRoll < suffixChance) { if (suffixChanceRoll < suffixChance) {
int suffixroll = ThreadLocalRandom.current().nextInt(101); int suffixroll = ThreadLocalRandom.current().nextInt(100)+1;
ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable); ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable);
if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) { if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) {
ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID); ModTable suffixModTable = modTables.get(suffixTable.getRowForRange(suffixroll).modTableID);
@ -175,9 +175,9 @@ public class LootManager {
if(mobLevel > 65){ if(mobLevel > 65){
mobLevel = 65; mobLevel = 65;
} }
int max = (int)(5.882 * mobLevel + 127.0); int max = (int)(4.882 * mobLevel + 127.0);
if(max > 320){ if(max > 321){
max = 320; max = 321;
} }
int min = (int)(4.469 * mobLevel - 3.469); int min = (int)(4.469 * mobLevel - 3.469);
int roll = ThreadLocalRandom.current().nextInt(max-min) + min; int roll = ThreadLocalRandom.current().nextInt(max-min) + min;
@ -273,7 +273,12 @@ public class LootManager {
} }
return; return;
} }
public static void GenerateItemLootDrop(Mob mob, BootySetEntry bse){ public static void GenerateItemLootDrop(Mob mob, BootySetEntry bse, float multiplier){
int chanceRoll = ThreadLocalRandom.current().nextInt(100) + 1;
if (chanceRoll > bse.dropChance * multiplier) {
//early exit, failed to hit minimum chance roll
return;
}
MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true); MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
if (disc != null) if (disc != null)
mob.getCharItemManager().addItemToInventory(disc); mob.getCharItemManager().addItemToInventory(disc);

Loading…
Cancel
Save