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
This commit is contained in:
Von Hresvelg 2022-10-30 07:24:31 +00:00 committed by Ryan
parent b64a595562
commit 712b44f008
14 changed files with 553 additions and 394 deletions

12
Server/data/GDT.xml Normal file
View file

@ -0,0 +1,12 @@
<GDT>
<item id="0" minAmt="1" maxAmt="1" weight="64"/>
<item id="1623" minAmt="1" maxAmt="1" weight="32"/>
<item id="1621" minAmt="1" maxAmt="1" weight="16"/>
<item id="1619" minAmt="1" maxAmt="1" weight="8"/>
<item id="1617" minAmt="1" maxAmt="1" weight="2"/>
<item id="1452" minAmt="1" maxAmt="1" weight="1.5"/>
<item id="1462" minAmt="1" maxAmt="1" weight="1.5"/>
<item id="830" minAmt="5" maxAmt="5" weight="1"/>
<item id="985" minAmt="1" maxAmt="1" weight="1"/>
<item id="987" minAmt="1" maxAmt="1" weight="1"/>
</GDT>

13
Server/data/HERBDT.xml Normal file
View file

@ -0,0 +1,13 @@
<HERBDT>
<item id="199" minAmt="1" maxAmt="1" weight="32"/>
<item id="201" minAmt="1" maxAmt="1" weight="24"/>
<item id="203" minAmt="1" maxAmt="1" weight="18"/>
<item id="205" minAmt="1" maxAmt="1" weight="14"/>
<item id="207" minAmt="1" maxAmt="1" weight="11"/>
<item id="209" minAmt="1" maxAmt="1" weight="8"/>
<item id="211" minAmt="1" maxAmt="1" weight="6"/>
<item id="213" minAmt="1" maxAmt="1" weight="5"/>
<item id="215" minAmt="1" maxAmt="1" weight="4"/>
<item id="2485" minAmt="1" maxAmt="1" weight="3"/>
<item id="217" minAmt="1" maxAmt="1" weight="3"/>
</HERBDT>

26
Server/data/SEEDDT.xml Normal file
View file

@ -0,0 +1,26 @@
<SEEDDT>
<item id="5100" minAmt="1" maxAmt="1" weight="136"/>
<item id="5323" minAmt="1" maxAmt="1" weight="130"/>
<item id="5292" minAmt="1" maxAmt="1" weight="122"/>
<item id="5104" minAmt="1" maxAmt="1" weight="91"/>
<item id="5293" minAmt="1" maxAmt="1" weight="83"/>
<item id="5311" minAmt="1" maxAmt="1" weight="82"/>
<item id="5321" minAmt="1" maxAmt="1" weight="62"/>
<item id="5294" minAmt="1" maxAmt="1" weight="57"/>
<item id="5295" minAmt="1" maxAmt="1" weight="39"/>
<item id="12176" minAmt="1" maxAmt="1" weight="38"/>
<item id="5105" minAmt="1" maxAmt="1" weight="33"/>
<item id="5282" minAmt="1" maxAmt="1" weight="28"/>
<item id="5296" minAmt="1" maxAmt="1" weight="26"/>
<item id="5281" minAmt="1" maxAmt="1" weight="18"/>
<item id="5297" minAmt="1" maxAmt="1" weight="18"/>
<item id="5106" minAmt="1" maxAmt="1" weight="13"/>
<item id="5298" minAmt="1" maxAmt="1" weight="12"/>
<item id="5280" minAmt="1" maxAmt="1" weight="11"/>
<item id="5299" minAmt="1" maxAmt="1" weight="9"/>
<item id="5300" minAmt="1" maxAmt="1" weight="5"/>
<item id="5301" minAmt="1" maxAmt="1" weight="4"/>
<item id="5302" minAmt="1" maxAmt="1" weight="3"/>
<item id="5303" minAmt="1" maxAmt="1" weight="2"/>
<item id="5304" minAmt="1" maxAmt="1" weight="1"/>
</SEEDDT>

View file

