Improved the performance of drop table rolling
Chromatic Dragon eggs now only drop at a 1/1000 rate if the player has 99 summoning, impossible to obtain otherwise
This commit is contained in:
@@ -31,7 +31,9 @@ import kotlin.math.floor
|
||||
* @author Emperor
|
||||
* @author Ceikry - Kotlin refactoring, general cleanup
|
||||
*/
|
||||
abstract class CombatSwingHandler(var type: CombatStyle?, vararg val flags: SwingHandlerFlag) {
|
||||
abstract class CombatSwingHandler(var type: CombatStyle?) {
|
||||
var flags: Array<out SwingHandlerFlag> = emptyArray()
|
||||
constructor(type: CombatStyle?, vararg flags: SwingHandlerFlag) : this(type) { this.flags = flags }
|
||||
/**
|
||||
* The mapping of the special attack handlers.
|
||||
*/
|
||||
|
||||
@@ -74,11 +74,17 @@ public final class NPCDropTables {
|
||||
*/
|
||||
public void drop(NPC npc, Entity looter) {
|
||||
Player p = looter instanceof Player ? (Player) looter : null;
|
||||
ArrayList<Item> drops = table.roll(looter);
|
||||
ArrayList<Item> drops = table.roll(looter, 1);
|
||||
npc.behavior.onDropTableRolled(npc, looter, drops);
|
||||
drops.forEach(item -> createDrop(item,p,npc,npc.getDropLocation()));
|
||||
}
|
||||
|
||||
public List<Item> roll (NPC npc, Entity looter, int times) {
|
||||
ArrayList<Item> drops = table.roll(looter, times);
|
||||
npc.behavior.onDropTableRolled(npc, looter, drops);
|
||||
return drops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dropped item.
|
||||
* @param item The item to drop.
|
||||
|
||||
@@ -167,13 +167,8 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) {
|
||||
val amount = args[2].toInt()
|
||||
|
||||
container.clear()
|
||||
|
||||
for(i in 0..amount)
|
||||
{
|
||||
val drops = NPCDefinition.forId(npcId).dropTables.table.roll(player)
|
||||
for(drop in drops) container.add(drop)
|
||||
}
|
||||
|
||||
val drops = NPCDefinition.forId(npcId).dropTables.table.roll(player, amount)
|
||||
for(drop in drops) container.add(drop, false)
|
||||
container.open(player)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user