From 0f83943d4f88d7d6e2e805f3f35395f98080a137 Mon Sep 17 00:00:00 2001 From: ceikry Date: Sat, 28 Aug 2021 16:19:03 -0500 Subject: [PATCH] Charm table population no longer uses heuristics --- .../main/kotlin/rs09/game/content/global/NPCDropTable.kt | 6 ++---- .../kotlin/rs09/game/system/config/DropTableParser.kt | 8 +++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Server/src/main/kotlin/rs09/game/content/global/NPCDropTable.kt b/Server/src/main/kotlin/rs09/game/content/global/NPCDropTable.kt index 9a71eb5f8..65b29d673 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/NPCDropTable.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/NPCDropTable.kt @@ -8,13 +8,11 @@ import core.game.node.item.Item import core.tools.RandomFunction 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() { val charmDrops = WeightBasedTable() - override fun add(element: WeightedItem): Boolean { - return if(CHARMS.contains(element.id)) charmDrops.add(element) - else super.add(element) + fun addToCharms(element: WeightedItem): Boolean { + return charmDrops.add(element) } override fun roll(player: Player?): ArrayList { diff --git a/Server/src/main/kotlin/rs09/game/system/config/DropTableParser.kt b/Server/src/main/kotlin/rs09/game/system/config/DropTableParser.kt index a40820697..78a715a65 100644 --- a/Server/src/main/kotlin/rs09/game/system/config/DropTableParser.kt +++ b/Server/src/main/kotlin/rs09/game/system/config/DropTableParser.kt @@ -5,6 +5,7 @@ import org.json.simple.JSONArray import org.json.simple.JSONObject import org.json.simple.parser.JSONParser import rs09.ServerConstants +import rs09.game.content.global.NPCDropTable import rs09.game.content.global.WeightBasedTable import rs09.game.content.global.WeightedItem import rs09.game.system.SystemLogger @@ -24,7 +25,7 @@ class DropTableParser { val def = NPCDefinition.forId(n.toInt()).dropTables def ?: continue 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) count++ } @@ -32,7 +33,7 @@ class DropTableParser { 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){ val item = it as JSONObject val id = item["id"].toString().toInt() @@ -40,7 +41,8 @@ class DropTableParser { val maxAmount = item["maxAmount"].toString().toInt() val weight = item["weight"].toString().toDouble() val newItem = WeightedItem(id,minAmount,maxAmount,weight.toDouble(),isAlways) - destTable.add(newItem) + if(isCharms) destTable.addToCharms(newItem) + else destTable.add(newItem) } } } \ No newline at end of file