fix clue scroll drops.

There is a fairly significant bug with clue scrolls. The only npcs that drops clue scrolls right now are hellhonds (that is because their ids are hard-coded in TreasureTrailPlugin.createDrop()). All other npcs do not drop clues due to a bug in `NPCDropTables`.

`NPCDropTables` has two separate ways to access the actual table: one is though `List<WeightedChanceItem> defaultTable`, ` List<WeightedChanceItem> charmTable`, and `List<WeightedChanceItem> mainTable`; And the other is though a combined table `NPCDropTable table`. The problem is that only `NPCDropTable table` is set properly--the other 3 tables are always empty.

The reason clues were bugged was because `TreasureTrailPlugin.createDrop()` has a check for `npc.getDefinition().getDropTables().getMainTable().size() < 3`, which always fails. I really do not see the point in this check to begin with, so i am going to remove it. The hard-coded check for hellounds is pointless as well and should be removed.
I am also going to remove the 3 empty tables from `NPCDropTables` to avoid and similar bugs in the future.

Alternatively, it is possible to make changes to `DropTableParser` and keep those tables, then add post-parsing step to populate `NPCDropTable table` from them. However that would just duplicate all the data in all drops table, and since nothing else was using these individual tables, i just opted for removing them.
This commit is contained in:
vk 2021-09-28 01:44:09 -07:00
parent 4124ebdef3
commit d027728c7f
2 changed files with 1 additions and 61 deletions

View file

@ -132,16 +132,7 @@ public final class TreasureTrailPlugin extends OptionHandler {
@Override
public boolean createDrop(Item item, Player player, NPC npc, Location l) {
if ((npc.getId() == 49 || npc.getId() == 3586)) {
return true;
}
if (npc.getDefinition().getDropTables().getMainTable().size() < 3) {
return false;
}
if (!hasClue(player)) {
return true;
}
return false;
return !hasClue(player);
}
@Override

View file

@ -10,7 +10,6 @@ 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 core.tools.RandomFunction;
@ -41,21 +40,6 @@ public final class NPCDropTables {
* The npcs that will display drop messages
*/
public static final int[] MESSAGE_NPCS = { 50, 7133, 7134, 2881, 2882, 2883, 3200, 3340, 6247, 6203, 6260, 6222, 2745, 1160, 8133, 8610, 8611, 8612, 8613, 8614, 6204, 6206, 6208, 6261, 6263, 6265, 6223, 6225, 6227 };
/**
* The default drop table (holding the 100% drops).
*/
private final List<WeightedChanceItem> defaultTable = new ArrayList<>(20);
/**
* The charms drop table (holding the charm drops).
*/
private final List<WeightedChanceItem> charmTable = new ArrayList<>(20);
/**
* The main drop table (holding the main drops).
*/
private final List<WeightedChanceItem> mainTable = new ArrayList<>(20);
public final NPCDropTable table = new NPCDropTable();
@ -239,41 +223,6 @@ public final class NPCDropTables {
return (1 / (1 + def.getCombatLevel())) * 10;
}
/**
* @return the defaultTable.
*/
public List<WeightedChanceItem> getDefaultTable() {
return defaultTable;
}
/**
* @return the charmTable.
*/
public List<WeightedChanceItem> getCharmTable() {
return charmTable;
}
/**
* @return the mainTable.
*/
public List<WeightedChanceItem> getMainTable() {
return mainTable;
}
/**
* @return the mainTableSize.
*/
public int getMainTableSize() {
return mainTableSize;
}
/**
* @param mainTableSize the mainTableSize to set.
*/
public void setMainTableSize(int mainTableSize) {
this.mainTableSize = mainTableSize;
}
/**
* Gets the modRate.
* @return The modRate.