Browse Source

loot manager for glass runes and contracts

lakebane-new
FatBoy-DOTC 6 months ago
parent
commit
4f535ef5fe
  1. 12
      src/engine/gameManager/LootManager.java
  2. 13
      src/engine/loot/ItemTableEntry.java

12
src/engine/gameManager/LootManager.java

@ -104,7 +104,7 @@ public enum LootManager {
//1 in 1,000 chance to drop glass //1 in 1,000 chance to drop glass
if(ThreadLocalRandom.current().nextInt(1,1000) == 500){ if(ThreadLocalRandom.current().nextInt(1,1000) == 500){
int glassID = rollRandomItem(126,221); int glassID = rollRandomItem(126);
ItemBase glassItem = ItemBase.getItemBase(glassID); ItemBase glassItem = ItemBase.getItemBase(glassID);
if(glassItem != null) { if(glassItem != null) {
MobLoot toAdd = new MobLoot(mob, glassItem, false); MobLoot toAdd = new MobLoot(mob, glassItem, false);
@ -193,12 +193,12 @@ public enum LootManager {
if(ThreadLocalRandom.current().nextInt(1,101) < 91) if(ThreadLocalRandom.current().nextInt(1,101) < 91)
return null; // cut down world drops rates of resources by 90% return null; // cut down world drops rates of resources by 90%
}else if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.RUNE)){ }else if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.RUNE)){
int randomRune = rollRandomItem(itemTableId,75); int randomRune = rollRandomItem(itemTableId);
if(randomRune != 0) { if(randomRune != 0) {
itemUUID = randomRune; itemUUID = randomRune;
} }
} else if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.CONTRACT)){ } else if(ItemBase.getItemBase(itemUUID).getType().equals(Enum.ItemType.CONTRACT)){
int randomContract = rollRandomItem(itemTableId,191); int randomContract = rollRandomItem(itemTableId);
if(randomContract != 0) { if(randomContract != 0) {
itemUUID = randomContract; itemUUID = randomContract;
} }
@ -491,9 +491,7 @@ public enum LootManager {
itemMan.updateInventory(); itemMan.updateInventory();
} }
public static int rollRandomItem(int itemTable, int min){ public static int rollRandomItem(int itemTable){
int roll = ThreadLocalRandom.current().nextInt(min,321); return ItemTableEntry.getRandomItem(itemTable);
ItemTableEntry ite = ItemTableEntry.rollTable(itemTable, roll);
return ite.cacheID;
} }
} }

13
src/engine/loot/ItemTableEntry.java

@ -13,6 +13,7 @@ import engine.gameManager.LootManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
public class ItemTableEntry { public class ItemTableEntry {
public int minRoll; public int minRoll;
@ -42,4 +43,16 @@ public class ItemTableEntry {
return itemTableEntry; return itemTableEntry;
} }
public static Integer getRandomItem(int itemTable) {
List<ItemTableEntry> itemTableEntryList;
itemTableEntryList = LootManager._itemTables.get(itemTable);
if(itemTableEntryList != null){
return (itemTableEntryList.get(ThreadLocalRandom.current().nextInt(0,itemTableEntryList.size() - 1))).cacheID;
}
return 0;
}
} }

Loading…
Cancel
Save