From 1a48009b8507a551bfca96019fa5336291e5a39f Mon Sep 17 00:00:00 2001 From: Player Name Date: Sat, 27 Jun 2026 15:28:37 +0200 Subject: [PATCH] barrage debugging --- .../node/entity/combat/spell/CombatSpell.java | 2 +- .../main/core/game/world/map/RegionManager.kt | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java b/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java index 6ac567b15..ce84e520d 100644 --- a/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java +++ b/Server/src/main/core/game/node/entity/combat/spell/CombatSpell.java @@ -121,7 +121,7 @@ public abstract class CombatSpell extends MagicSpell { List victims = new ArrayList<>(20); victims.add(target); - List surrounding = RegionManager.getLocalEntities(target.getLocation(), 1); + List surrounding = RegionManager.getLocalEntitiesIce(target.getLocation(), 1); for (Entity e : surrounding) { if (e == target || e == entity) { continue; diff --git a/Server/src/main/core/game/world/map/RegionManager.kt b/Server/src/main/core/game/world/map/RegionManager.kt index 5586549f2..fa242a789 100644 --- a/Server/src/main/core/game/world/map/RegionManager.kt +++ b/Server/src/main/core/game/world/map/RegionManager.kt @@ -453,6 +453,37 @@ object RegionManager { @JvmStatic fun getSurroundingNPCs(npc: Entity, maximum: Int): List = getLocalEntities(npc.location, 1, maximum, null) @JvmStatic fun getLocalPlayersBoundingBox(location: Location, maximum: Int): List = getLocalEntities(location, 1, maximum, null) + @JvmStatic fun getLocalEntitiesIce(location: Location, distance: Int): List { + val maximum = 0 + val ignore = null + + val entities: MutableList = ArrayList(20) + for (cx in (location.absChunkX - 0)..(location.absChunkX + 0)) { + for (cy in (location.absChunkY - 0)..(location.absChunkY + 0)) { + println("cx = $cx, cy = $cy, loc = $location, cx shl 3 = ${cx shl 3}, cy shl 3 = ${cy shl 3}") + val loc = Location(cx shl 3, cy shl 3, location.z) + println("Grabbing chunk at $cx,$cy, which is location $loc") + val chunk = Location(cx shl 3, cy shl 3, location.z).chunk + if (Entity::class.java.isAssignableFrom(Player::class.java)) { + println("adding players, of which there are ${chunk.players.size}") + entities.addAll(chunk.players as Collection) + } + if (Entity::class.java.isAssignableFrom(NPC::class.java)) { + println("adding npcs, of which there are ${chunk.npcs.size}") + entities.addAll(chunk.npcs as Collection) + } + println("Processed a chunk, now have ${entities.size} entities") + } + } + val b = ZoneBorders(location.x - distance, location.y - distance, location.x + distance, location.y + distance) + var filtered = entities.filter { it != ignore && b.insideBorder(it.location.x, it.location.y) } + if (maximum > 0 && filtered.size > maximum) { + filtered = filtered.slice(0 until maximum) + } + println("After filtering, ${entities.size} entities") + return filtered + } + /** * Gets a random teleport location in the radius around the given location. * @param location The centre location.