From 712b44f00806a76ca7f0339a3c4efb374adb76a1 Mon Sep 17 00:00:00 2001 From: Von Hresvelg Date: Sun, 30 Oct 2022 07:24:31 +0000 Subject: [PATCH] Added secondary drop tables Uncommon seed drop table added Gem drop table added Herb drop table added Reworked Green Dragon drop table Reworked Moss Giant drop table --- Server/data/GDT.xml | 12 + Server/data/HERBDT.xml | 13 + Server/data/SEEDDT.xml | 26 + Server/data/configs/drop_tables.json | 534 +++++------------- Server/data/configs/item_configs.json | 15 + .../node/entity/npc/drop/GemDropTable.java | 96 ++++ .../node/entity/npc/drop/HerbDropTable.java | 96 ++++ .../node/entity/npc/drop/NPCDropTables.java | 9 + .../npc/drop/UncommonSeedDropTable.java | 96 ++++ .../src/main/kotlin/rs09/ServerConstants.kt | 9 + .../game/content/global/WeightBasedTable.kt | 26 +- .../game/system/config/ServerConfigParser.kt | 3 + Server/src/test/resources/test.conf | 6 + Server/worldprops/default.conf | 6 + 14 files changed, 553 insertions(+), 394 deletions(-) create mode 100644 Server/data/GDT.xml create mode 100644 Server/data/HERBDT.xml create mode 100644 Server/data/SEEDDT.xml create mode 100644 Server/src/main/java/core/game/node/entity/npc/drop/GemDropTable.java create mode 100644 Server/src/main/java/core/game/node/entity/npc/drop/HerbDropTable.java create mode 100644 Server/src/main/java/core/game/node/entity/npc/drop/UncommonSeedDropTable.java diff --git a/Server/data/GDT.xml b/Server/data/GDT.xml new file mode 100644 index 000000000..9c632e925 --- /dev/null +++ b/Server/data/GDT.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Server/data/HERBDT.xml b/Server/data/HERBDT.xml new file mode 100644 index 000000000..ae6e4793f --- /dev/null +++ b/Server/data/HERBDT.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Server/data/SEEDDT.xml b/Server/data/SEEDDT.xml new file mode 100644 index 000000000..390bda00d --- /dev/null +++ b/Server/data/SEEDDT.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Server/data/configs/drop_tables.json b/Server/data/configs/drop_tables.json index f31ede8aa..23c88f485 100644 --- a/Server/data/configs/drop_tables.json +++ b/Server/data/configs/drop_tables.json @@ -6646,364 +6646,172 @@ "ids": "112,1587,1588,1681,4534,4688,4706", "description": "", "main": [ - { - "minAmount": "1", - "weight": "50.0", - "id": "1389", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "1243", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "1285", - "maxAmount": "1" - }, - { - "minAmount": "30", - "weight": "50.0", - "id": "886", - "maxAmount": "30" - }, - { - "minAmount": "15", - "weight": "50.0", - "id": "884", - "maxAmount": "15" - }, { "minAmount": "1", "weight": "5.0", - "id": "1287", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "1165", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", "id": "1179", "maxAmount": "1" }, { "minAmount": "1", - "weight": "50.0", + "weight": "2.0", + "id": "1389", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "2.0", "id": "1141", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "2.0", + "id": "1285", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "2.0", + "id": "1243", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "1.0", "id": "1193", "maxAmount": "1" }, + { + "minAmount": "3", + "weight": "4.0", + "id": "563", + "maxAmount": "3" + }, { "minAmount": "18", - "weight": "50.0", + "weight": "3.0", "id": "556", "maxAmount": "18" }, - { - "minAmount": "3", - "weight": "50.0", - "id": "564", - "maxAmount": "3" - }, { "minAmount": "27", - "weight": "50.0", + "weight": "3.0", "id": "557", "maxAmount": "27" }, + { + "minAmount": "7", + "weight": "3.0", + "id": "562", + "maxAmount": "7" + }, { "minAmount": "6", - "weight": "50.0", + "weight": "3.0", "id": "561", "maxAmount": "6" }, { "minAmount": "3", - "weight": "25.0", - "id": "563", - "maxAmount": "6" + "weight": "2.0", + "id": "564", + "maxAmount": "3" + }, + { + "minAmount": "15", + "weight": "2.0", + "id": "884", + "maxAmount": "15" + }, + { + "minAmount": "30", + "weight": "1.0", + "id": "886", + "maxAmount": "30" + }, + { + "minAmount": "3", + "weight": "1.0", + "id": "560", + "maxAmount": "3" }, { "minAmount": "1", - "weight": "25.0", + "weight": "1.0", "id": "565", "maxAmount": "1" }, - { - "minAmount": "7", - "weight": "25.0", - "id": "562", - "maxAmount": "7" - }, - { - "minAmount": "13", - "weight": "5.0", - "id": "560", - "maxAmount": "13" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "5323", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "5311", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "5293", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "5294", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "5104", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "5292", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "5281", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "12176", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "5100", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "5296", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "5105", - "maxAmount": "1" - }, { "minAmount": "1", "weight": "5.0", - "id": "5298", + "id": "14424", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", - "id": "5280", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5297", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5299", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5106", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5295", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5301", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5302", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5321", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "5303", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "199", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "201", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "203", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", - "id": "205", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "211", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "215", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "217", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "209", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "213", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "2485", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "207", + "weight": "35.0", + "id": "14422", "maxAmount": "1" }, { "minAmount": "2", - "weight": "50.0", + "weight": "8.0", "id": "995", - "maxAmount": "500" + "maxAmount": "2" + }, + { + "minAmount": "37", + "weight": "19.0", + "id": "995", + "maxAmount": "37" + }, + { + "minAmount": "119", + "weight": "10.0", + "id": "995", + "maxAmount": "119" + }, + { + "minAmount": "300", + "weight": "2.0", + "id": "995", + "maxAmount": "300" }, { "minAmount": "1", - "weight": "50.0", + "weight": "6.0", "id": "2353", "maxAmount": "1" }, { "minAmount": "1", - "weight": "50.0", - "id": "7871", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", + "weight": "1.0", "id": "453", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "1.0", "id": "1969", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", - "id": "1442", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", - "id": "10977", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "5.0", + "weight": "0.32", "id": "10976", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", - "id": "31", + "weight": "0.0256", + "id": "10977", "maxAmount": "1" }, { "minAmount": "1", - "weight": "61.6452", - "id": "0", + "weight": "4.0", + "id": "14426", "maxAmount": "1" } ] @@ -16616,193 +16424,133 @@ "main": [ { "minAmount": "1", - "weight": "50.0", - "id": "1365", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "50.0", + "weight": "4.0", "id": "1069", "maxAmount": "1" }, { "minAmount": "1", - "weight": "50.0", + "weight": "3.0", + "id": "1365", + "maxAmount": "1" + }, + { + "minAmount": "1", + "weight": "3.0", "id": "1355", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "2.0", "id": "1243", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "1.0", "id": "1197", "maxAmount": "1" }, { "minAmount": "1", - "weight": "5.0", - "id": "1145", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", + "weight": "1.0", "id": "1161", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "1.0", "id": "1213", "maxAmount": "1" }, { "minAmount": "75", - "weight": "50.0", + "weight": "8.0", "id": "555", "maxAmount": "75" }, - { - "minAmount": "37", - "weight": "50.0", - "id": "554", - "maxAmount": "37" - }, { "minAmount": "15", - "weight": "25.0", + "weight": "5.0", "id": "561", "maxAmount": "15" }, - { - "minAmount": "30", - "weight": "25.0", - "id": "561", - "maxAmount": "30" - }, - { - "minAmount": "75", - "weight": "5.0", - "id": "561", - "maxAmount": "75" - }, { "minAmount": "3", - "weight": "50.0", + "weight": "3.0", "id": "563", "maxAmount": "3" }, { - "minAmount": "1", - "weight": "25.0", - "id": "199", - "maxAmount": "1" + "minAmount": "37", + "weight": "1.0", + "id": "554", + "maxAmount": "37" }, { "minAmount": "1", - "weight": "25.0", - "id": "201", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "203", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "205", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "207", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "209", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "211", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "213", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "215", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "2485", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "25.0", - "id": "217", + "weight": "15.0", + "id": "14424", "maxAmount": "1" }, { "minAmount": "11", - "weight": "50.0", + "weight": "10.0", + "id": "995", + "maxAmount": "11" + }, + { + "minAmount": "44", + "weight": "23.0", + "id": "995", + "maxAmount": "44" + }, + { + "minAmount": "132", + "weight": "25.0", + "id": "995", + "maxAmount": "132" + }, + { + "minAmount": "200", + "weight": "10.0", + "id": "995", + "maxAmount": "200" + }, + { + "minAmount": "440", + "weight": "1.0", "id": "995", "maxAmount": "440" }, { "minAmount": "1", - "weight": "50.0", + "weight": "3.0", "id": "365", "maxAmount": "1" }, { "minAmount": "1", - "weight": "25.0", + "weight": "3.0", "id": "449", "maxAmount": "1" }, { "minAmount": "1", - "weight": "8.153", - "id": "5733", + "weight": "5.0", + "id": "14426", "maxAmount": "1" }, { "minAmount": "1", - "weight": "15.5", - "id": "31", + "weight": "1.0", + "id": "12070", "maxAmount": "1" }, { "minAmount": "1", - "weight": "150.0", - "id": "0", - "maxAmount": "1" - }, - { - "minAmount": "1", - "weight": "10.0", + "weight": "0.25", "id": "12479", "maxAmount": "1" } diff --git a/Server/data/configs/item_configs.json b/Server/data/configs/item_configs.json index aad235a7f..4f2712fa6 100644 --- a/Server/data/configs/item_configs.json +++ b/Server/data/configs/item_configs.json @@ -130578,5 +130578,20 @@ "archery_ticket_price": "0", "weight": "0.01", "id": "298" + }, + { + "examine": "You should not have this.", + "name": "Uncommon Seed Drop Table", + "id": "14422" + }, + { + "examine": "You should not have this.", + "name": "Herb Drop Table", + "id": "14424" + }, + { + "examine": "You should not have this.", + "name": "Gem Drop Table", + "id": "14426" } ] \ No newline at end of file diff --git a/Server/src/main/java/core/game/node/entity/npc/drop/GemDropTable.java b/Server/src/main/java/core/game/node/entity/npc/drop/GemDropTable.java new file mode 100644 index 000000000..9c8b287ee --- /dev/null +++ b/Server/src/main/java/core/game/node/entity/npc/drop/GemDropTable.java @@ -0,0 +1,96 @@ +package core.game.node.entity.npc.drop; + +import api.StartupListener; +import core.game.node.item.Item; +import core.game.node.item.WeightedChanceItem; +import core.tools.RandomFunction; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import rs09.ServerConstants; +import rs09.game.system.SystemLogger; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import static rs09.game.system.SystemLogger.logInfo; + +/** + * Handles the gem drop table. + * @author Von Hresvelg + */ +public final class GemDropTable implements StartupListener { + + /** + * The item id of the item representing the gem drop table slot in a drop + * table. + */ + public static final int SLOT_ITEM_ID = 14426; + + /** + * The gem drop table. + */ + private static final List TABLE = new ArrayList<>(20); + + + /** + * Initialize needed objects for xml reading/writing + */ + static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + static DocumentBuilder builder; + + static { + try { + builder = factory.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } + } + + public GemDropTable() throws ParserConfigurationException {} + + @Override + public void startup() { + if(ServerConstants.GDT_DATA_PATH != null && !new File(ServerConstants.GDT_DATA_PATH).exists()){ + SystemLogger.logErr(this.getClass(), "Can't locate GDT file at " + ServerConstants.GDT_DATA_PATH); + return; + } + parse(ServerConstants.GDT_DATA_PATH); + logInfo(this.getClass(), "Initialized Gem Drop Table from " + ServerConstants.GDT_DATA_PATH); + } + + /** + * Parses the xml file for the gem drop table. + * @param file the .xml file containing the gem drop table. + */ + public static void parse(String file){ + try { + Document doc = builder.parse(file); + + NodeList itemNodes = doc.getElementsByTagName("item"); + for(int i = 0; i < itemNodes.getLength(); i++){ + Node itemNode = itemNodes.item(i); + if(itemNode.getNodeType() == Node.ELEMENT_NODE){ + Element item = (Element) itemNode; + int itemId = Integer.parseInt(item.getAttribute("id")); + int minAmt = Integer.parseInt(item.getAttribute("minAmt")); + int maxAmt = Integer.parseInt(item.getAttribute("maxAmt")); + int weight = Integer.parseInt(item.getAttribute("weight")); + + TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight)); + } + } + } catch (Exception e){ + e.printStackTrace(); + } + } + + public static Item retrieve(){ + return RandomFunction.rollWeightedChanceTable(TABLE); + } +} \ No newline at end of file diff --git a/Server/src/main/java/core/game/node/entity/npc/drop/HerbDropTable.java b/Server/src/main/java/core/game/node/entity/npc/drop/HerbDropTable.java new file mode 100644 index 000000000..b1ab168d5 --- /dev/null +++ b/Server/src/main/java/core/game/node/entity/npc/drop/HerbDropTable.java @@ -0,0 +1,96 @@ +package core.game.node.entity.npc.drop; + +import api.StartupListener; +import core.game.node.item.Item; +import core.game.node.item.WeightedChanceItem; +import core.tools.RandomFunction; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import rs09.ServerConstants; +import rs09.game.system.SystemLogger; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import static rs09.game.system.SystemLogger.logInfo; + +/** + * Handles the herb drop table. + * @author Von Hresvelg + */ +public final class HerbDropTable implements StartupListener { + + /** + * The item id of the item representing the herb drop table slot in a drop + * table. + */ + public static final int SLOT_ITEM_ID = 14424; + + /** + * The herb drop table. + */ + private static final List TABLE = new ArrayList<>(20); + + + /** + * Initialize needed objects for xml reading/writing + */ + static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + static DocumentBuilder builder; + + static { + try { + builder = factory.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } + } + + public HerbDropTable() throws ParserConfigurationException {} + + @Override + public void startup() { + if(ServerConstants.HERBDT_DATA_PATH != null && !new File(ServerConstants.HERBDT_DATA_PATH).exists()){ + SystemLogger.logErr(this.getClass(), "Can't locate HERBDT file at " + ServerConstants.HERBDT_DATA_PATH); + return; + } + parse(ServerConstants.HERBDT_DATA_PATH); + logInfo(this.getClass(), "Initialized Herb Drop Table from " + ServerConstants.HERBDT_DATA_PATH); + } + + /** + * Parses the xml file for the herb drop table. + * @param file the .xml file containing the herb drop table. + */ + public static void parse(String file){ + try { + Document doc = builder.parse(file); + + NodeList itemNodes = doc.getElementsByTagName("item"); + for(int i = 0; i < itemNodes.getLength(); i++){ + Node itemNode = itemNodes.item(i); + if(itemNode.getNodeType() == Node.ELEMENT_NODE){ + Element item = (Element) itemNode; + int itemId = Integer.parseInt(item.getAttribute("id")); + int minAmt = Integer.parseInt(item.getAttribute("minAmt")); + int maxAmt = Integer.parseInt(item.getAttribute("maxAmt")); + int weight = Integer.parseInt(item.getAttribute("weight")); + + TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight)); + } + } + } catch (Exception e){ + e.printStackTrace(); + } + } + + public static Item retrieve(){ + return RandomFunction.rollWeightedChanceTable(TABLE); + } +} \ No newline at end of file diff --git a/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java b/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java index 42c1d8495..a5a0b05d8 100644 --- a/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java +++ b/Server/src/main/java/core/game/node/entity/npc/drop/NPCDropTables.java @@ -92,6 +92,15 @@ public final class NPCDropTables { if (item.getId() == RareDropTable.SLOT_ITEM_ID){ item = RareDropTable.retrieve(); } + if (item.getId() == UncommonSeedDropTable.SLOT_ITEM_ID){ + item = UncommonSeedDropTable.retrieve(); + } + if (item.getId() == HerbDropTable.SLOT_ITEM_ID){ + item = HerbDropTable.retrieve(); + } + if (item.getId() == GemDropTable.SLOT_ITEM_ID){ + item = GemDropTable.retrieve(); + } if (item.getId() == 995 && player.getBank().hasSpaceFor(item) && ( player.getGlobalData().isEnableCoinMachine() )) { item = new Item(995, (int) (item.getAmount() + (item.getAmount() * 0.25))); player.getBank().add(item); diff --git a/Server/src/main/java/core/game/node/entity/npc/drop/UncommonSeedDropTable.java b/Server/src/main/java/core/game/node/entity/npc/drop/UncommonSeedDropTable.java new file mode 100644 index 000000000..2792a3b8d --- /dev/null +++ b/Server/src/main/java/core/game/node/entity/npc/drop/UncommonSeedDropTable.java @@ -0,0 +1,96 @@ +package core.game.node.entity.npc.drop; + +import api.StartupListener; +import core.game.node.item.Item; +import core.game.node.item.WeightedChanceItem; +import core.tools.RandomFunction; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import rs09.ServerConstants; +import rs09.game.system.SystemLogger; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import static rs09.game.system.SystemLogger.logInfo; + +/** + * Handles the seed drop table. + * @author Von Hresvelg + */ +public final class UncommonSeedDropTable implements StartupListener { + + /** + * The item id of the item representing the seed drop table slot in a drop + * table. + */ + public static final int SLOT_ITEM_ID = 14422; + + /** + * The seed drop table. + */ + private static final List TABLE = new ArrayList<>(20); + + + /** + * Initialize needed objects for xml reading/writing + */ + static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + static DocumentBuilder builder; + + static { + try { + builder = factory.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } + } + + public UncommonSeedDropTable() throws ParserConfigurationException {} + + @Override + public void startup() { + if(ServerConstants.SEEDDT_DATA_PATH != null && !new File(ServerConstants.SEEDDT_DATA_PATH).exists()){ + SystemLogger.logErr(this.getClass(), "Can't locate SEEDDT file at " + ServerConstants.SEEDDT_DATA_PATH); + return; + } + parse(ServerConstants.SEEDDT_DATA_PATH); + logInfo(this.getClass(), "Initialized Uncommon Seed Drop Table from " + ServerConstants.SEEDDT_DATA_PATH); + } + + /** + * Parses the xml file for the seed drop table. + * @param file the .xml file containing the seed drop table. + */ + public static void parse(String file){ + try { + Document doc = builder.parse(file); + + NodeList itemNodes = doc.getElementsByTagName("item"); + for(int i = 0; i < itemNodes.getLength(); i++){ + Node itemNode = itemNodes.item(i); + if(itemNode.getNodeType() == Node.ELEMENT_NODE){ + Element item = (Element) itemNode; + int itemId = Integer.parseInt(item.getAttribute("id")); + int minAmt = Integer.parseInt(item.getAttribute("minAmt")); + int maxAmt = Integer.parseInt(item.getAttribute("maxAmt")); + int weight = Integer.parseInt(item.getAttribute("weight")); + + TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight)); + } + } + } catch (Exception e){ + e.printStackTrace(); + } + } + + public static Item retrieve(){ + return RandomFunction.rollWeightedChanceTable(TABLE); + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/ServerConstants.kt b/Server/src/main/kotlin/rs09/ServerConstants.kt index 9425830f1..6189127de 100644 --- a/Server/src/main/kotlin/rs09/ServerConstants.kt +++ b/Server/src/main/kotlin/rs09/ServerConstants.kt @@ -74,6 +74,15 @@ class ServerConstants { @JvmField var CELEDT_DATA_PATH: String? = null + @JvmField + var SEEDDT_DATA_PATH: String? = null + + @JvmField + var HERBDT_DATA_PATH: String? = null + + @JvmField + var GDT_DATA_PATH: String? = null + //the max number of players. @JvmField var MAX_PLAYERS = 2000 diff --git a/Server/src/main/kotlin/rs09/game/content/global/WeightBasedTable.kt b/Server/src/main/kotlin/rs09/game/content/global/WeightBasedTable.kt index 32a242f6d..1709a4abf 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/WeightBasedTable.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/WeightBasedTable.kt @@ -5,6 +5,9 @@ import core.game.content.ttrail.ClueLevel import core.game.content.ttrail.ClueScrollPlugin import core.game.node.entity.npc.drop.RareDropTable import core.game.node.entity.npc.drop.CELEMinorTable +import core.game.node.entity.npc.drop.UncommonSeedDropTable +import core.game.node.entity.npc.drop.HerbDropTable +import core.game.node.entity.npc.drop.GemDropTable import core.game.node.entity.player.Player import core.game.node.item.Item import core.tools.RandomFunction @@ -53,6 +56,9 @@ open class WeightBasedTable : ArrayList() { SLOT_CLUE_HARD -> ClueScrollPlugin.getClue(ClueLevel.HARD) SLOT_RDT -> RareDropTable.retrieve() SLOT_CELEDT -> CELEMinorTable.retrieve() + SLOT_SEEDDT -> UncommonSeedDropTable.retrieve() + SLOT_HERBDT -> HerbDropTable.retrieve() + SLOT_GDT -> GemDropTable.retrieve() else -> e.getItem() } safeItems.add(safeItem) @@ -88,7 +94,22 @@ open class WeightBasedTable : ArrayList() { fun insertCELEDTRoll(weight: Double): WeightBasedTable{ this.add(WeightedItem(SLOT_CELEDT,1,1,weight,false)) return this - } + } + + fun insertSEEDDTRoll(weight: Double): WeightBasedTable{ + this.add(WeightedItem(SLOT_SEEDDT,1,1,weight,false)) + return this + } + + fun insertHERBDTRoll(weight: Double): WeightBasedTable{ + this.add(WeightedItem(SLOT_HERBDT,1,1,weight,false)) + return this + } + + fun insertGDTRoll(weight: Double): WeightBasedTable{ + this.add(WeightedItem(SLOT_GDT,1,1,weight,false)) + return this + } companion object { @JvmStatic @@ -106,6 +127,9 @@ open class WeightBasedTable : ArrayList() { val SLOT_CLUE_MEDIUM = Items.ROTTEN_POTATO_5733 val SLOT_CLUE_HARD = Items.GRANITE_LOBSTER_POUCH_12070 val SLOT_CELEDT = Items.NULL_799 + val SLOT_SEEDDT = Items.SACRED_CLAY_POUCH_CLASS_1_14422 + val SLOT_HERBDT = Items.SACRED_CLAY_POUCH_CLASS_2_14424 + val SLOT_GDT = Items.SACRED_CLAY_POUCH_CLASS_3_14426 } override fun toString(): String { diff --git a/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt b/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt index 7e1e95679..0bb1b0558 100644 --- a/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt +++ b/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt @@ -110,6 +110,9 @@ object ServerConfigParser { ServerConstants.LOG_CUTSCENE = data.getBoolean("world.verbose_cutscene", false) ServerConstants.GRAND_EXCHANGE_DATA_PATH = data.getPath("paths.eco_data") ServerConstants.CELEDT_DATA_PATH = data.getPath("paths.cele_drop_table_path") + ServerConstants.SEEDDT_DATA_PATH = data.getPath("paths.seed_drop_table_path") + ServerConstants.HERBDT_DATA_PATH = data.getPath("paths.herb_drop_table_path") + ServerConstants.GDT_DATA_PATH = data.getPath("paths.gem_drop_table_path") ServerConstants.SERVER_GE_NAME = data.getString("world.name_ge") ?: ServerConstants.SERVER_NAME ServerConstants.RULES_AND_INFO_ENABLED = data.getBoolean("world.show_rules", true) ServerConstants.BOTS_INFLUENCE_PRICE_INDEX = data.getBoolean("world.bots_influence_ge_price", true) diff --git a/Server/src/test/resources/test.conf b/Server/src/test/resources/test.conf index 97ca19a32..a44c1a0aa 100644 --- a/Server/src/test/resources/test.conf +++ b/Server/src/test/resources/test.conf @@ -64,6 +64,12 @@ grand_exchange_data_path = "@data/eco" rare_drop_table_path = "@data/RDT.xml" #path to file defining c.ele minor drop table cele_drop_table_path = "@data/CELEDT.xml" +#path to file defining the uncommon seed drop table +seed_drop_table_path = "@data/SEEDDT.xml" +#path to file defining the herb drop table +herb_drop_table_path = "@data/HERBDT.xml" +#path to file defining the gem drop table +gem_drop_table_path = "@data/GDT.xml" #path to file containing boot-time object changes object_parser_path = "@data/ObjectParser.xml" #path logs are written to diff --git a/Server/worldprops/default.conf b/Server/worldprops/default.conf index 8bdb499da..b5d9afa73 100644 --- a/Server/worldprops/default.conf +++ b/Server/worldprops/default.conf @@ -86,6 +86,12 @@ grand_exchange_data_path = "@data/eco" rare_drop_table_path = "@data/RDT.xml" #path to file defining c.ele minor drop table cele_drop_table_path = "@data/CELEDT.xml" +#path to file defining the uncommon seed drop table +seed_drop_table_path = "@data/SEEDDT.xml" +#path to file defining the herb drop table +herb_drop_table_path = "@data/HERBDT.xml" +#path to file defining the gem drop table +gem_drop_table_path = "@data/GDT.xml" #path to file containing boot-time object changes object_parser_path = "@data/ObjectParser.xml" #path logs are written to