mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-11 17:10:21 -07:00
NPC drop tables -> NPCDropTable.kt
Corrections to HAM members
This commit is contained in:
parent
398ea3b411
commit
c59f66f7c5
7 changed files with 107 additions and 60 deletions
|
|
@ -1,22 +1,26 @@
|
|||
package core.game.node.entity.npc.drop;
|
||||
|
||||
import core.cache.def.impl.NPCDefinition;
|
||||
import core.game.node.item.*;
|
||||
import rs09.game.system.config.ItemConfigParser;
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import rs09.game.ai.AIRepository;
|
||||
import rs09.game.ai.general.GeneralBotCreator;
|
||||
import core.game.ge.GrandExchangeDatabase;
|
||||
import core.game.content.global.Bones;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.ge.GrandExchangeDatabase;
|
||||
import core.game.node.entity.Entity;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.item.GroundItem;
|
||||
import core.game.node.item.GroundItemManager;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.RegionManager;
|
||||
import rs09.game.world.repository.Repository;
|
||||
import core.tools.RandomFunction;
|
||||
import core.tools.StringUtils;
|
||||
import rs09.game.ai.AIPlayer;
|
||||
import rs09.game.ai.AIRepository;
|
||||
import rs09.game.ai.general.GeneralBotCreator;
|
||||
import rs09.game.content.global.NPCDropTable;
|
||||
import rs09.game.system.config.ItemConfigParser;
|
||||
import rs09.game.world.repository.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -52,6 +56,8 @@ public final class NPCDropTables {
|
|||
*/
|
||||
private final List<WeightedChanceItem> mainTable = new ArrayList<>(20);
|
||||
|
||||
public final NPCDropTable table = new NPCDropTable();
|
||||
|
||||
/**
|
||||
* The NPC definitions.
|
||||
*/
|
||||
|
|
@ -82,26 +88,7 @@ public final class NPCDropTables {
|
|||
*/
|
||||
public void drop(NPC npc, Entity looter) {
|
||||
Player p = looter instanceof Player ? (Player) looter : null;
|
||||
if (!charmTable.isEmpty()) {
|
||||
boolean rollCharms = RandomFunction.random(5) == 3;
|
||||
if(rollCharms) {
|
||||
createDrop(RandomFunction.rollWeightedChanceTable(charmTable),p,npc,npc.getDropLocation());
|
||||
}
|
||||
}
|
||||
defaultTable.forEach(drop -> {
|
||||
createDrop(drop.getItem(),p,npc,npc.getDropLocation());
|
||||
});
|
||||
Item item = RandomFunction.rollWeightedChanceTable(mainTable);
|
||||
//boolean hasWealthRing = p != null && p.getEquipment().getNew(EquipmentContainer.SLOT_RING).getId() == 2572;
|
||||
if(item != null) {
|
||||
boolean isRDTSlot = item.getId() == RareDropTable.SLOT_ITEM_ID;
|
||||
if (isRDTSlot) {
|
||||
item = RareDropTable.retrieve();
|
||||
}
|
||||
if (item != null && p != null && npc != null) {
|
||||
createDrop(item, p, npc, npc.getDropLocation());
|
||||
}
|
||||
}
|
||||
table.roll().forEach(item -> createDrop(item,p,npc,npc.getDropLocation()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package rs09.game.content.global
|
||||
|
||||
import core.game.content.ttrail.ClueLevel
|
||||
import core.game.content.ttrail.ClueScrollPlugin
|
||||
import core.game.node.entity.npc.drop.RareDropTable
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.tools.RandomFunction
|
||||
|
|
@ -14,13 +17,14 @@ class NPCDropTable : WeightBasedTable() {
|
|||
else super.add(element)
|
||||
}
|
||||
|
||||
override fun roll(player: Player): ArrayList<Item> {
|
||||
override fun roll(player: Player?): ArrayList<Item> {
|
||||
if(size == 0) return ArrayList()
|
||||
val items= ArrayList<Item>(3)
|
||||
var tempWeight = RandomFunction.randomDouble(totalWeight)
|
||||
items.addAll(guaranteedItems.map { it.getItem() }.toList())
|
||||
|
||||
if(RandomFunction.random(1,15) == 5){
|
||||
items.addAll(charmDrops.roll(player))
|
||||
items.addAll(charmDrops.roll(null))
|
||||
}
|
||||
if(size == 1){
|
||||
items.add(get(0).getItem())
|
||||
|
|
@ -30,7 +34,13 @@ class NPCDropTable : WeightBasedTable() {
|
|||
for (item in shuffled()) {
|
||||
tempWeight -= item.weight
|
||||
if (tempWeight <= 0) {
|
||||
items.add(item.getItem())
|
||||
when(item.id){
|
||||
SLOT_CLUE_EASY -> items.add(ClueScrollPlugin.getClue(ClueLevel.EASY))
|
||||
SLOT_CLUE_MEDIUM -> items.add(ClueScrollPlugin.getClue(ClueLevel.MEDIUM))
|
||||
SLOT_CLUE_HARD -> items.add(ClueScrollPlugin.getClue(ClueLevel.HARD))
|
||||
SLOT_RDT -> items.add(RareDropTable.retrieve())
|
||||
else -> items.add(item.getItem())
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
package rs09.game.content.global
|
||||
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import core.game.content.ttrail.ClueLevel
|
||||
import core.game.content.ttrail.ClueScrollPlugin
|
||||
import core.game.node.entity.npc.drop.RareDropTable
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
|
||||
open class WeightBasedTable : ArrayList<WeightedItem>() {
|
||||
var totalWeight = 0.0
|
||||
|
|
@ -14,12 +19,17 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
|
|||
else super.add(element)
|
||||
}
|
||||
|
||||
open fun roll(player: Player): ArrayList<Item>{
|
||||
fun roll(): ArrayList<Item>{
|
||||
return roll(null)
|
||||
}
|
||||
|
||||
open fun roll(player: Player?): ArrayList<Item>{
|
||||
if(size == 0) return ArrayList()
|
||||
val items= ArrayList<Item>(3)
|
||||
var tempWeight = RandomFunction.randomDouble(totalWeight)
|
||||
items.addAll(guaranteedItems.map { it.getItem() }.toList())
|
||||
|
||||
if(player.inventory.isFull){
|
||||
if(player?.inventory?.isFull == true){
|
||||
return items
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +37,13 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
|
|||
for (item in shuffled()) {
|
||||
tempWeight -= item.weight
|
||||
if (tempWeight <= 0) {
|
||||
items.add(item.getItem())
|
||||
when(item.id){
|
||||
SLOT_CLUE_EASY -> items.add(ClueScrollPlugin.getClue(ClueLevel.EASY))
|
||||
SLOT_CLUE_MEDIUM -> items.add(ClueScrollPlugin.getClue(ClueLevel.MEDIUM))
|
||||
SLOT_CLUE_HARD -> items.add(ClueScrollPlugin.getClue(ClueLevel.HARD))
|
||||
SLOT_RDT -> items.add(RareDropTable.retrieve())
|
||||
else -> items.add(item.getItem())
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +56,28 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
|
|||
return (player.inventory.hasSpaceFor(*guaranteed) && guaranteed.isNotEmpty()) || !player.inventory.isFull
|
||||
}
|
||||
|
||||
|
||||
fun insertEasyClue(weight: Double): WeightBasedTable{
|
||||
this.add(WeightedItem(SLOT_CLUE_EASY,1,1,weight,false))
|
||||
return this
|
||||
}
|
||||
|
||||
fun insertMediumClue(weight: Double): WeightBasedTable{
|
||||
this.add(WeightedItem(SLOT_CLUE_MEDIUM,1,1,weight,false))
|
||||
return this
|
||||
}
|
||||
|
||||
fun insertHardClue(weight: Double): WeightBasedTable{
|
||||
this.add(WeightedItem(SLOT_CLUE_HARD,1,1,weight,false))
|
||||
return this
|
||||
}
|
||||
|
||||
fun insertRDTRoll(weight: Double): WeightBasedTable{
|
||||
this.add(WeightedItem(SLOT_RDT,1,1,weight,false))
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(vararg items: WeightedItem): WeightBasedTable{
|
||||
|
|
@ -49,5 +87,20 @@ open class WeightBasedTable : ArrayList<WeightedItem>() {
|
|||
}
|
||||
return table
|
||||
}
|
||||
|
||||
@JvmField
|
||||
val SLOT_RDT = Items.TINDERBOX_31
|
||||
val SLOT_CLUE_EASY = Items.TOOLKIT_1
|
||||
val SLOT_CLUE_MEDIUM = Items.ROTTEN_POTATO_5733
|
||||
val SLOT_CLUE_HARD = Items.GRANITE_LOBSTER_POUCH_12070
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val builder = StringBuilder()
|
||||
for(item in this){
|
||||
builder.append("${ItemDefinition.forId(item.id).name} || Weight: ${item.weight} || MinAmt: ${item.minAmt} || maxAmt: ${item.maxAmt}")
|
||||
builder.appendLine()
|
||||
}
|
||||
return builder.toString()
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ class ShootingStarEvent : WorldEvent("shooting-stars") {
|
|||
override fun initialize() {
|
||||
plugins = PluginSet(
|
||||
ScoreboardHandler(),
|
||||
ShootingStarOptionHandler(),
|
||||
ShootingStarScoreboard(),
|
||||
StarChartPlugin(),
|
||||
ShootingStarCommands(),
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ enum class Pickpockets(val ids: IntArray, val requiredLevel: Int, val low: Doubl
|
|||
WeightedItem(Items.UNCUT_OPAL_1625,1,1,2.5),
|
||||
WeightedItem(Items.RAW_ANCHOVIES_321,1,1,7.0),
|
||||
WeightedItem(Items.RAW_CHICKEN_2138,1,1,3.5),
|
||||
WeightedItem(Items.HAM_CLOAK_4304,1,1,1.0),
|
||||
WeightedItem(Items.HAM_HOOD_4302,1,1,1.0),
|
||||
WeightedItem(Items.HAM_LOGO_4306,1,1,1.0),
|
||||
WeightedItem(Items.HAM_ROBE_4300,1,1,1.0),
|
||||
WeightedItem(Items.HAM_CLOAK_4304,1,1,0.25),
|
||||
WeightedItem(Items.HAM_HOOD_4302,1,1,0.25),
|
||||
WeightedItem(Items.HAM_LOGO_4306,1,1,0.25),
|
||||
WeightedItem(Items.HAM_ROBE_4300,1,1,0.25),
|
||||
WeightedItem(Items.BOOTS_4310,1,1,1.0),
|
||||
WeightedItem(Items.GLOVES_4308,1,1,1.0),
|
||||
WeightedItem(Items.BRONZE_PICKAXE_1265,1,1,5.0),
|
||||
|
|
@ -42,7 +42,7 @@ enum class Pickpockets(val ids: IntArray, val requiredLevel: Int, val low: Doubl
|
|||
WeightedItem(Items.BROKEN_ARMOUR_698,1,1,3.5),
|
||||
WeightedItem(Items.BROKEN_STAFF_689,1,1,3.2),
|
||||
WeightedItem(Items.BROKEN_ARROW_687,1,1,3.1)
|
||||
)),
|
||||
).insertEasyClue(1.0)),
|
||||
FEMALE_HAM_MEMBER(intArrayOf(1715), 15, 135.0, 240.0, 18.5, 1,3,4, WeightBasedTable.create(
|
||||
WeightedItem(Items.COINS_995,1,21,5.5),
|
||||
WeightedItem(Items.TINDERBOX_590,1,1,5.0),
|
||||
|
|
@ -51,10 +51,10 @@ enum class Pickpockets(val ids: IntArray, val requiredLevel: Int, val low: Doubl
|
|||
WeightedItem(Items.UNCUT_OPAL_1625,1,1,2.5),
|
||||
WeightedItem(Items.RAW_ANCHOVIES_321,1,1,7.0),
|
||||
WeightedItem(Items.RAW_CHICKEN_2138,1,1,3.5),
|
||||
WeightedItem(Items.HAM_CLOAK_4304,1,1,1.0),
|
||||
WeightedItem(Items.HAM_HOOD_4302,1,1,1.0),
|
||||
WeightedItem(Items.HAM_LOGO_4306,1,1,1.0),
|
||||
WeightedItem(Items.HAM_ROBE_4300,1,1,1.0),
|
||||
WeightedItem(Items.HAM_CLOAK_4304,1,1,0.25),
|
||||
WeightedItem(Items.HAM_HOOD_4302,1,1,0.25),
|
||||
WeightedItem(Items.HAM_LOGO_4306,1,1,0.25),
|
||||
WeightedItem(Items.HAM_ROBE_4300,1,1,0.25),
|
||||
WeightedItem(Items.BOOTS_4310,1,1,1.0),
|
||||
WeightedItem(Items.GLOVES_4308,1,1,1.0),
|
||||
WeightedItem(Items.BRONZE_PICKAXE_1265,1,1,5.0),
|
||||
|
|
@ -68,7 +68,7 @@ enum class Pickpockets(val ids: IntArray, val requiredLevel: Int, val low: Doubl
|
|||
WeightedItem(Items.BROKEN_ARMOUR_698,1,1,3.5),
|
||||
WeightedItem(Items.BROKEN_STAFF_689,1,1,3.2),
|
||||
WeightedItem(Items.BROKEN_ARROW_687,1,1,3.1)
|
||||
)),
|
||||
).insertEasyClue(1.0)),
|
||||
WARRIOR(intArrayOf(15, 18), 25, 84.0, 240.0, 26.0, 2, 2, 5, WeightBasedTable.create(
|
||||
WeightedItem(Items.COINS_995,18,18,1.0,true)
|
||||
)),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import core.game.world.update.flag.context.Animation
|
|||
import core.tools.RandomFunction
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.tools.secondsToTicks
|
||||
|
||||
class ThievingListeners : InteractionListener() {
|
||||
|
|
@ -24,6 +25,7 @@ class ThievingListeners : InteractionListener() {
|
|||
on(NPC,"pickpocket","pick-pocket"){player, node ->
|
||||
val pickpocketData = Pickpockets.forID(node.id) ?: return@on false
|
||||
var successMod = 0
|
||||
SystemLogger.logInfo(pickpocketData.table.toString())
|
||||
|
||||
if(player.inCombat()){
|
||||
player.sendMessage("You can't pickpocket while in combat.")
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package rs09.game.system.config
|
||||
|
||||
import rs09.ServerConstants
|
||||
import core.cache.def.impl.NPCDefinition
|
||||
import core.game.node.item.WeightedChanceItem
|
||||
import rs09.game.system.SystemLogger
|
||||
import org.json.simple.JSONArray
|
||||
import org.json.simple.JSONObject
|
||||
import org.json.simple.parser.JSONParser
|
||||
import rs09.ServerConstants
|
||||
import rs09.game.content.global.WeightBasedTable
|
||||
import rs09.game.content.global.WeightedItem
|
||||
import rs09.game.system.SystemLogger
|
||||
import java.io.FileReader
|
||||
import java.util.*
|
||||
|
||||
class DropTableParser {
|
||||
val parser = JSONParser()
|
||||
|
|
@ -23,28 +23,24 @@ class DropTableParser {
|
|||
for(n in ids){
|
||||
val def = NPCDefinition.forId(n.toInt()).dropTables
|
||||
def ?: continue
|
||||
val mainTable: List<WeightedChanceItem> = parseTable(tab["main"] as JSONArray)
|
||||
val charmTable: List<WeightedChanceItem> = parseTable(tab["charm"] as JSONArray)
|
||||
val defaultTable: List<WeightedChanceItem> = parseTable(tab["default"] as JSONArray)
|
||||
def.mainTable.addAll(mainTable)
|
||||
def.charmTable.addAll(charmTable)
|
||||
def.defaultTable.addAll(defaultTable)
|
||||
parseTable(tab["main"] as JSONArray, def.table, false)
|
||||
parseTable(tab["charm"] as JSONArray, def.table, false)
|
||||
parseTable(tab["default"] as JSONArray,def.table,true)
|
||||
count++
|
||||
}
|
||||
}
|
||||
SystemLogger.logInfo("Parsed $count drop tables.")
|
||||
}
|
||||
|
||||
private fun parseTable(data: JSONArray): List<WeightedChanceItem> {
|
||||
val table: MutableList<WeightedChanceItem> = ArrayList()
|
||||
private fun parseTable(data: JSONArray, destTable: WeightBasedTable, isAlways: Boolean) {
|
||||
for(it in data){
|
||||
val item = it as JSONObject
|
||||
val id = item["id"].toString().toInt()
|
||||
val minAmount = item["minAmount"].toString().toInt()
|
||||
val maxAmount = item["maxAmount"].toString().toInt()
|
||||
val weight = item["weight"].toString().toInt()
|
||||
val newItem = WeightedChanceItem(id,minAmount,maxAmount,weight)
|
||||
table.add(newItem)
|
||||
val newItem = WeightedItem(id,minAmount,maxAmount,weight.toDouble(),isAlways)
|
||||
destTable.add(newItem)
|
||||
}
|
||||
return table
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue