From 2dc4ac49f4463464e7d9d33e090925f1fc5703e3 Mon Sep 17 00:00:00 2001 From: vk Date: Thu, 23 Sep 2021 12:47:33 -0700 Subject: [PATCH] ironman drop fix: get drop if npcs delt damage. Currenly the check is done against the entire ImpactLog, which includes NPC damage. This becomes very annoying when it comes to places like god wars where npcs constantly attach each other. This change makes the loot check only look at other players, and not npcs. The ironman player in question still has to do the most damage (including npcs) to get the drop. --- .../core/game/node/entity/combat/ImpactHandler.java | 10 ++++++++++ .../src/main/java/core/game/node/entity/npc/NPC.java | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Server/src/main/java/core/game/node/entity/combat/ImpactHandler.java b/Server/src/main/java/core/game/node/entity/combat/ImpactHandler.java index f173c4ed7..46fe57c21 100644 --- a/Server/src/main/java/core/game/node/entity/combat/ImpactHandler.java +++ b/Server/src/main/java/core/game/node/entity/combat/ImpactHandler.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Queue; +import java.util.stream.Collectors; /** * Class used for handling combat impacts. @@ -262,6 +263,15 @@ public final class ImpactHandler { return impactLog; } + /** + * Gets the impact log filtered for Player objects + * @return The impact log of each Player and their damage + */ + public Map getPlayerImpactLog() { + return impactLog.entrySet().stream().filter(entry -> entry.getKey() instanceof Player).collect( + Collectors.toMap(m -> m.getKey().asPlayer(), m -> m.getValue())); + } + /** * Checks if the entity needs a hit update. * @return {@code True} if so. diff --git a/Server/src/main/java/core/game/node/entity/npc/NPC.java b/Server/src/main/java/core/game/node/entity/npc/NPC.java index 6bb1b1add..1ee2fafb5 100644 --- a/Server/src/main/java/core/game/node/entity/npc/NPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/NPC.java @@ -38,6 +38,8 @@ import rs09.game.system.config.ShopParser; import rs09.game.world.GameWorld; import rs09.game.world.repository.Repository; +import java.util.Map; + import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_BASE; import static rs09.game.node.entity.player.info.stats.StatAttributeKeysKt.STATS_ENEMIES_KILLED; @@ -543,7 +545,7 @@ public class NPC extends Entity { if (getAttribute("disable:drop", false)) { return; } - if (killer instanceof Player && p != null && p.getIronmanManager().isIronman() && getImpactHandler().getImpactLog().size() > 1) { + if (killer instanceof Player && p != null && p.getIronmanManager().isIronman() && getImpactHandler().getPlayerImpactLog().size() > 1) { return; } if (definition == null || definition.getDropTables() == null) {