Charm table population no longer uses heuristics
This commit is contained in:
@@ -8,13 +8,11 @@ import core.game.node.item.Item
|
|||||||
import core.tools.RandomFunction
|
import core.tools.RandomFunction
|
||||||
import org.rs09.consts.Items
|
import org.rs09.consts.Items
|
||||||
|
|
||||||
private val CHARMS = intArrayOf(Items.CRIMSON_CHARM_12160,Items.BLUE_CHARM_12163,Items.GREEN_CHARM_12159,Items.GOLD_CHARM_12158)
|
|
||||||
class NPCDropTable : WeightBasedTable() {
|
class NPCDropTable : WeightBasedTable() {
|
||||||
val charmDrops = WeightBasedTable()
|
val charmDrops = WeightBasedTable()
|
||||||
|
|
||||||
override fun add(element: WeightedItem): Boolean {
|
fun addToCharms(element: WeightedItem): Boolean {
|
||||||
return if(CHARMS.contains(element.id)) charmDrops.add(element)
|
return charmDrops.add(element)
|
||||||
else super.add(element)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun roll(player: Player?): ArrayList<Item> {
|
override fun roll(player: Player?): ArrayList<Item> {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.json.simple.JSONArray
|
|||||||
import org.json.simple.JSONObject
|
import org.json.simple.JSONObject
|
||||||
import org.json.simple.parser.JSONParser
|
import org.json.simple.parser.JSONParser
|
||||||
import rs09.ServerConstants
|
import rs09.ServerConstants
|
||||||
|
import rs09.game.content.global.NPCDropTable
|
||||||
import rs09.game.content.global.WeightBasedTable
|
import rs09.game.content.global.WeightBasedTable
|
||||||
import rs09.game.content.global.WeightedItem
|
import rs09.game.content.global.WeightedItem
|
||||||
import rs09.game.system.SystemLogger
|
import rs09.game.system.SystemLogger
|
||||||
@@ -24,7 +25,7 @@ class DropTableParser {
|
|||||||
val def = NPCDefinition.forId(n.toInt()).dropTables
|
val def = NPCDefinition.forId(n.toInt()).dropTables
|
||||||
def ?: continue
|
def ?: continue
|
||||||
parseTable(tab["main"] as JSONArray, def.table, false)
|
parseTable(tab["main"] as JSONArray, def.table, false)
|
||||||
parseTable(tab["charm"] as JSONArray, def.table, false)
|
parseTable(tab["charm"] as JSONArray, def.table, false, true)
|
||||||
parseTable(tab["default"] as JSONArray,def.table,true)
|
parseTable(tab["default"] as JSONArray,def.table,true)
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
@@ -32,7 +33,7 @@ class DropTableParser {
|
|||||||
SystemLogger.logInfo("Parsed $count drop tables.")
|
SystemLogger.logInfo("Parsed $count drop tables.")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseTable(data: JSONArray, destTable: WeightBasedTable, isAlways: Boolean) {
|
private fun parseTable(data: JSONArray, destTable: NPCDropTable, isAlways: Boolean, isCharms: Boolean = false) {
|
||||||
for(it in data){
|
for(it in data){
|
||||||
val item = it as JSONObject
|
val item = it as JSONObject
|
||||||
val id = item["id"].toString().toInt()
|
val id = item["id"].toString().toInt()
|
||||||
@@ -40,7 +41,8 @@ class DropTableParser {
|
|||||||
val maxAmount = item["maxAmount"].toString().toInt()
|
val maxAmount = item["maxAmount"].toString().toInt()
|
||||||
val weight = item["weight"].toString().toDouble()
|
val weight = item["weight"].toString().toDouble()
|
||||||
val newItem = WeightedItem(id,minAmount,maxAmount,weight.toDouble(),isAlways)
|
val newItem = WeightedItem(id,minAmount,maxAmount,weight.toDouble(),isAlways)
|
||||||
destTable.add(newItem)
|
if(isCharms) destTable.addToCharms(newItem)
|
||||||
|
else destTable.add(newItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user