Players can no longer walk where there is no map data
Fixed an issue that prevented teleblock from being used in PvP Removed redundant code that prevented PvP looting in some instances Improved strictness of grave generation rules in regards to PvP Added nothing drop to the RDT (50% chance) Implemented ring of wealth effect on rare drops (removes nothing drop) Improved handling of nothing drops, preventing dwarf remains being awarded instead of nothing in some instances Added impling IDs to the ImplingNPC definition so all implings behave like implings Crystal shield and crystal bow now degrade Made cyclops room kickout on disconnect more reliable Fixed MTA Enchantment Zone items not adhering to the zone's rules
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.ServerConstants;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.SystemLogger;
|
||||
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 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 core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the rare drop table.
|
||||
* @author Ceikry
|
||||
*/
|
||||
public final class RareDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the rare drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 31;
|
||||
|
||||
/**
|
||||
* The rare 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 RareDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.RDT_DATA_PATH != null && !new File(ServerConstants.RDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.RDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the RDT.
|
||||
* @param file the .xml file containing the RDT.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package content.data.tables
|
||||
|
||||
import core.ServerConstants
|
||||
import core.api.StartupListener
|
||||
import core.api.shouldRemoveNothings
|
||||
import core.api.utils.WeightBasedTable
|
||||
import core.api.utils.WeightedItem
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.tools.RandomFunction
|
||||
import core.tools.SystemLogger.logErr
|
||||
import core.tools.SystemLogger.logInfo
|
||||
import org.rs09.consts.Items
|
||||
import org.w3c.dom.Element
|
||||
import org.w3c.dom.Node
|
||||
import java.io.File
|
||||
import javax.xml.parsers.DocumentBuilder
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.parsers.ParserConfigurationException
|
||||
|
||||
/**
|
||||
* Handles the rare drop table.
|
||||
* @author Ceikry
|
||||
*/
|
||||
class RareDropTable : StartupListener {
|
||||
override fun startup() {
|
||||
if (ServerConstants.RDT_DATA_PATH != null && !File(ServerConstants.RDT_DATA_PATH).exists()) {
|
||||
logErr(this.javaClass, "Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH)
|
||||
return
|
||||
}
|
||||
parse(ServerConstants.RDT_DATA_PATH)
|
||||
logInfo(this.javaClass, "Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TABLE: WeightBasedTable = object : WeightBasedTable() {
|
||||
override fun roll(receiver: Entity?): ArrayList<Item> {
|
||||
val items = ArrayList(guaranteedItems)
|
||||
var effectiveWeight = totalWeight
|
||||
val p = if (receiver is Player) receiver else null
|
||||
if (p != null && shouldRemoveNothings(p))
|
||||
effectiveWeight -= nothingWeight
|
||||
|
||||
if (this.size == 1) {
|
||||
items.add(get(0))
|
||||
} else if (!this.isEmpty()) {
|
||||
var rngWeight = RandomFunction.randomDouble(effectiveWeight)
|
||||
for (item in this.shuffled()) {
|
||||
if (item.id == Items.DWARF_REMAINS_0) continue
|
||||
rngWeight -= item.weight
|
||||
if (rngWeight <= 0) {
|
||||
items.add(item)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return convertWeightedItems(items, receiver)
|
||||
}
|
||||
|
||||
private val nothingWeight: Double
|
||||
get() {
|
||||
var sum = 0.0
|
||||
for (i in this) {
|
||||
if (i.id == Items.DWARF_REMAINS_0)
|
||||
sum += i.weight
|
||||
}
|
||||
return sum
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
var factory = DocumentBuilderFactory.newInstance()
|
||||
var builder: DocumentBuilder? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder()
|
||||
} catch (e: ParserConfigurationException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the RDT.
|
||||
* @param file the .xml file containing the RDT.
|
||||
*/
|
||||
fun parse(file: String?) {
|
||||
try {
|
||||
val doc = builder!!.parse(file)
|
||||
val itemNodes = doc.getElementsByTagName("item")
|
||||
for (i in 0 until itemNodes.length) {
|
||||
val itemNode = itemNodes.item(i)
|
||||
if (itemNode.nodeType == Node.ELEMENT_NODE) {
|
||||
val item = itemNode as Element
|
||||
val itemId = item.getAttribute("id").toInt()
|
||||
val minAmt = item.getAttribute("minAmt").toInt()
|
||||
val maxAmt = item.getAttribute("maxAmt").toInt()
|
||||
val weight = item.getAttribute("weight").toInt()
|
||||
TABLE.add(WeightedItem(itemId, minAmt, maxAmt, weight.toDouble(), false))
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun retrieve(receiver: Entity?): Item? {
|
||||
return TABLE.roll(receiver).getOrNull(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user