From a484d4ff940aa785593119d3d9e5dd0465d5325b Mon Sep 17 00:00:00 2001 From: FrozenEarth Date: Sat, 7 Sep 2024 07:49:43 -0500 Subject: [PATCH 1/2] grant first kills to other nearby players --- .../libraryofsouls/bestiary/BestiaryManager.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java b/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java index 6e3b084..1625e40 100644 --- a/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java +++ b/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java @@ -174,12 +174,26 @@ public void entityDeathEvent(EntityDeathEvent event) { } }); } else { - // Not a boss, just record kill for the killer + // Not a boss, record kill for the killer try { mStorage.recordKill(player, soul); } catch (Exception ex) { mLogger.warning(ex.getMessage()); } + + // also check if any nearby player has not killed that mob before, and give them the kill + // good for both unlocking the entry in group play, and also to stop descriptions from showing up too many times + List otherPlayers = player.getWorld().getPlayers(); + otherPlayers.remove(player); + otherPlayers.removeIf(p -> p.getLocation().distance(player.getLocation()) > 20); + otherPlayers.removeIf(p -> getKillsForMob(p, soul) > 0); + for (Player p : otherPlayers) { + try { + mStorage.recordKill(p, soul); + } catch (Exception ex) { + mLogger.warning(ex.getMessage()); + } + } } } } catch (Exception ex) { From de000d19f2cee05d44ed9d40eb33412cca6e4f82 Mon Sep 17 00:00:00 2001 From: FrozenEarth Date: Sat, 7 Sep 2024 08:15:07 -0500 Subject: [PATCH 2/2] distance squared --- .../playmonumenta/libraryofsouls/bestiary/BestiaryManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java b/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java index 1625e40..beaa13e 100644 --- a/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java +++ b/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiaryManager.java @@ -185,7 +185,7 @@ public void entityDeathEvent(EntityDeathEvent event) { // good for both unlocking the entry in group play, and also to stop descriptions from showing up too many times List otherPlayers = player.getWorld().getPlayers(); otherPlayers.remove(player); - otherPlayers.removeIf(p -> p.getLocation().distance(player.getLocation()) > 20); + otherPlayers.removeIf(p -> p.getLocation().distanceSquared(player.getLocation()) > 20 * 20); otherPlayers.removeIf(p -> getKillsForMob(p, soul) > 0); for (Player p : otherPlayers) { try {