@ -6646,364 +6646,172 @@
"ids": "112,1587,1588,1681,4534,4688,4706", "ids": "112,1587,1588,1681,4534,4688,4706",
"description": "", "description": "",
"main": [ "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", "minAmount": "1",
"weight": "5.0", "weight": "5.0",
"id": "1287",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "50.0",
"id": "1165",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "50.0",
"id": "1179", "id": "1179",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "50.0", "weight": "2.0",
"id": "1389",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "2.0",
"id": "1141", "id": "1141",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "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", "id": "1193",
"maxAmount": "1" "maxAmount": "1"
}, },
{
"minAmount": "3",
"weight": "4.0",
"id": "563",
"maxAmount": "3"
},
{ {
"minAmount": "18", "minAmount": "18",
"weight": "50.0", "weight": "3.0",
"id": "556", "id": "556",
"maxAmount": "18" "maxAmount": "18"
}, },
{
"minAmount": "3",
"weight": "50.0",
"id": "564",
"maxAmount": "3"
},
{ {
"minAmount": "27", "minAmount": "27",
"weight": "50.0", "weight": "3.0",
"id": "557", "id": "557",
"maxAmount": "27" "maxAmount": "27"
}, },
{
"minAmount": "7",
"weight": "3.0",
"id": "562",
"maxAmount": "7"
},
{ {
"minAmount": "6", "minAmount": "6",
"weight": "50.0", "weight": "3.0",
"id": "561", "id": "561",
"maxAmount": "6" "maxAmount": "6"
}, },
{ {
"minAmount": "3", "minAmount": "3",
"weight": "25.0", "weight": "2.0",
"id": "563", "id": "564",
"maxAmount": "6" "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", "minAmount": "1",
"weight": "25.0", "weight": "1.0",
"id": "565", "id": "565",
"maxAmount": "1" "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", "minAmount": "1",
"weight": "5.0", "weight": "5.0",
"id": "5298", "id": "14424",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "5.0", "weight": "35.0",
"id": "5280", "id": "14422",
"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",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "2", "minAmount": "2",
"weight": "50.0", "weight": "8.0",
"id": "995", "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", "minAmount": "1",
"weight": "50.0", "weight": "6.0",
"id": "2353", "id": "2353",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "50.0", "weight": "1.0",
"id": "7871",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "453", "id": "453",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "25.0", "weight": "1.0",
"id": "1969", "id": "1969",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "5.0", "weight": "0.32",
"id": "1442",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "10977",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "10976", "id": "10976",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "5.0", "weight": "0.0256",
"id": "31", "id": "10977",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "61.6452", "weight": "4.0",
"id": "0", "id": "14426",
"maxAmount": "1" "maxAmount": "1"
} }
] ]
@ -16616,193 +16424,133 @@
"main": [ "main": [
{ {
"minAmount": "1", "minAmount": "1",
"weight": "50.0", "weight": "4.0",
"id": "1365",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "50.0",
"id": "1069", "id": "1069",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "50.0", "weight": "3.0",
"id": "1365",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "3.0",
"id": "1355", "id": "1355",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "25.0", "weight": "2.0",
"id": "1243", "id": "1243",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "25.0", "weight": "1.0",
"id": "1197", "id": "1197",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "5.0", "weight": "1.0",
"id": "1145",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "1161", "id": "1161",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "25.0", "weight": "1.0",
"id": "1213", "id": "1213",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "75", "minAmount": "75",
"weight": "50.0", "weight": "8.0",
"id": "555", "id": "555",
"maxAmount": "75" "maxAmount": "75"
}, },
{
"minAmount": "37",
"weight": "50.0",
"id": "554",
"maxAmount": "37"
},
{ {
"minAmount": "15", "minAmount": "15",
"weight": "25.0", "weight": "5.0",
"id": "561", "id": "561",
"maxAmount": "15" "maxAmount": "15"
}, },
{
"minAmount": "30",
"weight": "25.0",
"id": "561",
"maxAmount": "30"
},
{
"minAmount": "75",
"weight": "5.0",
"id": "561",
"maxAmount": "75"
},
{ {
"minAmount": "3", "minAmount": "3",
"weight": "50.0", "weight": "3.0",
"id": "563", "id": "563",
"maxAmount": "3" "maxAmount": "3"
}, },
{ {
"minAmount": "1", "minAmount": "37",
"weight": "25.0", "weight": "1.0",
"id": "199", "id": "554",
"maxAmount": "1" "maxAmount": "37"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "25.0", "weight": "15.0",
"id": "201", "id": "14424",
"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",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "11", "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", "id": "995",
"maxAmount": "440" "maxAmount": "440"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "50.0", "weight": "3.0",
"id": "365", "id": "365",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "25.0", "weight": "3.0",
"id": "449", "id": "449",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "8.153", "weight": "5.0",
"id": "5733", "id": "14426",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "15.5", "weight": "1.0",
"id": "31", "id": "12070",
"maxAmount": "1" "maxAmount": "1"
}, },
{ {
"minAmount": "1", "minAmount": "1",
"weight": "150.0", "weight": "0.25",
"id": "0",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "10.0",
"id": "12479", "id": "12479",
"maxAmount": "1" "maxAmount": "1"
} }

View file

@ -130578,5 +130578,20 @@
"archery_ticket_price": "0", "archery_ticket_price": "0",
"weight": "0.01", "weight": "0.01",
"id": "298" "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"
} }
] ]

View file

@ -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<WeightedChanceItem> 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);
}
}

View file

@ -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<WeightedChanceItem> 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);
}
}

View file

