Added an Allotment Seed drop table

Reworked Farmer drop table
This commit is contained in:
Von Hresvelg
2022-12-17 07:40:18 +00:00
committed by Ryan
parent 00d460d2ba
commit e8ea397b6b
10 changed files with 190 additions and 141 deletions
+63 -141
View File
@@ -277,185 +277,107 @@
"ids": "7,1377,1757,1758,1759,1760,1761,7128,7129,7130",
"description": "",
"main": [
{
"minAmount": "1",
"weight": "5.0",
"id": "5345",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "5341",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "50.0",
"id": "5329",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "5331",
"maxAmount": "1"
},
{
"minAmount": "4",
"weight": "25.0",
"id": "5324",
"maxAmount": "4"
},
{
"minAmount": "4",
"weight": "50.0",
"id": "5323",
"maxAmount": "4"
},
{
"minAmount": "1",
"weight": "50.0",
"id": "5318",
"maxAmount": "4"
},
{
"minAmount": "4",
"weight": "25.0",
"id": "5322",
"maxAmount": "4"
},
{
"minAmount": "4",
"weight": "25.0",
"id": "5321",
"maxAmount": "4"
},
{
"minAmount": "4",
"weight": "25.0",
"id": "12148",
"maxAmount": "4"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "1965",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "313",
"maxAmount": "1"
},
{
"minAmount": "2",
"weight": "25.0",
"id": "562",
"maxAmount": "2"
},
{
"minAmount": "4",
"weight": "25.0",
"id": "556",
"weight": "2.0",
"id": "557",
"maxAmount": "4"
},
{
"minAmount": "6",
"weight": "25.0",
"weight": "2.0",
"id": "554",
"maxAmount": "6"
},
{
"minAmount": "9",
"weight": "25.0",
"weight": "2.0",
"id": "558",
"maxAmount": "9"
},
{
"minAmount": "2",
"weight": "1.0",
"id": "562",
"maxAmount": "2"
},
{
"minAmount": "1",
"weight": "25.0",
"weight": "11.0",
"id": "14424",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "27.0",
"id": "14430",
"maxAmount": "1"
},
{
"minAmount": "3",
"weight": "38.0",
"id": "995",
"maxAmount": "3"
},
{
"minAmount": "25",
"weight": "1.0",
"id": "995",
"maxAmount": "25"
},
{
"minAmount": "1",
"weight": "27.0",
"id": "0",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "313",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "3.0",
"id": "5341",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "2.0",
"id": "1440",
"maxAmount": "1"
},
{
"minAmount": "7",
"weight": "25.0",
"id": "882",
"maxAmount": "7"
},
{
"minAmount": "3",
"weight": "25.0",
"id": "877",
"maxAmount": "12"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "1139",
"weight": "2.0",
"id": "5345",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "1203",
"weight": "2.0",
"id": "5343",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "436",
"weight": "1.0",
"id": "5329",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "207",
"weight": "1.0",
"id": "5340",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "5320",
"weight": "1.0",
"id": "1",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "213",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "211",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "217",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "25.0",
"id": "5319",
"maxAmount": "1"
},
{
"minAmount": "1",
"weight": "5.0",
"id": "5733",
"maxAmount": "1"
},
{
"minAmount": "3",
"weight": "50.0",
"id": "995",
"maxAmount": "15"
}
]
},
+5
View File
@@ -130695,5 +130695,10 @@
"examine": "You should not have this.",
"name": "RSDT Slot",
"id": "14428"
},
{
"examine": "You should not have this.",
"name": "ASDT Slot",
"id": "14430"
}
]
@@ -0,0 +1,9 @@
<ASDT>
<item id="5318" minAmt="1" maxAmt="4" weight="64"/>
<item id="5319" minAmt="1" maxAmt="3" weight="32"/>
<item id="5324" minAmt="1" maxAmt="3" weight="16"/>
<item id="5322" minAmt="1" maxAmt="2" weight="8"/>
<item id="5320" minAmt="1" maxAmt="2" weight="4"/>
<item id="5323" minAmt="1" maxAmt="1" weight="2"/>
<item id="5321" minAmt="1" maxAmt="1" weight="2"/>
</ASDT>
@@ -0,0 +1,94 @@
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 allotment seed drop table.
* @author Von Hresvelg
*/
public final class AllotmentSeedDropTable implements StartupListener {
/**
* The item id of the item representing the allotment seed drop table slot in a drop
* table.
*/
public static final int SLOT_ITEM_ID = 14430;
/**
* The allotment 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 AllotmentSeedDropTable() throws ParserConfigurationException {}
@Override
public void startup() {
if(ServerConstants.ASDT_DATA_PATH != null && !new File(ServerConstants.ASDT_DATA_PATH).exists()){
SystemLogger.logErr(this.getClass(), "Can't locate ASDT file at " + ServerConstants.ASDT_DATA_PATH);
return;
}
parse(ServerConstants.ASDT_DATA_PATH);
logInfo(this.getClass(), "Initialized Allotment Seed Drop Table from " + ServerConstants.ASDT_DATA_PATH);
}
/**
* Parses the xml file for the allotment seed drop table.
* @param file the .xml file containing the allotment 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);}
}
@@ -104,6 +104,9 @@ public final class NPCDropTables {
if (item.getId() == RareSeedDropTable.SLOT_ITEM_ID){
item = RareSeedDropTable.retrieve();
}
if (item.getId() == AllotmentSeedDropTable.SLOT_ITEM_ID){
item = AllotmentSeedDropTable.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);
@@ -86,6 +86,9 @@ class ServerConstants {
@JvmField
var RSDT_DATA_PATH: String? = null
@JvmField
var ASDT_DATA_PATH: String? = null
//the max number of players.
@JvmField
var MAX_PLAYERS = 2000
@@ -9,6 +9,7 @@ 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.npc.drop.RareSeedDropTable
import core.game.node.entity.npc.drop.AllotmentSeedDropTable
import core.game.node.entity.player.Player
import core.game.node.item.Item
import core.tools.RandomFunction
@@ -61,6 +62,7 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
SLOT_HDT -> HerbDropTable.retrieve()
SLOT_GDT -> GemDropTable.retrieve()
SLOT_RSDT -> RareSeedDropTable.retrieve()
SLOT_ASDT -> AllotmentSeedDropTable.retrieve()
else -> e.getItem()
}
safeItems.add(safeItem)
@@ -118,6 +120,11 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
return this
}
fun insertASDTRoll(weight: Double): WeightBasedTable{
this.add(WeightedItem(SLOT_ASDT,1,1,weight,false))
return this
}
companion object {
@JvmStatic
fun create(vararg items: WeightedItem): WeightBasedTable{
@@ -138,6 +145,7 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
val SLOT_HDT = Items.SACRED_CLAY_POUCH_CLASS_2_14424
val SLOT_GDT = Items.SACRED_CLAY_POUCH_CLASS_3_14426
val SLOT_RSDT = Items.SACRED_CLAY_POUCH_CLASS_4_14428
val SLOT_ASDT = Items.SACRED_CLAY_POUCH_CLASS_5_14430
}
override fun toString(): String {
@@ -115,6 +115,7 @@ object ServerConfigParser {
ServerConstants.HDT_DATA_PATH = data.getPath("paths.herb_drop_table_path")
ServerConstants.GDT_DATA_PATH = data.getPath("paths.gem_drop_table_path")
ServerConstants.RSDT_DATA_PATH = data.getPath("paths.rare_seed_drop_table_path")
ServerConstants.ASDT_DATA_PATH = data.getPath("paths.allotment_seed_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)
+2
View File
@@ -73,6 +73,8 @@ herb_drop_table_path = "@data/configs/shared_tables/HDT.xml"
gem_drop_table_path = "@data/configs/shared_tables/GDT.xml"
#path to file defining the rare seed drop table
rare_seed_drop_table_path = "@data/configs/shared_tables/RSDT.xml"
#path to file defining the allotment seed drop table
allotment_seed_drop_table_path = "@data/configs/shared_tables/ASDT.xml"
#path to file containing boot-time object changes
object_parser_path = "@data/ObjectParser.xml"
#path logs are written to
+2
View File
@@ -95,6 +95,8 @@ herb_drop_table_path = "@data/configs/shared_tables/HDT.xml"
gem_drop_table_path = "@data/configs/shared_tables/GDT.xml"
#path to file defining the rare seed drop table
rare_seed_drop_table_path = "@data/configs/shared_tables/RSDT.xml"
#path to file defining the allotment seed drop table
allotment_seed_drop_table_path = "@data/configs/shared_tables/ASDT.xml"
#path to file containing boot-time object changes
object_parser_path = "@data/ObjectParser.xml"
#path logs are written to