@ -92,6 +92,15 @@ public final class NPCDropTables {
if (item.getId() == RareDropTable.SLOT_ITEM_ID){ if (item.getId() == RareDropTable.SLOT_ITEM_ID){
item = RareDropTable.retrieve(); 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() )) { if (item.getId() == 995 && player.getBank().hasSpaceFor(item) && ( player.getGlobalData().isEnableCoinMachine() )) {
item = new Item(995, (int) (item.getAmount() + (item.getAmount() * 0.25))); item = new Item(995, (int) (item.getAmount() + (item.getAmount() * 0.25)));
player.getBank().add(item); player.getBank().add(item);

View file

@ -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<WeightedChanceItem> 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);
}
}

View file

@ -74,6 +74,15 @@ class ServerConstants {
@JvmField @JvmField
var CELEDT_DATA_PATH: String? = null 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. //the max number of players.
@JvmField @JvmField
var MAX_PLAYERS = 2000 var MAX_PLAYERS = 2000

View file

@ -5,6 +5,9 @@ import core.game.content.ttrail.ClueLevel
import core.game.content.ttrail.ClueScrollPlugin import core.game.content.ttrail.ClueScrollPlugin
import core.game.node.entity.npc.drop.RareDropTable import core.game.node.entity.npc.drop.RareDropTable
import core.game.node.entity.npc.drop.CELEMinorTable 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.entity.player.Player
import core.game.node.item.Item import core.game.node.item.Item
import core.tools.RandomFunction import core.tools.RandomFunction
@ -53,6 +56,9 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
SLOT_CLUE_HARD -> ClueScrollPlugin.getClue(ClueLevel.HARD) SLOT_CLUE_HARD -> ClueScrollPlugin.getClue(ClueLevel.HARD)
SLOT_RDT -> RareDropTable.retrieve() SLOT_RDT -> RareDropTable.retrieve()
SLOT_CELEDT -> CELEMinorTable.retrieve() SLOT_CELEDT -> CELEMinorTable.retrieve()
SLOT_SEEDDT -> UncommonSeedDropTable.retrieve()
SLOT_HERBDT -> HerbDropTable.retrieve()
SLOT_GDT -> GemDropTable.retrieve()
else -> e.getItem() else -> e.getItem()
} }
safeItems.add(safeItem) safeItems.add(safeItem)
@ -90,6 +96,21 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
return this 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 { companion object {
@JvmStatic @JvmStatic
fun create(vararg items: WeightedItem): WeightBasedTable{ fun create(vararg items: WeightedItem): WeightBasedTable{
@ -106,6 +127,9 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
val SLOT_CLUE_MEDIUM = Items.ROTTEN_POTATO_5733 val SLOT_CLUE_MEDIUM = Items.ROTTEN_POTATO_5733
val SLOT_CLUE_HARD = Items.GRANITE_LOBSTER_POUCH_12070 val SLOT_CLUE_HARD = Items.GRANITE_LOBSTER_POUCH_12070
val SLOT_CELEDT = Items.NULL_799 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 { override fun toString(): String {

View file

@ -110,6 +110,9 @@ object ServerConfigParser {
ServerConstants.LOG_CUTSCENE = data.getBoolean("world.verbose_cutscene", false) ServerConstants.LOG_CUTSCENE = data.getBoolean("world.verbose_cutscene", false)
ServerConstants.GRAND_EXCHANGE_DATA_PATH = data.getPath("paths.eco_data") ServerConstants.GRAND_EXCHANGE_DATA_PATH = data.getPath("paths.eco_data")
ServerConstants.CELEDT_DATA_PATH = data.getPath("paths.cele_drop_table_path") 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.SERVER_GE_NAME = data.getString("world.name_ge") ?: ServerConstants.SERVER_NAME
ServerConstants.RULES_AND_INFO_ENABLED = data.getBoolean("world.show_rules", true) ServerConstants.RULES_AND_INFO_ENABLED = data.getBoolean("world.show_rules", true)
ServerConstants.BOTS_INFLUENCE_PRICE_INDEX = data.getBoolean("world.bots_influence_ge_price", true) ServerConstants.BOTS_INFLUENCE_PRICE_INDEX = data.getBoolean("world.bots_influence_ge_price", true)

View file

@ -64,6 +64,12 @@ grand_exchange_data_path = "@data/eco"
rare_drop_table_path = "@data/RDT.xml" rare_drop_table_path = "@data/RDT.xml"
#path to file defining c.ele minor drop table #path to file defining c.ele minor drop table
cele_drop_table_path = "@data/CELEDT.xml" 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 #path to file containing boot-time object changes
object_parser_path = "@data/ObjectParser.xml" object_parser_path = "@data/ObjectParser.xml"
#path logs are written to #path logs are written to

View file

@ -86,6 +86,12 @@ grand_exchange_data_path = "@data/eco"
rare_drop_table_path = "@data/RDT.xml" rare_drop_table_path = "@data/RDT.xml"
#path to file defining c.ele minor drop table #path to file defining c.ele minor drop table
cele_drop_table_path = "@data/CELEDT.xml" 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 #path to file containing boot-time object changes
object_parser_path = "@data/ObjectParser.xml" object_parser_path = "@data/ObjectParser.xml"
#path logs are written to #path logs are written to